@chevre/domain 20.2.0-alpha.48 → 20.2.0-alpha.49

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.
@@ -1,3 +1,4 @@
1
+ import { BulkWriteOpResultObject } from 'mongodb';
1
2
  import { Connection } from 'mongoose';
2
3
  import * as factory from '../factory';
3
4
  import * as EventFactory from '../factory/event';
@@ -74,12 +75,12 @@ export declare class MongoRepository {
74
75
  /**
75
76
  * 特定の追加特性をキーにして、なければ作成する(複数対応)
76
77
  */
77
- createIfNotExistMany<T extends factory.eventType.ScreeningEvent>(params: {
78
+ createManyIfNotExist<T extends factory.eventType>(params: {
78
79
  attributes: factory.event.IAttributes<T>;
79
80
  filter: {
80
81
  name: string;
81
82
  };
82
- }[]): Promise<void>;
83
+ }[]): Promise<BulkWriteOpResultObject | void>;
83
84
  /**
84
85
  * イベント部分更新
85
86
  */
@@ -138,7 +139,7 @@ export declare class MongoRepository {
138
139
  updateAggregationById<T extends factory.eventType>(params: {
139
140
  id: string;
140
141
  }, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
141
- bulkWrite(bulkWriteOps: any[]): Promise<import("mongodb").BulkWriteOpResultObject>;
142
+ bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
142
143
  getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
143
144
  deleteUnnecessaryProjectAttributesById(params: {
144
145
  id: string;
@@ -460,38 +460,36 @@ class MongoRepository {
460
460
  /**
461
461
  * 特定の追加特性をキーにして、なければ作成する(複数対応)
462
462
  */
463
- createIfNotExistMany(params) {
463
+ createManyIfNotExist(params) {
464
464
  return __awaiter(this, void 0, void 0, function* () {
465
465
  const bulkWriteOps = [];
466
466
  if (Array.isArray(params)) {
467
467
  params.forEach((creatingEventParams) => {
468
468
  var _a;
469
- if (creatingEventParams.attributes.typeOf === factory.eventType.ScreeningEvent) {
470
- const additionalPropertyValue = (_a = creatingEventParams.attributes.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === creatingEventParams.filter.name);
471
- if (typeof additionalPropertyValue !== 'string') {
472
- throw new factory.errors.NotFound('additionalProperty.value');
473
- }
474
- bulkWriteOps.push({
475
- updateOne: {
476
- filter: {
477
- typeOf: creatingEventParams.attributes.typeOf,
478
- // 追加特性をキーに更新
479
- additionalProperty: {
480
- $exists: true,
481
- $all: [{ name: creatingEventParams.filter.name, value: additionalPropertyValue }]
482
- }
483
- },
484
- update: {
485
- $setOnInsert: Object.assign({ _id: uniqid() }, creatingEventParams.attributes)
486
- },
487
- upsert: true
488
- }
489
- });
469
+ const additionalPropertyValue = (_a = creatingEventParams.attributes.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === creatingEventParams.filter.name);
470
+ if (typeof additionalPropertyValue !== 'string') {
471
+ throw new factory.errors.NotFound('additionalProperty.value');
490
472
  }
473
+ bulkWriteOps.push({
474
+ updateOne: {
475
+ filter: {
476
+ typeOf: creatingEventParams.attributes.typeOf,
477
+ // 追加特性をキーに更新
478
+ additionalProperty: {
479
+ $exists: true,
480
+ $all: [{ name: creatingEventParams.filter.name, value: additionalPropertyValue }]
481
+ }
482
+ },
483
+ update: {
484
+ $setOnInsert: Object.assign({ _id: uniqid() }, creatingEventParams.attributes)
485
+ },
486
+ upsert: true
487
+ }
488
+ });
491
489
  });
492
490
  }
493
491
  if (bulkWriteOps.length > 0) {
494
- yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
492
+ return this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
495
493
  }
496
494
  });
497
495
  }
@@ -24,7 +24,6 @@ export declare class MongoRepository {
24
24
  readonly taskModel: typeof Model;
25
25
  constructor(connection: Connection);
26
26
  static CREATE_MONGO_CONDITIONS(params: factory.task.ISearchConditions): any[];
27
- save(taskAttributes: factory.task.IAttributes<factory.taskName>): Promise<factory.task.ITask<factory.taskName>>;
28
27
  saveMany(taskAttributes: factory.task.IAttributes<factory.taskName>[]): Promise<any[]>;
29
28
  executeOneByName<T extends factory.taskName>(params: {
30
29
  name: T;
@@ -136,12 +136,11 @@ class MongoRepository {
136
136
  }
137
137
  return andConditions;
138
138
  }
139
- save(taskAttributes) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- return this.taskModel.create(taskAttributes)
142
- .then((doc) => doc.toObject());
143
- });
144
- }
139
+ // public async save(taskAttributes: factory.task.IAttributes<factory.taskName>): Promise<void> {
140
+ // // return this.taskModel.create(taskAttributes)
141
+ // // .then((doc) => <factory.task.ITask<factory.taskName>>doc.toObject());
142
+ // await this.taskModel.create(taskAttributes);
143
+ // }
145
144
  saveMany(taskAttributes) {
146
145
  return __awaiter(this, void 0, void 0, function* () {
147
146
  if (taskAttributes.length > 0) {
@@ -33,4 +33,4 @@ export declare function exportTasks<T extends factory.assetTransactionType>(para
33
33
  project: ProjectRepo;
34
34
  task: TaskRepo;
35
35
  assetTransaction: AssetTransactionRepo;
36
- }) => Promise<(import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/deleteAssetTransaction").ITask | import("@chevre/factory/lib/task/deleteAuthorization").ITask | import("@chevre/factory/lib/task/deleteOrder").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/deleteMember").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask)[] | undefined>;
36
+ }) => Promise<(import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/deleteAssetTransaction").ITask | import("@chevre/factory/lib/task/deleteAuthorization").ITask | import("@chevre/factory/lib/task/deleteOrder").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/deleteMember").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/orderProgramMembership").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask)[] | undefined>;
@@ -202,8 +202,10 @@ function onReturn(returnActionAttributes) {
202
202
  }
203
203
  }
204
204
  // タスク保管
205
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
206
- return repos.task.save(taskAttribute);
207
- })));
205
+ // saveManyに変更(2023-02-01~)
206
+ yield repos.task.saveMany(taskAttributes);
207
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
208
+ // return repos.task.save(taskAttribute);
209
+ // }));
208
210
  });
