@chevre/domain 21.4.0-alpha.26 → 21.4.0-alpha.28

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.
@@ -0,0 +1,31 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const PROJECT_ID = String(process.env.PROJECT_ID);
7
+ const memberId = String(process.env.MEMBER_ID);
8
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
+
12
+ const memberRepo = new chevre.repository.Member(mongoose.connection);
13
+
14
+ const ids = await memberRepo.searchMemberOfIdsByMemberId({
15
+ member: {
16
+ id: memberId,
17
+ memberOf: {
18
+ // typeOf: chevre.factory.organizationType.Corporation,
19
+ typeOf: chevre.factory.organizationType.Project
20
+ }
21
+ },
22
+ project: {
23
+ id: PROJECT_ID
24
+ }
25
+ });
26
+ console.log(ids);
27
+ }
28
+
29
+ main()
30
+ .then(console.log)
31
+ .catch(console.error);
@@ -1,10 +1,10 @@
1
1
  // tslint:disable:no-console
2
2
  import * as mongoose from 'mongoose';
3
3
 
4
- import { chevre } from '../../../lib/index';
4
+ import { chevre } from '../../../../lib/index';
5
5
 
6
6
  // const PROJECT_ID = String(process.env.PROJECT_ID);
7
- const memberId = 'xxx';
7
+ const memberId = String(process.env.MEMBER_ID);
8
8
 
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
@@ -134,5 +134,20 @@ export declare class MongoRepository {
134
134
  limit: number;
135
135
  page: number;
136
136
  }): Promise<string[]>;
137
+ /**
138
+ * member.memberOf.typeOfからmember.memberOf.idのリストを検索する
139
+ * 権限を持つ販売者IDの検索など
140
+ */
141
+ searchMemberOfIdsByMemberId(params: {
142
+ member: {
143
+ id: string;
144
+ memberOf: {
145
+ typeOf: factory.organizationType.Project | factory.organizationType.Corporation;
146
+ };
147
+ };
148
+ project: {
149
+ id: string;
150
+ };
151
+ }): Promise<string[]>;
137
152
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
138
153
  }
@@ -302,6 +302,21 @@ class MongoRepository {
302
302
  .then((docs) => docs.map((doc) => doc._id));
303
303
  });
304
304
  }
