@chevre/domain 21.4.0-alpha.1 → 21.4.0-alpha.10
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/cleanActions.ts +23 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +6 -0
- package/example/src/chevre/migrateEventOrganizer.ts +112 -0
- package/example/src/chevre/searchEvents.ts +1 -9
- package/example/src/chevre/searchProductOffers.ts +6 -0
- package/lib/chevre/repo/action.d.ts +6 -0
- package/lib/chevre/repo/action.js +13 -0
- package/lib/chevre/repo/event.d.ts +9 -4
- package/lib/chevre/repo/event.js +101 -60
- package/lib/chevre/repo/mongoose/schemas/event.d.ts +7 -4
- package/lib/chevre/repo/mongoose/schemas/event.js +15 -2
- package/lib/chevre/repo/productOffer.d.ts +45 -5
- package/lib/chevre/repo/productOffer.js +113 -14
- package/lib/chevre/repo/seller.d.ts +4 -3
- package/lib/chevre/repo/seller.js +40 -38
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -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/reserve/factory.d.ts +4 -3
- package/lib/chevre/service/assetTransaction/reserve/factory.js +6 -2
- package/lib/chevre/service/event.js +18 -22
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +15 -1
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
- package/lib/chevre/service/payment/creditCard.js +9 -1
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -1
- package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
- package/lib/chevre/service/payment/movieTicket.js +19 -2
- package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
- package/lib/chevre/service/transaction/returnOrder.js +9 -3
- package/package.json +3 -3
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +0 -90
- package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -75
- package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +0 -64
- package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +0 -79
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const result = await actionRepo.deleteStartDatePassedCertainPeriod({
|
|
13
|
+
$lt: moment()
|
|
14
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
15
|
+
.add(-548, 'days')
|
|
16
|
+
.toDate()
|
|
17
|
+
});
|
|
18
|
+
console.log(result);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main()
|
|
22
|
+
.then()
|
|
23
|
+
.catch(console.error);
|
|
@@ -5,6 +5,10 @@ import * as mongoose from 'mongoose';
|
|
|
5
5
|
import { chevre } from '../../../lib/index';
|
|
6
6
|
|
|
7
7
|
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
8
|
+
const ORGANIZER_ID = process.env.ORGANIZER_ID;
|
|
9
|
+
if (typeof ORGANIZER_ID !== 'string' || ORGANIZER_ID.length === 0) {
|
|
10
|
+
throw new Error('ORGANIZER_ID undefined');
|
|
11
|
+
}
|
|
8
12
|
|
|
9
13
|
// tslint:disable-next-line:max-func-body-length
|
|
10
14
|
async function main() {
|
|
@@ -15,6 +19,7 @@ async function main() {
|
|
|
15
19
|
const result = await eventRepo.createManyIfNotExist<chevre.factory.eventType.ScreeningEvent>([
|
|
16
20
|
{
|
|
17
21
|
attributes: {
|
|
22
|
+
organizer: { id: String(ORGANIZER_ID) },
|
|
18
23
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
19
24
|
project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
|
|
20
25
|
name: {
|
|
@@ -184,6 +189,7 @@ async function main() {
|
|
|
184
189
|
},
|
|
185
190
|
{
|
|
186
191
|
attributes: {
|
|
192
|
+
organizer: { id: String(ORGANIZER_ID) },
|
|
187
193
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
188
194
|
project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
|
|
189
195
|
name: {
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
|
|
13
|
+
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = eventRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
// 'project.id': { $eq: project.id },
|
|
20
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
21
|
+
typeOf: {
|
|
22
|
+
$in: [
|
|
23
|
+
chevre.factory.eventType.ScreeningEvent,
|
|
24
|
+
chevre.factory.eventType.ScreeningEventSeries
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
// startDate: {
|
|
28
|
+
// $gte: moment()
|
|
29
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
30
|
+
// .add(-6, 'months')
|
|
31
|
+
// .toDate()
|
|
32
|
+
// }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
_id: 1,
|
|
36
|
+
project: 1,
|
|
37
|
+
location: 1,
|
|
38
|
+
superEvent: 1,
|
|
39
|
+
startDate: 1,
|
|
40
|
+
typeOf: 1,
|
|
41
|
+
organizer: 1
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
console.log('events found');
|
|
45
|
+
|
|
46
|
+
let i = 0;
|
|
47
|
+
let updateCount = 0;
|
|
48
|
+
await cursor.eachAsync(async (doc) => {
|
|
49
|
+
i += 1;
|
|
50
|
+
const event: Pick<
|
|
51
|
+
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
|
|
52
|
+
'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer' | 'superEvent'
|
|
53
|
+
> | Pick<
|
|
54
|
+
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEventSeries>,
|
|
55
|
+
'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer'
|
|
56
|
+
> = doc.toObject();
|
|
57
|
+
|
|
58
|
+
const organizerId = event.organizer?.id;
|
|
59
|
+
const alreadyMigrated = typeof organizerId === 'string';
|
|
60
|
+
|
|
61
|
+
if (alreadyMigrated) {
|
|
62
|
+
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
63
|
+
} else {
|
|
64
|
+
let movieTheaterId: string;
|
|
65
|
+
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
66
|
+
movieTheaterId = event.location.id;
|
|
67
|
+
} else {
|
|
68
|
+
movieTheaterId = event.superEvent.location.id;
|
|
69
|
+
}
|
|
70
|
+
const movieTheaters = <Pick<chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom, 'parentOrganization'>[]>
|
|
71
|
+
await placeRepo.searchMovieTheaters(
|
|
72
|
+
{
|
|
73
|
+
limit: 1,
|
|
74
|
+
page: 1,
|
|
75
|
+
project: { id: { $eq: event.project.id } },
|
|
76
|
+
id: { $eq: movieTheaterId }
|
|
77
|
+
},
|
|
78
|
+
['parentOrganization'],
|
|
79
|
+
[]
|
|
80
|
+
);
|
|
81
|
+
const movieTheater = movieTheaters.shift();
|
|
82
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
83
|
+
console.log('movieTheater found', event.project.id, event.id, event.startDate, 'sellerId:', sellerId, i);
|
|
84
|
+
// if (typeof sellerId !== 'string') {
|
|
85
|
+
// throw new Error('movieTheater not found');
|
|
86
|
+
// }
|
|
87
|
+
if (typeof sellerId === 'string') {
|
|
88
|
+
const newOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
|
|
89
|
+
id: sellerId
|
|
90
|
+
};
|
|
91
|
+
console.log('updating event...', event.project.id, event.id, event.startDate, i);
|
|
92
|
+
await eventRepo.updatePartiallyById({
|
|
93
|
+
project: { id: event.project.id },
|
|
94
|
+
id: event.id,
|
|
95
|
+
attributes: <any>{
|
|
96
|
+
typeOf: event.typeOf,
|
|
97
|
+
organizer: newOrganizer
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
updateCount += 1;
|
|
101
|
+
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
console.log(i, 'events checked');
|
|
107
|
+
console.log(updateCount, 'events updated');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
main()
|
|
111
|
+
.then()
|
|
112
|
+
.catch(console.error);
|
|
@@ -10,14 +10,6 @@ async function main() {
|
|
|
10
10
|
|
|
11
11
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
12
12
|
|
|
13
|
-
const event = await eventRepo.findById(
|
|
14
|
-
{ id: 'al6aff83y' },
|
|
15
|
-
{
|
|
16
|
-
name: 1
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
console.log('event found', event);
|
|
20
|
-
|
|
21
13
|
const events = await eventRepo.search(
|
|
22
14
|
{
|
|
23
15
|
limit: 100,
|
|
@@ -25,7 +17,7 @@ async function main() {
|
|
|
25
17
|
sort: { startDate: 1 },
|
|
26
18
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
27
19
|
project: { id: { $eq: PROJECT_ID } },
|
|
28
|
-
id: { $
|
|
20
|
+
id: { $eq: 'al6aff83y' }
|
|
29
21
|
},
|
|
30
22
|
{
|
|
31
23
|
name: 1
|
|
@@ -16,6 +16,12 @@ async function main() {
|
|
|
16
16
|
});
|
|
17
17
|
console.log(offers);
|
|
18
18
|
console.log(offers.length);
|
|
19
|
+
|
|
20
|
+
// await productOfferRepo.deleteOne({
|
|
21
|
+
// project: { id: PROJECT_ID },
|
|
22
|
+
// seller: { id: 'xxx' },
|
|
23
|
+
// itemOffered: { id: 'xxx' }
|
|
24
|
+
// });
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
main()
|
|
@@ -163,6 +163,12 @@ export declare class MongoRepository {
|
|
|
163
163
|
};
|
|
164
164
|
entranceGateIdentifier: string;
|
|
165
165
|
}): Promise<IUseActionCountByOffer[]>;
|
|
166
|
+
/**
|
|
167
|
+
* 開始日時を一定期間過ぎたアクションを削除する
|
|
168
|
+
*/
|
|
169
|
+
deleteStartDatePassedCertainPeriod(params: {
|
|
170
|
+
$lt: Date;
|
|
171
|
+
}): Promise<any>;
|
|
166
172
|
/**
|
|
167
173
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
168
174
|
*/
|
|
@@ -713,6 +713,19 @@ class MongoRepository {
|
|
|
713
713
|
.exec();
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
+
/**
|
|
717
|
+
* 開始日時を一定期間過ぎたアクションを削除する
|
|
718
|
+
*/
|
|
719
|
+
deleteStartDatePassedCertainPeriod(params) {
|
|
720
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
721
|
+
return this.actionModel.deleteMany({
|
|
722
|
+
startDate: {
|
|
723
|
+
$lt: params.$lt
|
|
724
|
+
}
|
|
725
|
+
})
|
|
726
|
+
.exec();
|
|
727
|
+
});
|
|
728
|
+
}
|
|
716
729
|
/**
|
|
717
730
|
* 終了日時を一定期間過ぎたアクションを削除する
|
|
718
731
|
*/
|
|
@@ -121,6 +121,9 @@ export declare class MongoRepository {
|
|
|
121
121
|
* イベント部分更新
|
|
122
122
|
*/
|
|
123
123
|
updatePartiallyById<T extends factory.eventType>(params: {
|
|
124
|
+
project: {
|
|
125
|
+
id: string;
|
|
126
|
+
};
|
|
124
127
|
id: string;
|
|
125
128
|
attributes: IAttributes4patchUpdate<T>;
|
|
126
129
|
}): Promise<factory.event.IEvent<T>>;
|
|
@@ -143,15 +146,11 @@ export declare class MongoRepository {
|
|
|
143
146
|
oldEventId: string;
|
|
144
147
|
attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
|
|
145
148
|
}): Promise<factory.event.IEvent<factory.eventType.ScreeningEvent>>;
|
|
146
|
-
count<T extends factory.eventType>(params: ISearchConditions<T>): Promise<number>;
|
|
147
149
|
/**
|
|
148
150
|
* イベントを検索する
|
|
149
151
|
*/
|
|
150
152
|
search<T extends factory.eventType>(params: ISearchConditions<T>, projection?: IProjection): Promise<factory.event.IEvent<T>[]>;
|
|
151
153
|
searchIds<T extends factory.eventType>(params: ISearchConditions<T>): Promise<string[]>;
|
|
152
|
-
findById<T extends factory.eventType>(params: {
|
|
153
|
-
id: string;
|
|
154
|
-
}, projection?: IProjection): Promise<factory.event.IEvent<T>>;
|
|
155
154
|
findMinimizedIndividualEventById<T extends factory.eventType.ScreeningEvent | factory.eventType.Event>(params: {
|
|
156
155
|
id: string;
|
|
157
156
|
}): Promise<IMinimizedIndividualEvent<T>>;
|
|
@@ -159,9 +158,15 @@ export declare class MongoRepository {
|
|
|
159
158
|
* イベントをキャンセルする
|
|
160
159
|
*/
|
|
161
160
|
cancel(params: {
|
|
161
|
+
project: {
|
|
162
|
+
id: string;
|
|
163
|
+
};
|
|
162
164
|
id: string;
|
|
163
165
|
}): Promise<void>;
|
|
164
166
|
deleteById(params: {
|
|
167
|
+
project: {
|
|
168
|
+
id: string;
|
|
169
|
+
};
|
|
165
170
|
id: string;
|
|
166
171
|
}): Promise<void>;
|
|
167
172
|
deleteByProject(params: {
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -51,19 +51,35 @@ class MongoRepository {
|
|
|
51
51
|
}
|
|
52
52
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
53
53
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
54
|
-
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;
|
|
55
|
-
const andConditions = [
|
|
54
|
+
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 typeOfEq = conditions.typeOf;
|
|
57
|
+
if (typeof typeOfEq === 'string') {
|
|
58
|
+
andConditions.push({ typeOf: { $eq: typeOfEq } });
|
|
59
|
+
}
|
|
60
|
+
const typeOfIn = conditions.typeOfIn;
|
|
61
|
+
if (Array.isArray(typeOfIn)) {
|
|
62
|
+
andConditions.push({ typeOf: { $in: typeOfIn } });
|
|
63
|
+
}
|
|
64
|
+
// typeOf条件必須検証(2023-07-13~)
|
|
65
|
+
if (typeof typeOfEq !== 'string' && !Array.isArray(typeOfIn)) {
|
|
66
|
+
throw new factory.errors.ArgumentNull('typeOf');
|
|
67
|
+
}
|
|
56
68
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
57
69
|
if (typeof projectIdEq === 'string') {
|
|
58
|
-
andConditions.push({
|
|
59
|
-
'project.id': { $eq: projectIdEq }
|
|
60
|
-
});
|
|
70
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
61
71
|
}
|
|
62
|
-
const
|
|
72
|
+
const organizerIdEq = (_d = (_c = conditions.organizer) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
|
|
73
|
+
if (typeof organizerIdEq === 'string') {
|
|
74
|
+
andConditions.push({ 'organizer.id': { $exists: true, $eq: organizerIdEq } });
|
|
75
|
+
}
|
|
76
|
+
const idEq = (_e = conditions.id) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
77
|
+
if (typeof idEq === 'string') {
|
|
78
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
79
|
+
}
|
|
80
|
+
const idIn = (_f = conditions.id) === null || _f === void 0 ? void 0 : _f.$in;
|
|
63
81
|
if (Array.isArray(idIn)) {
|
|
64
|
-
andConditions.push({
|
|
65
|
-
_id: { $in: idIn }
|
|
66
|
-
});
|
|
82
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
67
83
|
}
|
|
68
84
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
69
85
|
/* istanbul ignore else */
|
|
@@ -114,17 +130,17 @@ class MongoRepository {
|
|
|
114
130
|
endDate: { $lte: conditions.endThrough }
|
|
115
131
|
});
|
|
116
132
|
}
|
|
117
|
-
const locationBranchCodeEq = (
|
|
133
|
+
const locationBranchCodeEq = (_h = (_g = conditions.location) === null || _g === void 0 ? void 0 : _g.branchCode) === null || _h === void 0 ? void 0 : _h.$eq;
|
|
118
134
|
if (typeof locationBranchCodeEq === 'string') {
|
|
119
135
|
andConditions.push({ 'location.branchCode': { $exists: true, $eq: locationBranchCodeEq } });
|
|
120
136
|
}
|
|
121
|
-
const locationBranchCodeIn = (
|
|
137
|
+
const locationBranchCodeIn = (_k = (_j = conditions.location) === null || _j === void 0 ? void 0 : _j.branchCode) === null || _k === void 0 ? void 0 : _k.$in;
|
|
122
138
|
if (Array.isArray(locationBranchCodeIn)) {
|
|
123
139
|
andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
|
|
124
140
|
}
|
|
125
141
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
126
142
|
/* istanbul ignore else */
|
|
127
|
-
const hasOfferCatalogIdEq = (
|
|
143
|
+
const hasOfferCatalogIdEq = (_m = (_l = conditions.hasOfferCatalog) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$eq;
|
|
128
144
|
if (typeof hasOfferCatalogIdEq === 'string') {
|
|
129
145
|
andConditions.push({
|
|
130
146
|
'hasOfferCatalog.id': {
|
|
@@ -133,7 +149,7 @@ class MongoRepository {
|
|
|
133
149
|
}
|
|
134
150
|
});
|
|
135
151
|
}
|
|
136
|
-
const additionalPropertyElemMatch = (
|
|
152
|
+
const additionalPropertyElemMatch = (_o = conditions.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
|
|
137
153
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
138
154
|
andConditions.push({
|
|
139
155
|
additionalProperty: {
|
|
@@ -149,7 +165,7 @@ class MongoRepository {
|
|
|
149
165
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
150
166
|
/* istanbul ignore else */
|
|
151
167
|
if (params.offers !== undefined) {
|
|
152
|
-
const itemOfferedIdIn4event = (
|
|
168
|
+
const itemOfferedIdIn4event = (_q = (_p = params.offers.itemOffered) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$in;
|
|
153
169
|
if (Array.isArray(itemOfferedIdIn4event)) {
|
|
154
170
|
andConditions.push({
|
|
155
171
|
'offers.itemOffered.id': {
|
|
@@ -199,8 +215,8 @@ class MongoRepository {
|
|
|
199
215
|
}
|
|
200
216
|
}
|
|
201
217
|
}
|
|
202
|
-
const sellerMakesOfferElemMatch4event = (
|
|
203
|
-
if (typeof ((
|
|
218
|
+
const sellerMakesOfferElemMatch4event = (_t = (_s = (_r = params.offers) === null || _r === void 0 ? void 0 : _r.seller) === null || _s === void 0 ? void 0 : _s.makesOffer) === null || _t === void 0 ? void 0 : _t.$elemMatch;
|
|
219
|
+
if (typeof ((_u = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _u === void 0 ? void 0 : _u.$eq) === 'string') {
|
|
204
220
|
andConditions.push({
|
|
205
221
|
'offers.seller.makesOffer': {
|
|
206
222
|
$exists: true,
|
|
@@ -208,7 +224,7 @@ class MongoRepository {
|
|
|
208
224
|
}
|
|
209
225
|
});
|
|
210
226
|
}
|
|
211
|
-
const reservationForIdentifierEq = (
|
|
227
|
+
const reservationForIdentifierEq = (_z = (_y = (_x = (_w = (_v = params.offers) === null || _v === void 0 ? void 0 : _v.itemOffered) === null || _w === void 0 ? void 0 : _w.serviceOutput) === null || _x === void 0 ? void 0 : _x.reservationFor) === null || _y === void 0 ? void 0 : _y.identifier) === null || _z === void 0 ? void 0 : _z.$eq;
|
|
212
228
|
if (typeof reservationForIdentifierEq === 'string') {
|
|
213
229
|
andConditions.push({
|
|
214
230
|
'offers.itemOffered.serviceOutput.reservationFor.identifier': {
|
|
@@ -217,7 +233,7 @@ class MongoRepository {
|
|
|
217
233
|
}
|
|
218
234
|
});
|
|
219
235
|
}
|
|
220
|
-
const reservationForArrivalBusStopBranchCodeEq = (
|
|
236
|
+
const reservationForArrivalBusStopBranchCodeEq = (_5 = (_4 = (_3 = (_2 = (_1 = (_0 = params.offers) === null || _0 === void 0 ? void 0 : _0.itemOffered) === null || _1 === void 0 ? void 0 : _1.serviceOutput) === null || _2 === void 0 ? void 0 : _2.reservationFor) === null || _3 === void 0 ? void 0 : _3.arrivalBusStop) === null || _4 === void 0 ? void 0 : _4.branchCode) === null || _5 === void 0 ? void 0 : _5.$eq;
|
|
221
237
|
if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
|
|
222
238
|
andConditions.push({
|
|
223
239
|
'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
|
|
@@ -226,7 +242,7 @@ class MongoRepository {
|
|
|
226
242
|
}
|
|
227
243
|
});
|
|
228
244
|
}
|
|
229
|
-
const reservationForDepartureBusStopBranchCodeEq = (
|
|
245
|
+
const reservationForDepartureBusStopBranchCodeEq = (_11 = (_10 = (_9 = (_8 = (_7 = (_6 = params.offers) === null || _6 === void 0 ? void 0 : _6.itemOffered) === null || _7 === void 0 ? void 0 : _7.serviceOutput) === null || _8 === void 0 ? void 0 : _8.reservationFor) === null || _9 === void 0 ? void 0 : _9.departureBusStop) === null || _10 === void 0 ? void 0 : _10.branchCode) === null || _11 === void 0 ? void 0 : _11.$eq;
|
|
230
246
|
if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
|
|
231
247
|
andConditions.push({
|
|
232
248
|
'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
|
|
@@ -260,7 +276,7 @@ class MongoRepository {
|
|
|
260
276
|
}
|
|
261
277
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
262
278
|
/* istanbul ignore else */
|
|
263
|
-
const superEventLocationIdEq = (
|
|
279
|
+
const superEventLocationIdEq = (_14 = (_13 = (_12 = params.superEvent) === null || _12 === void 0 ? void 0 : _12.location) === null || _13 === void 0 ? void 0 : _13.id) === null || _14 === void 0 ? void 0 : _14.$eq;
|
|
264
280
|
if (typeof superEventLocationIdEq === 'string') {
|
|
265
281
|
andConditions.push({
|
|
266
282
|
'superEvent.location.id': {
|
|
@@ -303,7 +319,7 @@ class MongoRepository {
|
|
|
303
319
|
});
|
|
304
320
|
}
|
|
305
321
|
}
|
|
306
|
-
const itemOfferedIdIn = (
|
|
322
|
+
const itemOfferedIdIn = (_17 = (_16 = (_15 = params.offers) === null || _15 === void 0 ? void 0 : _15.itemOffered) === null || _16 === void 0 ? void 0 : _16.id) === null || _17 === void 0 ? void 0 : _17.$in;
|
|
307
323
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
308
324
|
andConditions.push({
|
|
309
325
|
'offers.itemOffered.id': {
|
|
@@ -312,7 +328,7 @@ class MongoRepository {
|
|
|
312
328
|
}
|
|
313
329
|
});
|
|
314
330
|
}
|
|
315
|
-
const itemOfferedTicketedSeatTypeOfIn = (
|
|
331
|
+
const itemOfferedTicketedSeatTypeOfIn = (_22 = (_21 = (_20 = (_19 = (_18 = params.offers) === null || _18 === void 0 ? void 0 : _18.itemOffered) === null || _19 === void 0 ? void 0 : _19.serviceOutput) === null || _20 === void 0 ? void 0 : _20.reservedTicket) === null || _21 === void 0 ? void 0 : _21.ticketedSeat) === null || _22 === void 0 ? void 0 : _22.typeOfs;
|
|
316
332
|
if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
|
|
317
333
|
andConditions.push({
|
|
318
334
|
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
@@ -321,7 +337,7 @@ class MongoRepository {
|
|
|
321
337
|
}
|
|
322
338
|
});
|
|
323
339
|
}
|
|
324
|
-
const itemOfferedServiceTypeIdIn = (
|
|
340
|
+
const itemOfferedServiceTypeIdIn = (_25 = (_24 = (_23 = params.offers) === null || _23 === void 0 ? void 0 : _23.itemOffered) === null || _24 === void 0 ? void 0 : _24.serviceType) === null || _25 === void 0 ? void 0 : _25.ids;
|
|
325
341
|
if (Array.isArray(itemOfferedServiceTypeIdIn)) {
|
|
326
342
|
andConditions.push({
|
|
327
343
|
'offers.itemOffered.serviceType.id': {
|
|
@@ -330,8 +346,8 @@ class MongoRepository {
|
|
|
330
346
|
}
|
|
331
347
|
});
|
|
332
348
|
}
|
|
333
|
-
const sellerMakesOfferElemMatch = (
|
|
334
|
-
if (typeof ((
|
|
349
|
+
const sellerMakesOfferElemMatch = (_28 = (_27 = (_26 = params.offers) === null || _26 === void 0 ? void 0 : _26.seller) === null || _27 === void 0 ? void 0 : _27.makesOffer) === null || _28 === void 0 ? void 0 : _28.$elemMatch;
|
|
350
|
+
if (typeof ((_29 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _29 === void 0 ? void 0 : _29.$eq) === 'string') {
|
|
335
351
|
andConditions.push({
|
|
336
352
|
'offers.seller.makesOffer': {
|
|
337
353
|
$exists: true,
|
|
@@ -368,7 +384,7 @@ class MongoRepository {
|
|
|
368
384
|
]
|
|
369
385
|
});
|
|
370
386
|
}
|
|
371
|
-
const locationIdEq = (
|
|
387
|
+
const locationIdEq = (_31 = (_30 = params.location) === null || _30 === void 0 ? void 0 : _30.id) === null || _31 === void 0 ? void 0 : _31.$eq;
|
|
372
388
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
373
389
|
/* istanbul ignore else */
|
|
374
390
|
if (typeof locationIdEq === 'string') {
|
|
@@ -390,7 +406,7 @@ class MongoRepository {
|
|
|
390
406
|
});
|
|
391
407
|
}
|
|
392
408
|
}
|
|
393
|
-
const workPerformedIdentifierIn = (
|
|
409
|
+
const workPerformedIdentifierIn = (_32 = params.workPerformed) === null || _32 === void 0 ? void 0 : _32.identifiers;
|
|
394
410
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
395
411
|
/* istanbul ignore else */
|
|
396
412
|
if (Array.isArray(workPerformedIdentifierIn)) {
|
|
@@ -398,13 +414,13 @@ class MongoRepository {
|
|
|
398
414
|
'workPerformed.identifier': { $exists: true, $in: workPerformedIdentifierIn }
|
|
399
415
|
});
|
|
400
416
|
}
|
|
401
|
-
const workPerformedVersionEq = (
|
|
417
|
+
const workPerformedVersionEq = (_34 = (_33 = params.workPerformed) === null || _33 === void 0 ? void 0 : _33.version) === null || _34 === void 0 ? void 0 : _34.$eq;
|
|
402
418
|
if (typeof workPerformedVersionEq === 'string') {
|
|
403
419
|
andConditions.push({
|
|
404
420
|
'workPerformed.version': { $exists: true, $eq: workPerformedVersionEq }
|
|
405
421
|
});
|
|
406
422
|
}
|
|
407
|
-
const videoFormatTypeOfEq = (
|
|
423
|
+
const videoFormatTypeOfEq = (_36 = (_35 = params.videoFormat) === null || _35 === void 0 ? void 0 : _35.typeOf) === null || _36 === void 0 ? void 0 : _36.$eq;
|
|
408
424
|
if (typeof videoFormatTypeOfEq === 'string') {
|
|
409
425
|
andConditions.push({
|
|
410
426
|
'videoFormat.typeOf': {
|
|
@@ -413,7 +429,7 @@ class MongoRepository {
|
|
|
413
429
|
}
|
|
414
430
|
});
|
|
415
431
|
}
|
|
416
|
-
const videoFormatTypeOfIn = (
|
|
432
|
+
const videoFormatTypeOfIn = (_38 = (_37 = params.videoFormat) === null || _37 === void 0 ? void 0 : _37.typeOf) === null || _38 === void 0 ? void 0 : _38.$in;
|
|
417
433
|
if (Array.isArray(videoFormatTypeOfIn)) {
|
|
418
434
|
andConditions.push({
|
|
419
435
|
'videoFormat.typeOf': {
|
|
@@ -422,7 +438,7 @@ class MongoRepository {
|
|
|
422
438
|
}
|
|
423
439
|
});
|
|
424
440
|
}
|
|
425
|
-
const soundFormatTypeOfEq = (
|
|
441
|
+
const soundFormatTypeOfEq = (_40 = (_39 = params.soundFormat) === null || _39 === void 0 ? void 0 : _39.typeOf) === null || _40 === void 0 ? void 0 : _40.$eq;
|
|
426
442
|
if (typeof soundFormatTypeOfEq === 'string') {
|
|
427
443
|
andConditions.push({
|
|
428
444
|
'soundFormat.typeOf': {
|
|
@@ -431,7 +447,7 @@ class MongoRepository {
|
|
|
431
447
|
}
|
|
432
448
|
});
|
|
433
449
|
}
|
|
434
|
-
const soundFormatTypeOfIn = (
|
|
450
|
+
const soundFormatTypeOfIn = (_42 = (_41 = params.soundFormat) === null || _41 === void 0 ? void 0 : _41.typeOf) === null || _42 === void 0 ? void 0 : _42.$in;
|
|
435
451
|
if (Array.isArray(soundFormatTypeOfIn)) {
|
|
436
452
|
andConditions.push({
|
|
437
453
|
'soundFormat.typeOf': {
|
|
@@ -586,6 +602,7 @@ class MongoRepository {
|
|
|
586
602
|
const _a = params.attributes, { typeOf } = _a, updateFields = __rest(_a, ["typeOf"]);
|
|
587
603
|
doc = yield this.eventModel.findOneAndUpdate({
|
|
588
604
|
_id: params.id,
|
|
605
|
+
'project.id': { $eq: params.project.id },
|
|
589
606
|
typeOf: params.attributes.typeOf
|
|
590
607
|
}, {
|
|
591
608
|
$set: updateFields
|
|
@@ -688,6 +705,7 @@ class MongoRepository {
|
|
|
688
705
|
const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
|
|
689
706
|
const id = uniqid();
|
|
690
707
|
doc = yield this.eventModel.findOneAndUpdate({
|
|
708
|
+
'project.id': { $eq: params.attributes.project.id },
|
|
691
709
|
typeOf: params.attributes.typeOf,
|
|
692
710
|
// 追加特性をキーに更新
|
|
693
711
|
additionalProperty: {
|
|
@@ -711,14 +729,16 @@ class MongoRepository {
|
|
|
711
729
|
return doc.toObject();
|
|
712
730
|
});
|
|
713
731
|
}
|
|
714
|
-
count(
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
732
|
+
// public async count<T extends factory.eventType>(
|
|
733
|
+
// params: ISearchConditions<T>
|
|
734
|
+
// ): Promise<number> {
|
|
735
|
+
// const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
736
|
+
// return this.eventModel.countDocuments(
|
|
737
|
+
// { $and: conditions }
|
|
738
|
+
// )
|
|
739
|
+
// .setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
740
|
+
// .exec();
|
|
741
|
+
// }
|
|
722
742
|
/**
|
|
723
743
|
* イベントを検索する
|
|
724
744
|
*/
|
|
@@ -766,24 +786,39 @@ class MongoRepository {
|
|
|
766
786
|
.exec();
|
|
767
787
|
});
|
|
768
788
|
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
789
|
+
// searchに置き換え(2023-07-13~)
|
|
790
|
+
// public async findById<T extends factory.eventType>(
|
|
791
|
+
// params: {
|
|
792
|
+
// project: { id: string };
|
|
793
|
+
// id: string;
|
|
794
|
+
// },
|
|
795
|
+
// projection?: IProjection
|
|
796
|
+
// ): Promise<factory.event.IEvent<T>> {
|
|
797
|
+
// const positiveProjectionExists: boolean = (projection !== undefined && projection !== null)
|
|
798
|
+
// ? Object.values(projection)
|
|
799
|
+
// .some((value) => value !== 0)
|
|
800
|
+
// : false;
|
|
801
|
+
// const doc = await this.eventModel.findOne(
|
|
802
|
+
// {
|
|
803
|
+
// _id: params.id,
|
|
804
|
+
// 'project.id': { $eq: params.project.id }
|
|
805
|
+
// },
|
|
806
|
+
// // :1対応(2023-01-25~)
|
|
807
|
+
// (positiveProjectionExists)
|
|
808
|
+
// ? projection
|
|
809
|
+
// : {
|
|
810
|
+
// ...projection,
|
|
811
|
+
// __v: 0,
|
|
812
|
+
// createdAt: 0,
|
|
813
|
+
// updatedAt: 0
|
|
814
|
+
// }
|
|
815
|
+
// )
|
|
816
|
+
// .exec();
|
|
817
|
+
// if (doc === null) {
|
|
818
|
+
// throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
819
|
+
// }
|
|
820
|
+
// return doc.toObject();
|
|
821
|
+
// }
|
|
787
822
|
findMinimizedIndividualEventById(params) {
|
|
788
823
|
return __awaiter(this, void 0, void 0, function* () {
|
|
789
824
|
const doc = yield this.eventModel.findOne({ _id: params.id }, exports.PROJECTION_MINIMIZED_EVENT)
|
|
@@ -799,13 +834,19 @@ class MongoRepository {
|
|
|
799
834
|
*/
|
|
800
835
|
cancel(params) {
|
|
801
836
|
return __awaiter(this, void 0, void 0, function* () {
|
|
802
|
-
yield this.eventModel.findOneAndUpdate({
|
|
837
|
+
yield this.eventModel.findOneAndUpdate({
|
|
838
|
+
_id: params.id,
|
|
839
|
+
'project.id': { $eq: params.project.id }
|
|
840
|
+
}, { eventStatus: factory.eventStatusType.EventCancelled })
|
|
803
841
|
.exec();
|
|
804
842
|
});
|
|
805
843
|
}
|
|
806
844
|
deleteById(params) {
|
|
807
845
|
return __awaiter(this, void 0, void 0, function* () {
|
|
808
|
-
yield this.eventModel.findOneAndDelete({
|
|
846
|
+
yield this.eventModel.findOneAndDelete({
|
|
847
|
+
_id: params.id,
|
|
848
|
+
'project.id': { $eq: params.project.id }
|
|
849
|
+
})
|
|
809
850
|
.exec();
|
|
810
851
|
});
|
|
811
852
|
}
|