@chevre/domain 21.4.0-alpha.3 → 21.4.0-alpha.30
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/cleanEventsByMovieTheater.ts +32 -0
- package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
- package/example/src/chevre/createManyEventsIfNotExist.ts +6 -0
- package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +31 -0
- package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +32 -0
- package/example/src/chevre/migrateEventOrganizer.ts +125 -0
- 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/searchEvents.ts +1 -9
- package/example/src/chevre/searchPermissions.ts +7 -15
- package/lib/chevre/factory/event.d.ts +1 -1
- package/lib/chevre/repo/action.d.ts +6 -0
- package/lib/chevre/repo/action.js +13 -0
- package/lib/chevre/repo/assetTransaction.d.ts +4 -1
- package/lib/chevre/repo/assetTransaction.js +6 -12
- package/lib/chevre/repo/event.d.ts +25 -4
- package/lib/chevre/repo/event.js +122 -60
- package/lib/chevre/repo/member.d.ts +76 -1
- package/lib/chevre/repo/member.js +81 -20
- 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/mongoose/schemas/member.d.ts +7 -7
- package/lib/chevre/repo/mongoose/schemas/member.js +12 -6
- 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/reservation.d.ts +33 -21
- package/lib/chevre/repo/reservation.js +97 -79
- package/lib/chevre/repo/seller.d.ts +18 -5
- package/lib/chevre/repo/seller.js +53 -46
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
- 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 +2 -2
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +10 -4
- package/lib/chevre/service/assetTransaction/reserve/factory.js +21 -40
- 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 +26 -26
- package/lib/chevre/service/iam.d.ts +5 -0
- package/lib/chevre/service/iam.js +7 -19
- package/lib/chevre/service/moneyTransfer.js +1 -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 +16 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +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 +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/payment/paymentCard.js +1 -3
- 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 +1 -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/findByOrderNumberAndReservationId.ts +0 -20
- package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
- 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
- package/example/src/chevre/searchScreeningRooms.ts +0 -33
- package/example/src/chevre/syncScreeningRooms.ts +0 -21
- package/example/src/chevre/syncScreeningRoomsAll.ts +0 -41
|
@@ -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);
|
|
@@ -0,0 +1,32 @@
|
|
|
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 LOCATION_BRANCH_CODE = String(process.env.LOCATION_BRANCH_CODE);
|
|
9
|
+
// const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
10
|
+
|
|
11
|
+
// tslint:disable-next-line:max-func-body-length
|
|
12
|
+
async function main() {
|
|
13
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
+
|
|
15
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
let result = await eventRepo.deleteScreeningEventSeriesByMovieTheaterBranchCode({
|
|
18
|
+
project: { id: project.id },
|
|
19
|
+
location: { branchCode: LOCATION_BRANCH_CODE }
|
|
20
|
+
});
|
|
21
|
+
console.log('deleteScreeningEventSeriesByMovieTheaterBranchCode processed.', result);
|
|
22
|
+
|
|
23
|
+
result = await eventRepo.deleteScreeningEventsByMovieTheaterBranchCode({
|
|
24
|
+
project: { id: project.id },
|
|
25
|
+
location: { branchCode: LOCATION_BRANCH_CODE }
|
|
26
|
+
});
|
|
27
|
+
console.log('deleteScreeningEventsByMovieTheaterBranchCode processed.', result);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then()
|
|
32
|
+
.catch(console.error);
|
|
@@ -0,0 +1,126 @@
|
|
|
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 USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const now = new Date();
|
|
14
|
+
|
|
15
|
+
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
16
|
+
const orderRepo = new chevre.repository.Order(mongoose.connection);
|
|
17
|
+
const personRepo = new chevre.repository.Person({ userPoolId: USERPOOL_ID_NEW });
|
|
18
|
+
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
|
+
|
|
20
|
+
const cursor = orderRepo.getCursor(
|
|
21
|
+
{
|
|
22
|
+
'project.id': { $eq: project.id },
|
|
23
|
+
'customer.typeOf': { $eq: chevre.factory.personType.Person },
|
|
24
|
+
'acceptedOffers.itemOffered.typeOf': { $exists: true.valueOf, $eq: chevre.factory.reservationType.EventReservation }
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
_id: 1,
|
|
28
|
+
project: 1,
|
|
29
|
+
orderNumber: 1,
|
|
30
|
+
orderDate: 1,
|
|
31
|
+
customer: 1
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
console.log('orders found');
|
|
35
|
+
|
|
36
|
+
let i = 0;
|
|
37
|
+
let updateCount = 0;
|
|
38
|
+
await cursor.eachAsync(async (doc) => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const order = <Pick<chevre.factory.order.IOrder, 'id' | 'orderDate' | 'orderNumber' | 'customer' | 'project'>>doc.toObject();
|
|
41
|
+
|
|
42
|
+
// person検索
|
|
43
|
+
console.log('seaching person....', order.project.id, order.orderNumber, order.orderDate, order.customer.id, i);
|
|
44
|
+
const people = await personRepo.search({ id: String(order.customer.id) });
|
|
45
|
+
const person = people.shift();
|
|
46
|
+
const activePerson = (<any>person).Enabled === true;
|
|
47
|
+
if (activePerson) {
|
|
48
|
+
// activeであれば何もしない
|
|
49
|
+
console.log(
|
|
50
|
+
'person found', order.project.id, order.orderNumber, order.orderDate,
|
|
51
|
+
person?.memberOf?.membershipNumber,
|
|
52
|
+
(<any>person).Enabled, i);
|
|
53
|
+
} else {
|
|
54
|
+
// migrateアクション検索
|
|
55
|
+
const deletePersonActions = <chevre.factory.action.update.deleteAction.member.IAction[]>await actionRepo.search(
|
|
56
|
+
{
|
|
57
|
+
limit: 1,
|
|
58
|
+
page: 1,
|
|
59
|
+
project: { id: { $eq: order.project.id } },
|
|
60
|
+
actionStatus: { $in: [chevre.factory.actionStatusType.CompletedActionStatus] },
|
|
61
|
+
typeOf: { $eq: chevre.factory.actionType.DeleteAction },
|
|
62
|
+
object: {
|
|
63
|
+
id: { $eq: order.customer.id },
|
|
64
|
+
typeOf: { $eq: chevre.factory.personType.Person }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[],
|
|
68
|
+
[]
|
|
69
|
+
);
|
|
70
|
+
const deletePersonAction = deletePersonActions.shift();
|
|
71
|
+
if (deletePersonAction !== undefined) {
|
|
72
|
+
// migrateアクションがあれば何もしない
|
|
73
|
+
const migratedUser: boolean = deletePersonAction.object.migrate === true;
|
|
74
|
+
console.log('migratedUser:', migratedUser);
|
|
75
|
+
if (migratedUser) {
|
|
76
|
+
console.log(
|
|
77
|
+
'person migrated', order.project.id, order.orderNumber, order.orderDate,
|
|
78
|
+
person?.memberOf?.membershipNumber, i);
|
|
79
|
+
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(
|
|
85
|
+
'creating task...', order.project.id, order.orderNumber, order.orderDate,
|
|
86
|
+
person?.memberOf?.membershipNumber, i);
|
|
87
|
+
// task作成
|
|
88
|
+
const deleteTransactionTasks: chevre.factory.task.deleteTransaction.IAttributes[] = [
|
|
89
|
+
chevre.factory.transactionType.MoneyTransfer,
|
|
90
|
+
chevre.factory.transactionType.PlaceOrder,
|
|
91
|
+
chevre.factory.transactionType.ReturnOrder
|
|
92
|
+
].map((transactionType) => {
|
|
93
|
+
return {
|
|
94
|
+
project: { id: order.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
95
|
+
name: chevre.factory.taskName.DeleteTransaction,
|
|
96
|
+
status: chevre.factory.taskStatus.Ready,
|
|
97
|
+
runsAt: now,
|
|
98
|
+
remainingNumberOfTries: 3,
|
|
99
|
+
numberOfTried: 0,
|
|
100
|
+
executionResults: [],
|
|
101
|
+
data: {
|
|
102
|
+
object: {
|
|
103
|
+
specifyingMethod: chevre.factory.task.deleteTransaction.SpecifyingMethod.AgentId,
|
|
104
|
+
agent: { id: order.customer.id },
|
|
105
|
+
project: { id: order.project.id },
|
|
106
|
+
typeOf: transactionType
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
// console.log(deleteTransactionTasks);
|
|
112
|
+
await taskRepo.saveMany(deleteTransactionTasks, { emitImmediately: false });
|
|
113
|
+
updateCount += 1;
|
|
114
|
+
console.log(
|
|
115
|
+
'task created.', order.project.id, order.orderNumber, order.orderDate,
|
|
116
|
+
person?.memberOf?.membershipNumber, i);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
console.log(i, 'orders checked');
|
|
121
|
+
console.log(updateCount, 'tasks created');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
main()
|
|
125
|
+
.then()
|
|
126
|
+
.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,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);
|
|
@@ -0,0 +1,32 @@
|
|
|
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.searchProjectIdsByMemberId({
|
|
15
|
+
member: {
|
|
16
|
+
id: memberId
|
|
17
|
+
},
|
|
18
|
+
project: {
|
|
19
|
+
id: {
|
|
20
|
+
// $regex: 'c'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
limit: 3,
|
|
24
|
+
page: 1
|
|
25
|
+
|
|
26
|
+
});
|
|
27
|
+
console.log(ids);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main()
|
|
31
|
+
.then(console.log)
|
|
32
|
+
.catch(console.error);
|
|
@@ -0,0 +1,125 @@
|
|
|
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
|
+
organizer: { $exists: false }
|
|
28
|
+
// startDate: {
|
|
29
|
+
// $gte: moment()
|
|
30
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
31
|
+
// .add(-6, 'months')
|
|
32
|
+
// .toDate()
|
|
33
|
+
// }
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
_id: 1,
|
|
37
|
+
project: 1,
|
|
38
|
+
location: 1,
|
|
39
|
+
superEvent: 1,
|
|
40
|
+
startDate: 1,
|
|
41
|
+
typeOf: 1,
|
|
42
|
+
organizer: 1
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
console.log('events found');
|
|
46
|
+
|
|
47
|
+
let i = 0;
|
|
48
|
+
let updateCount = 0;
|
|
49
|
+
await cursor.eachAsync(async (doc) => {
|
|
50
|
+
i += 1;
|
|
51
|
+
const event: Pick<
|
|
52
|
+
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
|
|
53
|
+
'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer' | 'superEvent'
|
|
54
|
+
> | Pick<
|
|
55
|
+
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEventSeries>,
|
|
56
|
+
'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer'
|
|
57
|
+
> = doc.toObject();
|
|
58
|
+
|
|
59
|
+
const organizerId = event.organizer?.id;
|
|
60
|
+
const alreadyMigrated = typeof organizerId === 'string';
|
|
61
|
+
|
|
62
|
+
if (alreadyMigrated) {
|
|
63
|
+
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
64
|
+
} else {
|
|
65
|
+
let movieTheaterId: string;
|
|
66
|
+
let movieTheaterBranchCode: string;
|
|
67
|
+
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
68
|
+
movieTheaterId = event.location.id;
|
|
69
|
+
movieTheaterBranchCode = event.location.branchCode;
|
|
70
|
+
} else {
|
|
71
|
+
movieTheaterId = event.superEvent.location.id;
|
|
72
|
+
movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
73
|
+
}
|
|
74
|
+
const movieTheaters = <Pick<
|
|
75
|
+
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
76
|
+
'parentOrganization' | 'branchCode'
|
|
77
|
+
>[]>
|
|
78
|
+
await placeRepo.searchMovieTheaters(
|
|
79
|
+
{
|
|
80
|
+
limit: 1,
|
|
81
|
+
page: 1,
|
|
82
|
+
project: { id: { $eq: event.project.id } },
|
|
83
|
+
id: { $eq: movieTheaterId }
|
|
84
|
+
},
|
|
85
|
+
['parentOrganization', 'branchCode'],
|
|
86
|
+
[]
|
|
87
|
+
);
|
|
88
|
+
const movieTheater = movieTheaters.shift();
|
|
89
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
90
|
+
console.log(
|
|
91
|
+
'movieTheater found',
|
|
92
|
+
event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
|
|
93
|
+
'movieTheaterId:', movieTheaterId,
|
|
94
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
95
|
+
i
|
|
96
|
+
);
|
|
97
|
+
// if (typeof sellerId !== 'string') {
|
|
98
|
+
// throw new Error('movieTheater not found');
|
|
99
|
+
// }
|
|
100
|
+
if (typeof sellerId === 'string') {
|
|
101
|
+
const newOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
|
|
102
|
+
id: sellerId
|
|
103
|
+
};
|
|
104
|
+
console.log('updating event...', event.project.id, event.id, event.startDate, i);
|
|
105
|
+
await eventRepo.updatePartiallyById({
|
|
106
|
+
project: { id: event.project.id },
|
|
107
|
+
id: event.id,
|
|
108
|
+
attributes: <any>{
|
|
109
|
+
typeOf: event.typeOf,
|
|
110
|
+
organizer: newOrganizer
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
updateCount += 1;
|
|
114
|
+
console.log('updated.', event.project.id, event.id, event.startDate, i);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
console.log(i, 'events checked');
|
|
120
|
+
console.log(updateCount, 'events updated');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
main()
|
|
124
|
+
.then()
|
|
125
|
+
.catch(console.error);
|
|
@@ -0,0 +1,59 @@
|
|
|
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 memberRepo = new chevre.repository.Member(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = memberRepo.getCursor(
|
|
17
|
+
{},
|
|
18
|
+
{
|
|
19
|
+
// _id: 1,
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
console.log('members found');
|
|
23
|
+
|
|
24
|
+
let i = 0;
|
|
25
|
+
let updateCount = 0;
|
|
26
|
+
await cursor.eachAsync(async (doc) => {
|
|
27
|
+
i += 1;
|
|
28
|
+
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
29
|
+
|
|
30
|
+
const memberOfId = iamMember.member.memberOf?.id;
|
|
31
|
+
const alreadyMigrated = typeof memberOfId === 'string';
|
|
32
|
+
|
|
33
|
+
if (alreadyMigrated) {
|
|
34
|
+
console.log('already exist...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
|
|
35
|
+
} else {
|
|
36
|
+
console.log(
|
|
37
|
+
'updating reservation...', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
|
|
38
|
+
await memberRepo.updateByMemberMemberOf({
|
|
39
|
+
project: { id: iamMember.project.id },
|
|
40
|
+
member: {
|
|
41
|
+
id: iamMember.member.id,
|
|
42
|
+
memberOf: {
|
|
43
|
+
id: iamMember.project.id,
|
|
44
|
+
typeOf: chevre.factory.organizationType.Project
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
updateCount += 1;
|
|
49
|
+
console.log('updated.', iamMember.project.id, iamMember.member.id, iamMember.member.typeOf, memberOfId, i);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
console.log(i, 'members checked');
|
|
54
|
+
console.log(updateCount, 'members updated');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
main()
|
|
58
|
+
.then()
|
|
59
|
+
.catch(console.error);
|
|
@@ -0,0 +1,119 @@
|
|
|
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: false });
|
|
13
|
+
|
|
14
|
+
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
15
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
16
|
+
|
|
17
|
+
const cursor = reservationRepo.getCursor(
|
|
18
|
+
{
|
|
19
|
+
typeOf: {
|
|
20
|
+
$in: [
|
|
21
|
+
chevre.factory.reservationType.EventReservation
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
// bookingTime: {
|
|
25
|
+
// $gte: moment('2022-07-01T00:00:00Z')
|
|
26
|
+
// .toDate(),
|
|
27
|
+
// $lte: moment('2022-03-01T00:00:00Z')
|
|
28
|
+
// .toDate()
|
|
29
|
+
// },
|
|
30
|
+
'provider.id': { $exists: false }
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
_id: 1,
|
|
34
|
+
project: 1,
|
|
35
|
+
provider: 1,
|
|
36
|
+
bookingTime: 1,
|
|
37
|
+
reservationFor: 1
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
console.log('reservations found');
|
|
41
|
+
|
|
42
|
+
let i = 0;
|
|
43
|
+
let updateCount = 0;
|
|
44
|
+
await cursor.eachAsync(async (doc) => {
|
|
45
|
+
i += 1;
|
|
46
|
+
const reservation: Pick<
|
|
47
|
+
chevre.factory.reservation.IReservation<chevre.factory.reservationType.EventReservation>,
|
|
48
|
+
'id' | 'project' | 'provider' | 'bookingTime' | 'reservationFor'
|
|
49
|
+
> = doc.toObject();
|
|
50
|
+
|
|
51
|
+
const providerId = reservation.provider?.id;
|
|
52
|
+
const alreadyMigrated = typeof providerId === 'string';
|
|
53
|
+
|
|
54
|
+
if (alreadyMigrated) {
|
|
55
|
+
console.log('already exist...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
|
|
56
|
+
} else {
|
|
57
|
+
const movieTheaterId: string = reservation.reservationFor.superEvent.location.id;
|
|
58
|
+
const movieTheaterBranchCode: string = reservation.reservationFor.superEvent.location.branchCode;
|
|
59
|
+
const movieTheaters = <Pick<
|
|
60
|
+
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
61
|
+
'parentOrganization' | 'branchCode'
|
|
62
|
+
>[]>
|
|
63
|
+
await placeRepo.searchMovieTheaters(
|
|
64
|
+
{
|
|
65
|
+
limit: 1,
|
|
66
|
+
page: 1,
|
|
67
|
+
project: { id: { $eq: reservation.project.id } },
|
|
68
|
+
id: { $eq: movieTheaterId }
|
|
69
|
+
},
|
|
70
|
+
['parentOrganization', 'branchCode'],
|
|
71
|
+
[]
|
|
72
|
+
);
|
|
73
|
+
const movieTheater = movieTheaters.shift();
|
|
74
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
75
|
+
console.log(
|
|
76
|
+
'movieTheater found',
|
|
77
|
+
reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
|
|
78
|
+
'movieTheaterId:', movieTheaterId,
|
|
79
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
80
|
+
i
|
|
81
|
+
);
|
|
82
|
+
if (typeof sellerId !== 'string') {
|
|
83
|
+
console.error(
|
|
84
|
+
'movieTheater not found',
|
|
85
|
+
reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
|
|
86
|
+
'movieTheaterId:', movieTheaterId,
|
|
87
|
+
'movieTheaterBranchCode:', movieTheaterBranchCode,
|
|
88
|
+
i
|
|
89
|
+
);
|
|
90
|
+
throw new Error('movieTheater not found');
|
|
91
|
+
|
|
92
|
+
// return;
|
|
93
|
+
}
|
|
94
|
+
if (typeof sellerId === 'string') {
|
|
95
|
+
const newProvider: chevre.factory.reservation.IProvider = {
|
|
96
|
+
id: sellerId,
|
|
97
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
98
|
+
};
|
|
99
|
+
console.log(
|
|
100
|
+
'updating reservation...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
|
|
101
|
+
await reservationRepo.updatePartiallyById({
|
|
102
|
+
id: reservation.id,
|
|
103
|
+
update: <any>{
|
|
104
|
+
provider: newProvider
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
updateCount += 1;
|
|
108
|
+
console.log('updated.', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
console.log(i, 'reservations checked');
|
|
114
|
+
console.log(updateCount, 'reservations updated');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
main()
|
|
118
|
+
.then()
|
|
119
|
+
.catch(console.error);
|
|
@@ -0,0 +1,91 @@
|
|
|
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 placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = placeRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
typeOf: {
|
|
21
|
+
$in: [
|
|
22
|
+
chevre.factory.placeType.ScreeningRoom
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
// organizer: { $exists: false }
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
containsPlace: 0
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
console.log('places found');
|
|
32
|
+
|
|
33
|
+
let i = 0;
|
|
34
|
+
let updateCount = 0;
|
|
35
|
+
await cursor.eachAsync(async (doc) => {
|
|
36
|
+
i += 1;
|
|
37
|
+
const screeningRoom: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
|
|
38
|
+
console.log(screeningRoom);
|
|
39
|
+
|
|
40
|
+
const organizerId = screeningRoom.parentOrganization?.id;
|
|
41
|
+
const alreadyMigrated = typeof organizerId === 'string';
|
|
42
|
+
|
|
43
|
+
if (alreadyMigrated) {
|
|
44
|
+
console.log('already exist...', screeningRoom.project.id, screeningRoom.branchCode, organizerId, i);
|
|
45
|
+
} else {
|
|
46
|
+
const movieTheaterId = screeningRoom.containedInPlace?.id;
|
|
47
|
+
if (typeof movieTheaterId !== 'string') {
|
|
48
|
+
throw new Error('containedInPlace?.id undefined');
|
|
49
|
+
}
|
|
50
|
+
const movieTheaters = <Pick<chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom, 'parentOrganization'>[]>
|
|
51
|
+
await placeRepo.searchMovieTheaters(
|
|
52
|
+
{
|
|
53
|
+
limit: 1,
|
|
54
|
+
page: 1,
|
|
55
|
+
project: { id: { $eq: screeningRoom.project.id } },
|
|
56
|
+
id: { $eq: movieTheaterId }
|
|
57
|
+
},
|
|
58
|
+
['parentOrganization'],
|
|
59
|
+
[]
|
|
60
|
+
);
|
|
61
|
+
const movieTheater = movieTheaters.shift();
|
|
62
|
+
const sellerId = movieTheater?.parentOrganization?.id;
|
|
63
|
+
console.log('movieTheater found', screeningRoom.project.id, screeningRoom.branchCode, 'sellerId:', sellerId, i);
|
|
64
|
+
// if (typeof sellerId !== 'string') {
|
|
65
|
+
// throw new Error('movieTheater not found');
|
|
66
|
+
// }
|
|
67
|
+
if (typeof sellerId === 'string') {
|
|
68
|
+
const newParentOrganization: chevre.factory.place.screeningRoom.IParentOrganization = {
|
|
69
|
+
id: sellerId,
|
|
70
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
71
|
+
};
|
|
72
|
+
console.log('updating room...', screeningRoom.project.id, screeningRoom.branchCode, i);
|
|
73
|
+
await placeRepo.addParentOrganization2ScreeningRoom({
|
|
74
|
+
project: screeningRoom.project,
|
|
75
|
+
branchCode: screeningRoom.branchCode,
|
|
76
|
+
containedInPlace: { branchCode: String(screeningRoom.containedInPlace?.branchCode) },
|
|
77
|
+
parentOrganization: newParentOrganization
|
|
78
|
+
});
|
|
79
|
+
updateCount += 1;
|
|
80
|
+
console.log('updated.', screeningRoom.project.id, screeningRoom.branchCode, i);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
console.log(i, 'rooms checked');
|
|
86
|
+
console.log(updateCount, 'rooms updated');
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main()
|
|
90
|
+
.then()
|
|
91
|
+
.catch(console.error);
|