305
+ /**
306
+ * member.memberOf.typeOfからmember.memberOf.idのリストを検索する
307
+ * 権限を持つ販売者IDの検索など
308
+ */
309
+ searchMemberOfIdsByMemberId(params) {
310
+ return __awaiter(this, void 0, void 0, function* () {
311
+ const query = this.memberModel.distinct('member.memberOf.id', {
312
+ 'project.id': { $eq: params.project.id },
313
+ 'member.id': { $eq: params.member.id },
314
+ 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
315
+ });
316
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
317
+ .exec();
318
+ });
319
+ }
305
320
  getCursor(conditions, projection) {
306
321
  return this.memberModel.find(conditions, projection)
307
322
  .sort({ 'member.id': factory.sortType.Ascending })
@@ -25,13 +25,25 @@
25
25
  import { Connection } from 'mongoose';
26
26
  import * as factory from '../factory';
27
27
  export type ISeller = factory.seller.ISeller;
28
+ export interface IMemberSearchConditions {
29
+ /**
30
+ * 販売者メンバーで絞る場合
31
+ */
32
+ member?: {
33
+ memberOf?: {
34
+ id?: {
35
+ $in?: string[];
36
+ };
37
+ };
38
+ };
39
+ }
28
40
  /**
29
41
  * 販売者リポジトリ
30
42
  */
31
43
  export declare class MongoRepository {
32
44
  private readonly organizationModel;
33
45
  constructor(connection: Connection);
34
- static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions): any[];
46
+ static CREATE_MONGO_CONDITIONS(params: factory.seller.ISearchConditions & IMemberSearchConditions): any[];
35
47
  /**
36
48
  * 特定販売者検索
37
49
  * searchに置き換え(2023-07-13~)
@@ -46,7 +58,7 @@ export declare class MongoRepository {
46
58
  /**
47
59
  * 販売者検索
48
60
  */
49
- search(conditions: factory.seller.ISearchConditions, inclusion: string[], exclusion: string[]): Promise<ISeller[]>;
61
+ search(conditions: factory.seller.ISearchConditions & IMemberSearchConditions, inclusion: string[], exclusion: string[]): Promise<ISeller[]>;
50
62
  /**
51
63
  * 対応決済方法を検索する
52
64
  */
@@ -34,7 +34,7 @@ class MongoRepository {
34
34
  }
35
35
  // tslint:disable-next-line:max-func-body-length
36
36
  static CREATE_MONGO_CONDITIONS(params) {
37
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
37
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
38
38
  // MongoDB検索条件
39
39
  const andConditions = [];
40
40
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -45,6 +45,11 @@ class MongoRepository {
45
45
  if (typeof idEq === 'string') {
46
46
  andConditions.push({ _id: { $eq: idEq } });
47
47
  }
48
+ // メンバー条件追加(2023-07-24~)
49
+ const memberMemberOfIdIn = (_f = (_e = (_d = params.member) === null || _d === void 0 ? void 0 : _d.memberOf) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
50
+ if (Array.isArray(memberMemberOfIdIn)) {
51
+ andConditions.push({ _id: { $in: memberMemberOfIdIn } });
52
+ }
48
53
  const nameRegex = params.name;
49
54
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
50
55
  andConditions.push({
@@ -64,7 +69,7 @@ class MongoRepository {
64
69
  ]
65
70
  });
66
71
  }
67
- const branchCodeEq = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$eq;
72
+ const branchCodeEq = (_g = params.branchCode) === null || _g === void 0 ? void 0 : _g.$eq;
68
73
  if (typeof branchCodeEq === 'string') {
69
74
  andConditions.push({
70
75
  branchCode: {
@@ -72,7 +77,7 @@ class MongoRepository {
72
77
  }
73
78
  });
74
79
  }
75
- const branchCodeRegex = (_e = params.branchCode) === null || _e === void 0 ? void 0 : _e.$regex;
80
+ const branchCodeRegex = (_h = params.branchCode) === null || _h === void 0 ? void 0 : _h.$regex;
76
81
  if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
77
82
  andConditions.push({
78
83
  branchCode: {
@@ -80,7 +85,7 @@ class MongoRepository {
80
85
  }
81
86
  });
82
87
  }
83
- const additionalPropertyAll = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$all;
88
+ const additionalPropertyAll = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$all;
84
89
  if (Array.isArray(additionalPropertyAll)) {
85
90
  andConditions.push({
86
91
  additionalProperty: {
@@ -89,7 +94,7 @@ class MongoRepository {
89
94
  }
90
95
  });
91
96
  }
92
- const additionalPropertyIn = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$in;
97
+ const additionalPropertyIn = (_k = params.additionalProperty) === null || _k === void 0 ? void 0 : _k.$in;
93
98
  if (Array.isArray(additionalPropertyIn)) {
94
99
  andConditions.push({
95
100
  additionalProperty: {
@@ -98,7 +103,7 @@ class MongoRepository {
98
103
  }
99
104
  });
100
105
  }
101
- const additionalPropertyNin = (_h = params.additionalProperty) === null || _h === void 0 ? void 0 : _h.$nin;
106
+ const additionalPropertyNin = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$nin;
102
107
  if (Array.isArray(additionalPropertyNin)) {
103
108
  andConditions.push({
104
109
  additionalProperty: {
@@ -106,7 +111,7 @@ class MongoRepository {
106
111
  }
107
112
  });
108
113
  }
109
- const additionalPropertyElemMatch = (_j = params.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
114
+ const additionalPropertyElemMatch = (_m = params.additionalProperty) === null || _m === void 0 ? void 0 : _m.$elemMatch;
110
115
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
111
116
  andConditions.push({
112
117
  additionalProperty: {
@@ -115,7 +120,7 @@ class MongoRepository {
115
120
  }
116
121
  });
117
122
  }
118
- const hasMerchantReturnPolicyItemConditionIdEq = (_m = (_l = (_k = params.hasMerchantReturnPolicy) === null || _k === void 0 ? void 0 : _k.itemCondition) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$eq;
123
+ const hasMerchantReturnPolicyItemConditionIdEq = (_q = (_p = (_o = params.hasMerchantReturnPolicy) === null || _o === void 0 ? void 0 : _o.itemCondition) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
119
124
  if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
120
125
  andConditions.push({
121
126
  'hasMerchantReturnPolicy.itemCondition.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.26"
120
+ "version": "21.4.0-alpha.28"
121
121
  }