209
211
  }
@@ -77,8 +77,10 @@ function onRegistered(actionAttributes, __) {
77
77
  }
78
78
  }
79
79
  // タスク保管
80
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
81
- return repos.task.save(taskAttribute);
82
- })));
80
+ // saveManyに変更(2023-02-01~)
81
+ yield repos.task.saveMany(taskAttributes);
82
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
83
+ // return repos.task.save(taskAttribute);
84
+ // }));
83
85
  });
84
86
  }
@@ -217,8 +217,10 @@ function onRefund(refundActionAttributes) {
217
217
  });
218
218
  }
219
219
  // タスク保管
220
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
221
- return repos.task.save(taskAttribute);
222
- })));
220
+ // saveManyに変更(2023-02-01~)
221
+ yield repos.task.saveMany(taskAttributes);
222
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
223
+ // return repos.task.save(taskAttribute);
224
+ // }));
223
225
  });
224
226
  }
@@ -582,7 +582,9 @@ function exportTasksById(params) {
582
582
  transaction,
583
583
  runsAt: taskRunsAt
584
584
  });
585
- yield Promise.all(taskAttributes.map((a) => __awaiter(this, void 0, void 0, function* () { return repos.task.save(a); })));
585
+ // saveManyに変更(2023-02-01~)
586
+ yield repos.task.saveMany(taskAttributes);
587
+ // await Promise.all(taskAttributes.map(async (a) => repos.task.save(a)));
586
588
  });
587
589
  }
588
590
  exports.exportTasksById = exportTasksById;
@@ -36,9 +36,11 @@ function exportTasksById(params) {
36
36
  transaction,
37
37
  runsAt: taskRunsAt
38
38
  });
39
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
40
- yield repos.task.save(taskAttribute);
41
- })));
39
+ // saveManyに変更(2023-02-01~)
40
+ yield repos.task.saveMany(taskAttributes);
41
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
42
+ // await repos.task.save(taskAttribute);
43
+ // }));
42
44
  });
43
45
  }
44
46
  exports.exportTasksById = exportTasksById;
@@ -386,9 +386,11 @@ function exportTasksById(params) {
386
386
  transaction,
387
387
  runsAt: taskRunsAt
388
388
  });
389
- yield Promise.all(taskAttributes.map((taskAttribute) => __awaiter(this, void 0, void 0, function* () {
390
- yield repos.task.save(taskAttribute);
391
- })));
389
+ // saveManyに変更(2023-02-01~)
390
+ yield repos.task.saveMany(taskAttributes);
391
+ // await Promise.all(taskAttributes.map(async (taskAttribute) => {
392
+ // await repos.task.save(taskAttribute);
393
+ // }));
392
394
  });
393
395
  }
394
396
  exports.exportTasksById = exportTasksById;
package/package.json CHANGED
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.2.0-alpha.48"
123
+ "version": "20.2.0-alpha.49"
124
124
  }