@chevre/domain 21.4.0-alpha.8 → 21.4.0
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.
- package/example/src/chevre/cleanEventsByMovieTheater.ts +32 -0
- package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
- package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +31 -0
- package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +32 -0
- package/example/src/chevre/importEventsFromCOA.ts +5 -4
- package/example/src/chevre/migrateEventOrganizer.ts +18 -5
- package/example/src/chevre/migrateIAMMemberMemberOf.ts +59 -0
- package/example/src/chevre/migrateReservationProvider.ts +119 -0
- package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
- package/example/src/chevre/processReserve.ts +0 -1
- package/example/src/chevre/searchActions.ts +1 -1
- package/example/src/chevre/searchPermissions.ts +7 -15
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/repo/assetTransaction.d.ts +4 -1
- package/lib/chevre/repo/assetTransaction.js +6 -12
- package/lib/chevre/repo/event.d.ts +16 -0
- package/lib/chevre/repo/event.js +34 -1
- package/lib/chevre/repo/member.d.ts +77 -5
- package/lib/chevre/repo/member.js +115 -97
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/member.d.ts +7 -7
- package/lib/chevre/repo/mongoose/schemas/member.js +22 -8
- package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -6
- package/lib/chevre/repo/mongoose/schemas/place.js +9 -2
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +6 -3
- package/lib/chevre/repo/mongoose/schemas/reservation.js +10 -4
- package/lib/chevre/repo/order.d.ts +21 -0
- package/lib/chevre/repo/order.js +54 -62
- package/lib/chevre/repo/place.d.ts +57 -16
- package/lib/chevre/repo/place.js +112 -167
- package/lib/chevre/repo/product.d.ts +2 -4
- package/lib/chevre/repo/product.js +52 -7
- package/lib/chevre/repo/project.d.ts +5 -3
- package/lib/chevre/repo/project.js +48 -8
- package/lib/chevre/repo/reservation.d.ts +33 -21
- package/lib/chevre/repo/reservation.js +97 -79
- package/lib/chevre/repo/role.d.ts +0 -4
- package/lib/chevre/repo/role.js +0 -46
- package/lib/chevre/repo/seller.d.ts +18 -5
- package/lib/chevre/repo/seller.js +53 -46
- package/lib/chevre/repo/stockHolder.d.ts +2 -77
- package/lib/chevre/repo/stockHolder.js +200 -476
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
- package/lib/chevre/service/aggregation/project.js +5 -1
- package/lib/chevre/service/assetTransaction/cancelReservation.js +10 -2
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +9 -1
- package/lib/chevre/service/assetTransaction/pay.js +9 -1
- package/lib/chevre/service/assetTransaction/registerService.js +7 -3
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +6 -1
- package/lib/chevre/service/assetTransaction/reserve/factory.js +15 -38
- package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
- package/lib/chevre/service/assetTransaction/reserve.js +7 -22
- package/lib/chevre/service/event/createEvent.d.ts +11 -0
- package/lib/chevre/service/event/createEvent.js +112 -0
- package/lib/chevre/service/event.d.ts +2 -0
- package/lib/chevre/service/event.js +8 -4
- package/lib/chevre/service/iam.d.ts +5 -0
- package/lib/chevre/service/iam.js +7 -19
- package/lib/chevre/service/moneyTransfer.js +6 -2
- package/lib/chevre/service/notification.js +5 -1
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
- package/lib/chevre/service/offer/event/authorize.js +6 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
- package/lib/chevre/service/order/returnOrder.js +8 -1
- package/lib/chevre/service/order/sendOrder.js +8 -1
- package/lib/chevre/service/payment/creditCard.js +14 -2
- package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
- package/lib/chevre/service/payment/movieTicket.js +19 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -4
- package/lib/chevre/service/reserve/cancelReservation.js +15 -28
- package/lib/chevre/service/reserve/confirmReservation.js +14 -30
- package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
- package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
- package/lib/chevre/service/task/{syncScreeningRooms.d.ts → createEvent.d.ts} +1 -1
- package/lib/chevre/service/task/{syncScreeningRooms.js → createEvent.js} +11 -3
- package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
- package/lib/chevre/service/task/returnPayTransaction.js +1 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
- package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +6 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
- package/lib/chevre/service/transaction/returnOrder.js +9 -3
- package/lib/chevre/settings.d.ts +0 -2
- package/lib/chevre/settings.js +7 -7
- package/package.json +3 -3
- package/example/src/chevre/findByOrderNumberAndReservationId.ts +0 -20
- package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
- package/example/src/chevre/searchHoldReservations.ts +0 -38
- package/example/src/chevre/searchScreeningRooms.ts +0 -33
- package/example/src/chevre/syncScreeningRooms.ts +0 -21
- package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
- package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +0 -75
- package/lib/chevre/repo/mongoose/schemas/holdReservation.js +0 -93
|
@@ -319,23 +319,17 @@ class MongoRepository {
|
|
|
319
319
|
});
|
|
320
320
|
}
|
|
321
321
|
addReservations(params) {
|
|
322
|
-
var _a;
|
|
323
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
324
323
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
325
324
|
_id: { $eq: params.id },
|
|
326
325
|
typeOf: { $eq: params.typeOf },
|
|
327
326
|
status: { $eq: factory.transactionStatusType.InProgress }
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
'object.
|
|
333
|
-
|
|
334
|
-
// 冗長なので削除(2021/10/19~)
|
|
335
|
-
// 'object.reservations': params.object.subReservation,
|
|
336
|
-
'object.subReservation': params.object.subReservation }, (typeof ((_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
337
|
-
? { 'object.issuedThrough': params.object.issuedThrough }
|
|
338
|
-
: undefined), { new: true })
|
|
327
|
+
}, {
|
|
328
|
+
'object.acceptedOffer': params.object.acceptedOffer,
|
|
329
|
+
'object.issuedThrough': params.object.issuedThrough,
|
|
330
|
+
'object.reservationFor': params.object.reservationFor,
|
|
331
|
+
'object.subReservation': params.object.subReservation
|
|
332
|
+
}, { new: true })
|
|
339
333
|
.exec();
|
|
340
334
|
if (doc === null) {
|
|
341
335
|
throw new factory.errors.NotFound(this.transactionModel.modelName);
|
|
@@ -169,6 +169,22 @@ export declare class MongoRepository {
|
|
|
169
169
|
};
|
|
170
170
|
id: string;
|
|
171
171
|
}): Promise<void>;
|
|
172
|
+
deleteScreeningEventsByMovieTheaterBranchCode(params: {
|
|
173
|
+
project: {
|
|
174
|
+
id: string;
|
|
175
|
+
};
|
|
176
|
+
location: {
|
|
177
|
+
branchCode: string;
|
|
178
|
+
};
|
|
179
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
180
|
+
deleteScreeningEventSeriesByMovieTheaterBranchCode(params: {
|
|
181
|
+
project: {
|
|
182
|
+
id: string;
|
|
183
|
+
};
|
|
184
|
+
location: {
|
|
185
|
+
branchCode: string;
|
|
186
|
+
};
|
|
187
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
172
188
|
deleteByProject(params: {
|
|
173
189
|
project: {
|
|
174
190
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -28,6 +28,7 @@ const errorHandler_1 = require("../errorHandler");
|
|
|
28
28
|
const settings_1 = require("../settings");
|
|
29
29
|
exports.PROJECTION_MINIMIZED_EVENT = {
|
|
30
30
|
project: 1,
|
|
31
|
+
organizer: 1,
|
|
31
32
|
_id: 1,
|
|
32
33
|
typeOf: 1,
|
|
33
34
|
additionalProperty: 1,
|
|
@@ -52,7 +53,19 @@ class MongoRepository {
|
|
|
52
53
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
53
54
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
54
55
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42;
|
|
55
|
-
const andConditions = [
|
|
56
|
+
const andConditions = [];
|
|
57
|
+
const typeOfEq = conditions.typeOf;
|
|
58
|
+
if (typeof typeOfEq === 'string') {
|
|
59
|
+
andConditions.push({ typeOf: { $eq: typeOfEq } });
|
|
60
|
+
}
|
|
61
|
+
const typeOfIn = conditions.typeOfIn;
|
|
62
|
+
if (Array.isArray(typeOfIn)) {
|
|
63
|
+
andConditions.push({ typeOf: { $in: typeOfIn } });
|
|
64
|
+
}
|
|
65
|
+
// typeOf条件必須検証(2023-07-13~)
|
|
66
|
+
if (typeof typeOfEq !== 'string' && !Array.isArray(typeOfIn)) {
|
|
67
|
+
throw new factory.errors.ArgumentNull('typeOf');
|
|
68
|
+
}
|
|
56
69
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
57
70
|
if (typeof projectIdEq === 'string') {
|
|
58
71
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
@@ -838,6 +851,26 @@ class MongoRepository {
|
|
|
838
851
|
.exec();
|
|
839
852
|
});
|
|
840
853
|
}
|
|
854
|
+
deleteScreeningEventsByMovieTheaterBranchCode(params) {
|
|
855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
856
|
+
return this.eventModel.deleteMany({
|
|
857
|
+
typeOf: { $eq: factory.eventType.ScreeningEvent },
|
|
858
|
+
'project.id': { $eq: params.project.id },
|
|
859
|
+
'superEvent.location.branchCode': { $exists: true, $eq: params.location.branchCode }
|
|
860
|
+
})
|
|
861
|
+
.exec();
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
deleteScreeningEventSeriesByMovieTheaterBranchCode(params) {
|
|
865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
866
|
+
return this.eventModel.deleteMany({
|
|
867
|
+
typeOf: { $eq: factory.eventType.ScreeningEventSeries },
|
|
868
|
+
'project.id': { $eq: params.project.id },
|
|
869
|
+
'location.branchCode': { $exists: true, $eq: params.location.branchCode }
|
|
870
|
+
})
|
|
871
|
+
.exec();
|
|
872
|
+
});
|
|
873
|
+
}
|
|
841
874
|
deleteByProject(params) {
|
|
842
875
|
return __awaiter(this, void 0, void 0, function* () {
|
|
843
876
|
yield this.eventModel.deleteMany({
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
1
25
|
import { Connection } from 'mongoose';
|
|
2
26
|
import * as factory from '../factory';
|
|
3
27
|
/**
|
|
@@ -7,7 +31,6 @@ export declare class MongoRepository {
|
|
|
7
31
|
private readonly memberModel;
|
|
8
32
|
constructor(connection: Connection);
|
|
9
33
|
static CREATE_MONGO_CONDITIONS(params: factory.iam.ISearchConditions): any[];
|
|
10
|
-
count(params: factory.iam.ISearchConditions): Promise<number>;
|
|
11
34
|
search(params: factory.iam.ISearchConditions): Promise<factory.iam.IMember[]>;
|
|
12
35
|
aggregateRoleNames(params: {
|
|
13
36
|
project: {
|
|
@@ -19,13 +42,18 @@ export declare class MongoRepository {
|
|
|
19
42
|
id: {
|
|
20
43
|
$eq: string;
|
|
21
44
|
};
|
|
45
|
+
memberOf: {
|
|
46
|
+
id: {
|
|
47
|
+
$eq: string;
|
|
48
|
+
};
|
|
49
|
+
typeOf: {
|
|
50
|
+
$eq: factory.organizationType.Corporation | factory.organizationType.Project;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
22
53
|
};
|
|
23
54
|
}): Promise<{
|
|
24
55
|
roleName: string;
|
|
25
56
|
}[]>;
|
|
26
|
-
findById(params: {
|
|
27
|
-
id: string;
|
|
28
|
-
}): Promise<factory.iam.IMember>;
|
|
29
57
|
deleteByProject(params: {
|
|
30
58
|
project: {
|
|
31
59
|
id: string;
|
|
@@ -43,12 +71,31 @@ export declare class MongoRepository {
|
|
|
43
71
|
id: string;
|
|
44
72
|
};
|
|
45
73
|
member: {
|
|
46
|
-
hasRole?: factory.iam.IMemberHasRole;
|
|
47
74
|
id: string;
|
|
75
|
+
memberOf: {
|
|
76
|
+
id: string;
|
|
77
|
+
typeOf: factory.organizationType.Corporation | factory.organizationType.Project;
|
|
78
|
+
};
|
|
79
|
+
hasRole?: factory.iam.IMemberHasRole;
|
|
48
80
|
image?: string;
|
|
49
81
|
name?: string;
|
|
50
82
|
};
|
|
51
83
|
}): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* 互換性維持プログラム専用
|
|
86
|
+
*/
|
|
87
|
+
updateByMemberMemberOf(params: {
|
|
88
|
+
project: {
|
|
89
|
+
id: string;
|
|
90
|
+
};
|
|
91
|
+
member: {
|
|
92
|
+
id: string;
|
|
93
|
+
memberOf: {
|
|
94
|
+
id: string;
|
|
95
|
+
typeOf: factory.organizationType.Project;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
}): Promise<void>;
|
|
52
99
|
/**
|
|
53
100
|
* メンバー削除
|
|
54
101
|
*/
|
|
@@ -58,6 +105,14 @@ export declare class MongoRepository {
|
|
|
58
105
|
};
|
|
59
106
|
member: {
|
|
60
107
|
id: string;
|
|
108
|
+
memberOf: {
|
|
109
|
+
id: {
|
|
110
|
+
$eq: string;
|
|
111
|
+
};
|
|
112
|
+
typeOf: {
|
|
113
|
+
$eq: factory.organizationType.Corporation | factory.organizationType.Project;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
61
116
|
};
|
|
62
117
|
}): Promise<void>;
|
|
63
118
|
/**
|
|
@@ -69,10 +124,27 @@ export declare class MongoRepository {
|
|
|
69
124
|
};
|
|
70
125
|
project?: {
|
|
71
126
|
id?: {
|
|
127
|
+
$eq?: string;
|
|
72
128
|
$regex?: string;
|
|
73
129
|
};
|
|
74
130
|
};
|
|
75
131
|
limit: number;
|
|
76
132
|
page: number;
|
|
77
133
|
}): Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* member.memberOf.typeOfからmember.memberOf.idのリストを検索する
|
|
136
|
+
* 権限を持つ販売者IDの検索など
|
|
137
|
+
*/
|
|
138
|
+
searchMemberOfIdsByMemberId(params: {
|
|
139
|
+
member: {
|
|
140
|
+
id: string;
|
|
141
|
+
memberOf: {
|
|
142
|
+
typeOf: factory.organizationType.Corporation | factory.organizationType.Project;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
project: {
|
|
146
|
+
id: string;
|
|
147
|
+
};
|
|
148
|
+
}): Promise<string[]>;
|
|
149
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
78
150
|
}
|
|
@@ -22,64 +22,37 @@ class MongoRepository {
|
|
|
22
22
|
}
|
|
23
23
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
24
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
26
26
|
const andConditions = [];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (typeof params.id.$eq === 'string') {
|
|
31
|
-
andConditions.push({
|
|
32
|
-
_id: {
|
|
33
|
-
$eq: params.id.$eq
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
27
|
+
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
28
|
+
if (typeof idEq === 'string') {
|
|
29
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
37
30
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (params.project.id !== undefined && params.project.id !== null) {
|
|
42
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
43
|
-
andConditions.push({
|
|
44
|
-
'project.id': {
|
|
45
|
-
$eq: params.project.id.$eq
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
31
|
+
const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
32
|
+
if (typeof projectIdEq === 'string') {
|
|
33
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
50
34
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (params.member.typeOf !== undefined && params.member.typeOf !== null) {
|
|
55
|
-
if (typeof params.member.typeOf.$eq === 'string') {
|
|
56
|
-
andConditions.push({
|
|
57
|
-
'member.typeOf': {
|
|
58
|
-
$exists: true,
|
|
59
|
-
$eq: params.member.typeOf.$eq
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (params.member.id !== undefined && params.member.id !== null) {
|
|
65
|
-
if (typeof params.member.id.$eq === 'string') {
|
|
66
|
-
andConditions.push({
|
|
67
|
-
'member.id': {
|
|
68
|
-
$eq: params.member.id.$eq
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
35
|
+
const memberMemberOfTypeOfEq = (_f = (_e = (_d = params.member) === null || _d === void 0 ? void 0 : _d.memberOf) === null || _e === void 0 ? void 0 : _e.typeOf) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
36
|
+
if (typeof memberMemberOfTypeOfEq === 'string') {
|
|
37
|
+
andConditions.push({ 'member.memberOf.typeOf': { $eq: memberMemberOfTypeOfEq } });
|
|
73
38
|
}
|
|
74
|
-
const
|
|
39
|
+
const memberMemberOfIdEq = (_j = (_h = (_g = params.member) === null || _g === void 0 ? void 0 : _g.memberOf) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
40
|
+
if (typeof memberMemberOfIdEq === 'string') {
|
|
41
|
+
andConditions.push({ 'member.memberOf.id': { $eq: memberMemberOfIdEq } });
|
|
42
|
+
}
|
|
43
|
+
const memberTypeOfEq = (_l = (_k = params.member) === null || _k === void 0 ? void 0 : _k.typeOf) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
44
|
+
if (typeof memberTypeOfEq === 'string') {
|
|
45
|
+
andConditions.push({ 'member.typeOf': { $exists: true, $eq: memberTypeOfEq } });
|
|
46
|
+
}
|
|
47
|
+
const memberIdEq = (_o = (_m = params.member) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
48
|
+
if (typeof memberIdEq === 'string') {
|
|
49
|
+
andConditions.push({ 'member.id': { $eq: memberIdEq } });
|
|
50
|
+
}
|
|
51
|
+
const memberIdIn = (_q = (_p = params.member) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$in;
|
|
75
52
|
if (Array.isArray(memberIdIn)) {
|
|
76
|
-
andConditions.push({
|
|
77
|
-
'member.id': {
|
|
78
|
-
$in: memberIdIn
|
|
79
|
-
}
|
|
80
|
-
});
|
|
53
|
+
andConditions.push({ 'member.id': { $in: memberIdIn } });
|
|
81
54
|
}
|
|
82
|
-
const memberNameRegex = (
|
|
55
|
+
const memberNameRegex = (_s = (_r = params.member) === null || _r === void 0 ? void 0 : _r.name) === null || _s === void 0 ? void 0 : _s.$regex;
|
|
83
56
|
if (typeof memberNameRegex === 'string' && memberNameRegex.length > 0) {
|
|
84
57
|
andConditions.push({
|
|
85
58
|
'member.name': {
|
|
@@ -88,7 +61,7 @@ class MongoRepository {
|
|
|
88
61
|
}
|
|
89
62
|
});
|
|
90
63
|
}
|
|
91
|
-
const memberHasRoleRoleNameEq = (
|
|
64
|
+
const memberHasRoleRoleNameEq = (_v = (_u = (_t = params.member) === null || _t === void 0 ? void 0 : _t.hasRole) === null || _u === void 0 ? void 0 : _u.roleName) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
92
65
|
if (typeof memberHasRoleRoleNameEq === 'string') {
|
|
93
66
|
andConditions.push({
|
|
94
67
|
'member.hasRole.roleName': {
|
|
@@ -99,14 +72,6 @@ class MongoRepository {
|
|
|
99
72
|
}
|
|
100
73
|
return andConditions;
|
|
101
74
|
}
|
|
102
|
-
count(params) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
105
|
-
return this.memberModel.countDocuments((conditions.length > 0) ? { $and: conditions } : {})
|
|
106
|
-
.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
107
|
-
.exec();
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
75
|
search(params) {
|
|
111
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
77
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -136,7 +101,9 @@ class MongoRepository {
|
|
|
136
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
102
|
const matchStages = [
|
|
138
103
|
{ $match: { 'project.id': { $eq: params.project.id.$eq } } },
|
|
139
|
-
{ $match: { 'member.id': { $eq: params.member.id.$eq } } }
|
|
104
|
+
{ $match: { 'member.id': { $eq: params.member.id.$eq } } },
|
|
105
|
+
{ $match: { 'member.memberOf.id': { $eq: params.member.memberOf.id.$eq } } },
|
|
106
|
+
{ $match: { 'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq } } }
|
|
140
107
|
];
|
|
141
108
|
const aggregate = this.memberModel.aggregate([
|
|
142
109
|
// ...(typeof params.sort?.productID === 'number')
|
|
@@ -159,19 +126,21 @@ class MongoRepository {
|
|
|
159
126
|
.exec();
|
|
160
127
|
});
|
|
161
128
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
129
|
+
// public async findById2(params: {
|
|
130
|
+
// id: string;
|
|
131
|
+
// }): Promise<factory.iam.IMember> {
|
|
132
|
+
// const doc = await this.memberModel.findOne(
|
|
133
|
+
// {
|
|
134
|
+
// _id: params.id
|
|
135
|
+
// }
|
|
136
|
+
// )
|
|
137
|
+
// .select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
138
|
+
// .exec();
|
|
139
|
+
// if (doc === null) {
|
|
140
|
+
// throw new factory.errors.NotFound(this.memberModel.modelName);
|
|
141
|
+
// }
|
|
142
|
+
// return doc.toObject();
|
|
143
|
+
// }
|
|
175
144
|
deleteByProject(params) {
|
|
176
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
146
|
yield this.memberModel.deleteMany({
|
|
@@ -200,12 +169,6 @@ class MongoRepository {
|
|
|
200
169
|
// no op
|
|
201
170
|
}
|
|
202
171
|
return members;
|
|
203
|
-
// return this.memberModel.create({
|
|
204
|
-
// project: params.project,
|
|
205
|
-
// typeOf: params.typeOf,
|
|
206
|
-
// member: params.member
|
|
207
|
-
// })
|
|
208
|
-
// .then((doc) => doc.toObject());
|
|
209
172
|
});
|
|
210
173
|
}
|
|
211
174
|
/**
|
|
@@ -215,7 +178,9 @@ class MongoRepository {
|
|
|
215
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
216
179
|
const doc = yield this.memberModel.findOneAndUpdate({
|
|
217
180
|
'project.id': { $eq: params.project.id },
|
|
218
|
-
'member.id': { $eq: params.member.id }
|
|
181
|
+
'member.id': { $eq: params.member.id },
|
|
182
|
+
'member.memberOf.id': { $eq: params.member.memberOf.id },
|
|
183
|
+
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
|
|
219
184
|
}, Object.assign(Object.assign(Object.assign({ updatedAt: new Date() }, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined))
|
|
220
185
|
.exec();
|
|
221
186
|
if (doc === null) {
|
|
@@ -223,6 +188,24 @@ class MongoRepository {
|
|
|
223
188
|
}
|
|
224
189
|
});
|
|
225
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* 互換性維持プログラム専用
|
|
193
|
+
*/
|
|
194
|
+
updateByMemberMemberOf(params) {
|
|
195
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
196
|
+
const doc = yield this.memberModel.findOneAndUpdate({
|
|
197
|
+
'project.id': { $eq: params.project.id },
|
|
198
|
+
'member.id': { $eq: params.member.id },
|
|
199
|
+
'member.memberOf': { $exists: false }
|
|
200
|
+
}, {
|
|
201
|
+
'member.memberOf': params.member.memberOf
|
|
202
|
+
})
|
|
203
|
+
.exec();
|
|
204
|
+
if (doc === null) {
|
|
205
|
+
throw new factory.errors.NotFound(this.memberModel.modelName);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
226
209
|
/**
|
|
227
210
|
* メンバー削除
|
|
228
211
|
*/
|
|
@@ -230,7 +213,9 @@ class MongoRepository {
|
|
|
230
213
|
return __awaiter(this, void 0, void 0, function* () {
|
|
231
214
|
const doc = yield this.memberModel.findOneAndDelete({
|
|
232
215
|
'project.id': { $eq: params.project.id },
|
|
233
|
-
'member.id': { $eq: params.member.id }
|
|
216
|
+
'member.id': { $eq: params.member.id },
|
|
217
|
+
'member.memberOf.id': { $eq: params.member.memberOf.id.$eq },
|
|
218
|
+
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf.$eq }
|
|
234
219
|
})
|
|
235
220
|
.exec();
|
|
236
221
|
if (doc === null) {
|
|
@@ -242,24 +227,57 @@ class MongoRepository {
|
|
|
242
227
|
* メンバーの権限を持つプロジェクト検索
|
|
243
228
|
*/
|
|
244
229
|
searchProjectIdsByMemberId(params) {
|
|
245
|
-
var _a, _b;
|
|
230
|
+
var _a, _b, _c, _d;
|
|
246
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
: undefined);
|
|
250
|
-
const query = this.memberModel.find(searchConditions, { project: 1 })
|
|
251
|
-
// sortを保証する
|
|
252
|
-
.sort({ 'project.id': factory.sortType.Ascending });
|
|
253
|
-
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
254
|
-
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
255
|
-
query.limit(params.limit)
|
|
256
|
-
.skip(params.limit * (page - 1));
|
|
232
|
+
if (typeof params.limit !== 'number') {
|
|
233
|
+
throw new factory.errors.ArgumentNull('limit');
|
|
257
234
|
}
|
|
258
|
-
|
|
235
|
+
if (typeof params.page !== 'number') {
|
|
236
|
+
throw new factory.errors.ArgumentNull('page');
|
|
237
|
+
}
|
|
238
|
+
const matchStages = [{ $match: { 'member.id': { $eq: params.member.id } } }];
|
|
239
|
+
if (typeof ((_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') {
|
|
240
|
+
matchStages.push({ $match: { 'project.id': { $eq: params.project.id.$eq } } });
|
|
241
|
+
}
|
|
242
|
+
if (typeof ((_d = (_c = params.project) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$regex) === 'string' && params.project.id.$regex.length > 0) {
|
|
243
|
+
matchStages.push({ $match: { 'project.id': { $regex: new RegExp(params.project.id.$regex) } } });
|
|
244
|
+
}
|
|
245
|
+
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
246
|
+
const aggregate = this.memberModel.aggregate([
|
|
247
|
+
...matchStages,
|
|
248
|
+
{
|
|
249
|
+
$group: {
|
|
250
|
+
_id: '$project.id'
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{ $sort: { _id: factory.sortType.Ascending } }
|
|
254
|
+
])
|
|
255
|
+
.limit(params.limit * page)
|
|
256
|
+
.skip(params.limit * (page - 1));
|
|
257
|
+
return aggregate
|
|
259
258
|
.exec()
|
|
260
|
-
.then((docs) => docs.map((doc) => doc.
|
|
261
|
-
return projectMembers.map((m) => m.project.id);
|
|
259
|
+
.then((docs) => docs.map((doc) => doc._id));
|
|
262
260
|
});
|
|
263
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* member.memberOf.typeOfからmember.memberOf.idのリストを検索する
|
|
264
|
+
* 権限を持つ販売者IDの検索など
|
|
265
|
+
*/
|
|
266
|
+
searchMemberOfIdsByMemberId(params) {
|
|
267
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
+
const query = this.memberModel.distinct('member.memberOf.id', {
|
|
269
|
+
'project.id': { $eq: params.project.id },
|
|
270
|
+
'member.id': { $eq: params.member.id },
|
|
271
|
+
'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
|
|
272
|
+
});
|
|
273
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
274
|
+
.exec();
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
getCursor(conditions, projection) {
|
|
278
|
+
return this.memberModel.find(conditions, projection)
|
|
279
|
+
.sort({ 'member.id': factory.sortType.Ascending })
|
|
280
|
+
.cursor();
|
|
281
|
+
}
|
|
264
282
|
}
|
|
265
283
|
exports.MongoRepository = MongoRepository;
|
|
@@ -54,9 +54,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
54
54
|
}, {
|
|
55
55
|
typeOf: string;
|
|
56
56
|
project: any;
|
|
57
|
+
organizer: any;
|
|
57
58
|
checkInCount: number;
|
|
58
59
|
attendeeCount: number;
|
|
59
|
-
organizer: any;
|
|
60
60
|
_id?: string | undefined;
|
|
61
61
|
name?: any;
|
|
62
62
|
alternateName?: any;
|
|
@@ -88,9 +88,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
88
88
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
89
89
|
typeOf: string;
|
|
90
90
|
project: any;
|
|
91
|
+
organizer: any;
|
|
91
92
|
checkInCount: number;
|
|
92
93
|
attendeeCount: number;
|
|
93
|
-
organizer: any;
|
|
94
94
|
_id?: string | undefined;
|
|
95
95
|
name?: any;
|
|
96
96
|
alternateName?: any;
|
|
@@ -122,9 +122,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
122
122
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
123
123
|
typeOf: string;
|
|
124
124
|
project: any;
|
|
125
|
+
organizer: any;
|
|
125
126
|
checkInCount: number;
|
|
126
127
|
attendeeCount: number;
|
|
127
|
-
organizer: any;
|
|
128
128
|
_id?: string | undefined;
|
|
129
129
|
name?: any;
|
|
130
130
|
alternateName?: any;
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
import { Schema } from 'mongoose';
|
|
26
26
|
declare const modelName = "Member";
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* IAMメンバースキーマ
|
|
29
29
|
*/
|
|
30
30
|
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
31
|
collection: string;
|
|
@@ -53,16 +53,16 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
53
53
|
};
|
|
54
54
|
}, {
|
|
55
55
|
typeOf: string;
|
|
56
|
-
project
|
|
57
|
-
member
|
|
56
|
+
project: any;
|
|
57
|
+
member: any;
|
|
58
58
|
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
59
59
|
typeOf: string;
|
|
60
|
-
project
|
|
61
|
-
member
|
|
60
|
+
project: any;
|
|
61
|
+
member: any;
|
|
62
62
|
}>> & Omit<import("mongoose").FlatRecord<{
|
|
63
63
|
typeOf: string;
|
|
64
|
-
project
|
|
65
|
-
member
|
|
64
|
+
project: any;
|
|
65
|
+
member: any;
|
|
66
66
|
}> & {
|
|
67
67
|
_id: import("mongoose").Types.ObjectId;
|
|
68
68
|
}, never>>;
|
|
@@ -6,15 +6,21 @@ const writeConcern_1 = require("../writeConcern");
|
|
|
6
6
|
const modelName = 'Member';
|
|
7
7
|
exports.modelName = modelName;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* IAMメンバースキーマ
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose_1.Schema({
|
|
12
|
-
project:
|
|
12
|
+
project: {
|
|
13
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
13
16
|
typeOf: {
|
|
14
17
|
type: String,
|
|
15
18
|
required: true
|
|
16
19
|
},
|
|
17
|
-
member:
|
|
20
|
+
member: {
|
|
21
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
22
|
+
required: true
|
|
23
|
+
}
|
|
18
24
|
}, {
|
|
19
25
|
collection: 'members',
|
|
20
26
|
id: true,
|
|
@@ -43,11 +49,17 @@ const schema = new mongoose_1.Schema({
|
|
|
43
49
|
exports.schema = schema;
|
|
44
50
|
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
45
51
|
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
46
|
-
schema.index({ 'member.id': 1 }, {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
schema.index({ 'member.id': 1 }, { name: 'searchByMemberId' });
|
|
53
|
+
// uniqueIndex再設定(2023-07-25~)
|
|
54
|
+
// schema.index(
|
|
55
|
+
// { 'project.id': 1, 'member.id': 1 },
|
|
56
|
+
// {
|
|
57
|
+
// name: 'uniqueProjectMember',
|
|
58
|
+
// unique: true
|
|
59
|
+
// }
|
|
60
|
+
// );
|
|
61
|
+
schema.index({ 'project.id': 1, 'member.id': 1, 'member.memberOf.id': 1 }, {
|
|
62
|
+
name: 'uniqueIAMMember',
|
|
51
63
|
unique: true
|
|
52
64
|
});
|
|
53
65
|
schema.index({ 'member.typeOf': 1, 'member.id': 1 }, {
|
|
@@ -62,3 +74,5 @@ schema.index({ 'member.hasRole.roleName': 1, 'member.id': 1 }, {
|
|
|
62
74
|
'member.hasRole.roleName': { $exists: true }
|
|
63
75
|
}
|
|
64
76
|
});
|
|
77
|
+
schema.index({ 'member.memberOf.typeOf': 1, 'member.id': 1 }, { name: 'searchByMemberMemberOfTypeOf' });
|
|
78
|
+
schema.index({ 'member.memberOf.id': 1, 'member.id': 1 }, { name: 'searchByMemberMemberOfId' });
|