@chevre/domain 21.4.0-alpha.0 → 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 +12 -21
- 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 +72 -0
- package/lib/chevre/repo/productOffer.js +185 -0
- package/lib/chevre/repo/seller.d.ts +4 -3
- package/lib/chevre/repo/seller.js +40 -38
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- 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
|
|
@@ -3,34 +3,25 @@ import * as mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { chevre } from '../../../lib/index';
|
|
5
5
|
|
|
6
|
-
const PROJECT_ID = process.env.PROJECT_ID;
|
|
6
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
11
|
+
const productOfferRepo = new chevre.repository.ProductOffer(mongoose.connection);
|
|
13
12
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
itemOffered: { id: '62b90fef5b3eb4000b75150f' },
|
|
18
|
-
// seller?: {
|
|
19
|
-
// id: string;
|
|
20
|
-
// },
|
|
21
|
-
// availableAt?: {
|
|
22
|
-
// id: string;
|
|
23
|
-
// },
|
|
24
|
-
onlyValid: true,
|
|
25
|
-
// limit?: number,
|
|
26
|
-
// page?: number,
|
|
27
|
-
addSortIndex: false
|
|
28
|
-
})({
|
|
29
|
-
offer: offerRepo,
|
|
30
|
-
product: productRepo
|
|
13
|
+
const offers = await productOfferRepo.search({
|
|
14
|
+
project: { id: { $eq: PROJECT_ID } }
|
|
15
|
+
// seller: { id: { $eq: 'xxx' } }
|
|
31
16
|
});
|
|
32
|
-
console.log(offers
|
|
17
|
+
console.log(offers);
|
|
33
18
|
console.log(offers.length);
|
|
19
|
+
|
|
20
|
+
// await productOfferRepo.deleteOne({
|
|
21
|
+
// project: { id: PROJECT_ID },
|
|
22
|
+
// seller: { id: 'xxx' },
|
|
23
|
+
// itemOffered: { id: 'xxx' }
|
|
24
|
+
// });
|
|
34
25
|
}
|
|
35
26
|
|
|
36
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: {
|