@chevre/domain 21.4.0-alpha.33 → 21.4.0-alpha.34

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.
@@ -31,9 +31,11 @@ export declare class MongoRepository {
31
31
  private readonly projectModel;
32
32
  constructor(connection: Connection);
33
33
  static CREATE_MONGO_CONDITIONS(params: factory.project.ISearchConditions): any[];
34
- findById(conditions: {
34
+ findById(params: {
35
35
  id: string;
36
- }, projection?: any): Promise<factory.project.IProject>;
36
+ inclusion: string[];
37
+ exclusion: string[];
38
+ }): Promise<factory.project.IProject>;
37
39
  findAlternateNameById(params: {
38
40
  id: string;
39
41
  }): Promise<Pick<factory.project.IProject, 'alternateName'>>;
@@ -52,9 +52,29 @@ class MongoRepository {
52
52
  }
53
53
  return andConditions;
54
54
  }
55
- findById(conditions, projection) {
55
+ findById(params
56
+ // projection?: any
57
+ ) {
56
58
  return __awaiter(this, void 0, void 0, function* () {
57
- const doc = yield this.projectModel.findOne({ _id: conditions.id }, Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection))
59
+ let projection = {};
60
+ if (Array.isArray(params.inclusion) && params.inclusion.length > 0) {
61
+ params.inclusion.forEach((field) => {
62
+ projection[field] = 1;
63
+ });
64
+ }
65
+ else {
66
+ projection = {
67
+ __v: 0,
68
+ createdAt: 0,
69
+ updatedAt: 0
70
+ };
71
+ if (Array.isArray(params.exclusion) && params.exclusion.length > 0) {
72
+ params.exclusion.forEach((field) => {
73
+ projection[field] = 0;
74
+ });
75
+ }
76
+ }
77
+ const doc = yield this.projectModel.findOne({ _id: { $eq: params.id } }, projection)
58
78
  .exec();
59
79
  if (doc === null) {
60
80
  throw new factory.errors.NotFound(this.projectModel.modelName);
@@ -64,7 +84,7 @@ class MongoRepository {
64
84
  }
65
85
  findAlternateNameById(params) {
66
86
  return __awaiter(this, void 0, void 0, function* () {
67
- const doc = yield this.projectModel.findOne({ _id: params.id }, { alternateName: 1 })
87
+ const doc = yield this.projectModel.findOne({ _id: { $eq: params.id } }, { alternateName: 1 })
68
88
  .exec();
69
89
  if (doc === null) {
70
90
  throw new factory.errors.NotFound(this.projectModel.modelName);
@@ -21,7 +21,11 @@ function aggregate(params) {
21
21
  return (repos) => __awaiter(this, void 0, void 0, function* () {
22
22
  const now = new Date();
23
23
  // 集計対象プロジェクト検索
24
- const project = yield repos.project.findById(params.project);
24
+ const project = yield repos.project.findById({
25
+ id: params.project.id,
26
+ inclusion: ['_id', 'typeOf'],
27
+ exclusion: []
28
+ });
25
29
  // 予約集計
26
30
  const { aggregateReservation } = yield aggregateReservationOnProject({
27
31
  aggregateDate: now,
@@ -73,7 +73,11 @@ function validateStartParams(params) {
73
73
  */
74
74
  function start(params) {
75
75
  return (repos) => __awaiter(this, void 0, void 0, function* () {
76
- const project = yield repos.project.findById({ id: params.project.id });
76
+ const project = yield repos.project.findById({
77
+ id: params.project.id,
78
+ inclusion: ['_id', 'typeOf'],
79
+ exclusion: []
80
+ });
77
81
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
78
82
  const transactionNumber = params.transactionNumber;
79
83
  if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
@@ -125,7 +129,11 @@ exports.confirm = confirm;
125
129
  */
126
130
  function startAndConfirm(params) {
127
131
  return (repos) => __awaiter(this, void 0, void 0, function* () {
128
- const project = yield repos.project.findById({ id: params.project.id });
132
+ const project = yield repos.project.findById({
133
+ id: params.project.id,
134
+ inclusion: ['_id', 'typeOf'],
135
+ exclusion: []
136
+ });
129
137
  const { reserveTransaction, reservations } = yield validateStartParams(params)(repos);
130
138
  const transactionNumber = params.transactionNumber;
131
139
  if (typeof transactionNumber !== 'string' || transactionNumber.length === 0) {
@@ -25,7 +25,11 @@ const PermitService = require("../permit");
25
25
  */
26
26
  function start(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
- const project = yield repos.project.findById({ id: params.project.id });
28
+ const project = yield repos.project.findById({
29
+ id: params.project.id,
30
+ inclusion: ['_id', 'typeOf'],
31
+ exclusion: []
32
+ });
29
33
  // objectはオファー
30
34
  let acceptedOffers = params.object;
31
35
  if (!Array.isArray(acceptedOffers)) {
@@ -22,7 +22,11 @@ const errorHandler_1 = require("../errorHandler");
22
22
  */
23
23
  function authorize(params) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
- const project = yield repos.project.findById({ id: params.project.id });
25
+ const project = yield repos.project.findById({
26
+ id: params.project.id,
27
+ inclusion: ['_id', 'settings', 'typeOf'],
28
+ exclusion: []
29
+ });
26
30
  const transaction = yield repos.assetTransaction.findById({
27
31
  typeOf: params.purpose.typeOf,
28
32
  id: params.purpose.id
@@ -26,7 +26,11 @@ const debug = createDebug('chevre-domain:service');
26
26
  function sendEmailMessage(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
28
  var _a, _b;
29
- const project = yield repos.project.findById({ id: params.project.id });
29
+ const project = yield repos.project.findById({
30
+ id: params.project.id,
31
+ inclusion: ['_id', 'settings'],
32
+ exclusion: []
33
+ });
30
34
  // アクション開始
31
35
  const action = yield repos.action.start(params);
32
36
  let result = {};
@@ -28,7 +28,11 @@ const debug = createDebug('chevre-domain:service:payment');
28
28
  function authorize(params, paymentServiceId, searchTrade4accountId) {
29
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
30
30
  var _a, _b, _c, _d;
31
- const project = yield repos.project.findById({ id: params.project.id });
31
+ const project = yield repos.project.findById({
32
+ id: params.project.id,
33
+ inclusion: ['settings'],
34
+ exclusion: []
35
+ });
32
36
  // CreditCard系統の決済方法タイプは動的
33
37
  const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.typeOf;
34
38
  if (typeof paymentMethodType !== 'string') {
@@ -23,7 +23,11 @@ const accountTransactionIdentifier_1 = require("../../factory/accountTransaction
23
23
  function authorize(params, paymentServiceId) {
24
24
  return (repos) => __awaiter(this, void 0, void 0, function* () {
25
25
  var _a;
26
- const project = yield repos.project.findById({ id: params.project.id });
26
+ const project = yield repos.project.findById({
27
+ id: params.project.id,
28
+ inclusion: ['_id', 'typeOf'],
29
+ exclusion: []
30
+ });
27
31
  const transactionNumber = params.transactionNumber;
28
32
  if (typeof transactionNumber !== 'string') {
29
33
  throw new factory.errors.ArgumentNull('transactionNumber');
@@ -34,7 +34,11 @@ function findCreditCard(params) {
34
34
  // throw new factory.errors.NotFound('CreditCard');
35
35
  // }
36
36
  var _a;
37
- const project = yield repos.project.findById({ id: params.project.id });
37
+ const project = yield repos.project.findById({
38
+ id: params.project.id,
39
+ inclusion: ['settings'],
40
+ exclusion: []
41
+ });
38
42
  // const userPoolId: string = params.iss;
39
43
  // checkUseMyCreditCards(project);
40
44
  let memberId = params.customer.id;
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.4.0-alpha.33"
120
+ "version": "21.4.0-alpha.34"
121
121
  }