@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
|
@@ -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);
|
|
@@ -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, { autoIndex: true });
|
|
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);
|
|
@@ -8,7 +8,7 @@ import { chevre } from '../../../lib/index';
|
|
|
8
8
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
9
|
|
|
10
10
|
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
12
|
|
|
13
13
|
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
14
14
|
const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
@@ -21,10 +21,11 @@ async function main() {
|
|
|
21
21
|
id: project.id,
|
|
22
22
|
typeOf: chevre.factory.organizationType.Project
|
|
23
23
|
},
|
|
24
|
-
locationBranchCode: '
|
|
25
|
-
importFrom: moment(
|
|
24
|
+
locationBranchCode: '022',
|
|
25
|
+
importFrom: moment()
|
|
26
26
|
.toDate(),
|
|
27
|
-
importThrough: moment(
|
|
27
|
+
importThrough: moment()
|
|
28
|
+
.add(1, 'day')
|
|
28
29
|
.toDate(),
|
|
29
30
|
saveMovieTheater: false,
|
|
30
31
|
saveScreeningEventSeries: false
|
|
@@ -9,7 +9,7 @@ import { chevre } from '../../../lib/index';
|
|
|
9
9
|
|
|
10
10
|
// tslint:disable-next-line:max-func-body-length
|
|
11
11
|
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
14
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
15
|
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
@@ -23,7 +23,8 @@ async function main() {
|
|
|
23
23
|
chevre.factory.eventType.ScreeningEvent,
|
|
24
24
|
chevre.factory.eventType.ScreeningEventSeries
|
|
25
25
|
]
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
organizer: { $exists: false }
|
|
27
28
|
// startDate: {
|
|
28
29
|
// $gte: moment()
|
|
29
30
|
// // tslint:disable-next-line:no-magic-numbers
|
|
@@ -62,12 +63,18 @@ async function main() {
|
|
|
62
63
|
console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
|
|
63
64
|
} else {
|
|
64
65
|
let movieTheaterId: string;
|
|
66
|
+
let movieTheaterBranchCode: string;
|
|
65
67
|
if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
|
|
66
68
|
movieTheaterId = event.location.id;
|
|
69
|
+
movieTheaterBranchCode = event.location.branchCode;
|
|
67
70
|
} else {
|
|
68
71
|
movieTheaterId = event.superEvent.location.id;
|
|
72
|
+
movieTheaterBranchCode = event.superEvent.location.branchCode;
|
|
69
73
|
}
|
|
70
|
-
const movieTheaters = <Pick<
|
|
74
|
+
const movieTheaters = <Pick<
|
|
75
|
+
chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
|
|
76
|
+
'parentOrganization' | 'branchCode'
|
|
77
|
+
>[]>
|
|
71
78
|
await placeRepo.searchMovieTheaters(
|
|
72
79
|
{
|
|
73
80
|
limit: 1,
|
|
@@ -75,12 +82,18 @@ async function main() {
|
|
|
75
82
|
project: { id: { $eq: event.project.id } },
|
|
76
83
|
id: { $eq: movieTheaterId }
|
|
77
84
|
},
|
|
78
|
-
['parentOrganization'],
|
|
85
|
+
['parentOrganization', 'branchCode'],
|
|
79
86
|
[]
|
|
80
87
|
);
|
|
81
88
|
const movieTheater = movieTheaters.shift();
|
|
82
89
|
const sellerId = movieTheater?.parentOrganization?.id;
|
|
83
|
-
console.log(
|
|
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
|
+
);
|
|
84
97
|
// if (typeof sellerId !== 'string') {
|
|
85
98
|
// throw new Error('movieTheater not found');
|
|
86
99
|
// }
|
|
@@ -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: false });
|
|
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: false });
|
|
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);
|
|
@@ -6,7 +6,7 @@ import * as mongoose from 'mongoose';
|
|
|
6
6
|
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex:
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
11
|
const actionRepo = new chevre.repository.Action(mongoose.connection);
|
|
12
12
|
const actions = await actionRepo.search(
|
|
@@ -15,24 +15,16 @@ async function main() {
|
|
|
15
15
|
|
|
16
16
|
let now: Date;
|
|
17
17
|
|
|
18
|
-
// let now = new Date();
|
|
19
|
-
// const aggregateRoleNamesResult = await memberRepo.aggregateRoleNames({
|
|
20
|
-
// project: { id: { $eq: PROJECT_ID } },
|
|
21
|
-
// member: { id: { $eq: memberId } }
|
|
22
|
-
// });
|
|
23
|
-
|
|
24
|
-
// const aggregatePermissionsResult = await roleRepo.aggregatePermissions({
|
|
25
|
-
// roleName: {
|
|
26
|
-
// $in: aggregateRoleNamesResult.map((r) => r.roleName)
|
|
27
|
-
// }
|
|
28
|
-
// });
|
|
29
|
-
// console.log('time cost:', moment()
|
|
30
|
-
// .diff(now));
|
|
31
|
-
|
|
32
18
|
now = new Date();
|
|
33
19
|
const searchPermissionsResult = await chevre.service.iam.searchPermissions({
|
|
34
20
|
project: { id: PROJECT_ID },
|
|
35
|
-
member: {
|
|
21
|
+
member: {
|
|
22
|
+
id: memberId,
|
|
23
|
+
memberOf: {
|
|
24
|
+
id: PROJECT_ID,
|
|
25
|
+
typeOf: chevre.factory.organizationType.Project
|
|
26
|
+
}
|
|
27
|
+
}
|
|
36
28
|
})({
|
|
37
29
|
member: memberRepo,
|
|
38
30
|
role: roleRepo
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
|
-
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
2
|
+
export type IMinimizedIndividualEvent<T extends factory.eventType.ScreeningEvent | factory.eventType.Event> = T extends factory.eventType.ScreeningEvent ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier'> : T extends factory.eventType.Event ? Pick<factory.event.IEvent<T>, 'project' | 'organizer' | 'id' | 'typeOf' | 'additionalProperty' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'offers'> : never;
|
|
@@ -67,7 +67,10 @@ export declare class MongoRepository {
|
|
|
67
67
|
addReservations(params: {
|
|
68
68
|
typeOf: factory.assetTransactionType.Reserve;
|
|
69
69
|
id: string;
|
|
70
|
-
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'issuedThrough' | 'reservationFor' | 'subReservation'
|
|
70
|
+
object: Pick<factory.assetTransaction.reserve.IObject, 'acceptedOffer' | 'issuedThrough' | 'reservationFor' | 'subReservation'> & {
|
|
71
|
+
issuedThrough: factory.assetTransaction.reserve.IIssuedThrough;
|
|
72
|
+
reservationFor: factory.assetTransaction.reserve.IReservationFor;
|
|
73
|
+
};
|
|
71
74
|
}): Promise<factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>>;
|
|
72
75
|
/**
|
|
73
76
|
* 取引を確定する
|