@chevre/domain 28.0.0-alpha.43 → 28.0.0-alpha.44

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,6 +31,7 @@ export interface ISearchConditions {
31
31
  };
32
32
  };
33
33
  }
34
+ type IKeyOfProjection = keyof IDocType;
34
35
  /**
35
36
  * Eメールメッセージリポジトリ
36
37
  */
@@ -39,8 +40,9 @@ export declare class EmailMessageRepo {
39
40
  constructor(connection: Connection);
40
41
  static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<IDocType>[];
41
42
  save(params: IEmailMessage): Promise<any>;
42
- findEmailMessages(params: ISearchConditions): Promise<IEmailMessage[]>;
43
+ findEmailMessages(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IEmailMessage[]>;
43
44
  deleteById(params: {
44
45
  id: string;
45
46
  }): Promise<void>;
46
47
  }
48
+ export {};
@@ -4,17 +4,15 @@ exports.EmailMessageRepo = void 0;
4
4
  const emailMessages_1 = require("./mongoose/schemas/emailMessages");
5
5
  const factory_1 = require("../factory");
6
6
  const settings_1 = require("../settings");
7
- const DEFAULT_PROJECTION = {
8
- _id: 0,
9
- id: { $toString: '$_id' },
10
- project: 1,
11
- typeOf: 1,
12
- identifier: 1,
13
- name: 1,
14
- about: 1,
15
- sender: 1,
16
- text: 1,
17
- };
7
+ const AVAILABLE_PROJECT_FIELDS = [
8
+ 'project',
9
+ 'typeOf',
10
+ 'identifier',
11
+ 'name',
12
+ 'about',
13
+ 'sender',
14
+ 'text',
15
+ ];
18
16
  /**
19
17
  * Eメールメッセージリポジトリ
20
18
  */
@@ -61,9 +59,18 @@ class EmailMessageRepo {
61
59
  }
62
60
  return doc.toObject();
63
61
  }
64
- async findEmailMessages(params) {
62
+ async findEmailMessages(params, inclusion) {
65
63
  const conditions = EmailMessageRepo.CREATE_MONGO_CONDITIONS(params);
66
- const query = this.emailMessageModel.find({ $and: conditions }, DEFAULT_PROJECTION);
64
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
65
+ if (Array.isArray(inclusion)) {
66
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
67
+ }
68
+ const projection = {
69
+ _id: 0,
70
+ id: { $toString: '$_id' },
71
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
72
+ };
73
+ const query = this.emailMessageModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
67
74
  if (typeof params.limit === 'number' && params.limit > 0) {
68
75
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
69
76
  query.limit(params.limit)
@@ -151,8 +151,9 @@ function createInformTasks(params, setting) {
151
151
  }
152
152
  return {
153
153
  project, organizer, typeOf, name, doorTime, endDate,
154
- eventStatus, location, startDate, superEvent, id, additionalProperty,
154
+ eventStatus, location, startDate, id, additionalProperty,
155
155
  offers: eventOfferAsNotification,
156
+ superEvent: { id: superEvent.id, typeOf: superEvent.typeOf }, // minimize superEvent(2026-10-22~)
156
157
  ...(typeof identifier === 'string') ? { identifier } : undefined // support notify identifier(2025-11-01~)
157
158
  };
158
159
  });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.1090.0",
13
13
  "@aws-sdk/credential-providers": "3.1090.0",
14
- "@chevre/factory": "11.1.0-alpha.10",
14
+ "@chevre/factory": "11.1.0-alpha.11",
15
15
  "@motionpicture/coa-service": "10.0.0",
16
16
  "@motionpicture/gmo-service": "6.1.0-alpha.0",
17
17
  "@sendgrid/client": "8.1.4",
@@ -88,5 +88,5 @@
88
88
  "postversion": "git push origin --tags",
89
89
  "prepublishOnly": "npm run clean && npm run build"
90
90
  },
91
- "version": "28.0.0-alpha.43"
91
+ "version": "28.0.0-alpha.44"
92
92
  }