@chevre/domain 21.4.0-alpha.2 → 21.4.0-alpha.21

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.
Files changed (86) hide show
  1. package/example/src/chevre/cleanActions.ts +23 -0
  2. package/example/src/chevre/cleanEventsByMovieTheater.ts +32 -0
  3. package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +126 -0
  4. package/example/src/chevre/createManyEventsIfNotExist.ts +6 -0
  5. package/example/src/chevre/migrateEventOrganizer.ts +125 -0
  6. package/example/src/chevre/migrateReservationProvider.ts +117 -0
  7. package/example/src/chevre/migrateScreeningRoomOrganizer.ts +91 -0
  8. package/example/src/chevre/processReserve.ts +0 -1
  9. package/example/src/chevre/searchEvents.ts +1 -9
  10. package/example/src/chevre/searchProductOffers.ts +6 -0
  11. package/lib/chevre/factory/event.d.ts +1 -1
  12. package/lib/chevre/repo/action.d.ts +6 -0
  13. package/lib/chevre/repo/action.js +13 -0
  14. package/lib/chevre/repo/assetTransaction.d.ts +4 -1
  15. package/lib/chevre/repo/assetTransaction.js +6 -12
  16. package/lib/chevre/repo/event.d.ts +25 -4
  17. package/lib/chevre/repo/event.js +122 -60
  18. package/lib/chevre/repo/mongoose/schemas/event.d.ts +7 -4
  19. package/lib/chevre/repo/mongoose/schemas/event.js +15 -2
  20. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -6
  21. package/lib/chevre/repo/mongoose/schemas/place.js +9 -2
  22. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  23. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +3 -0
  24. package/lib/chevre/repo/mongoose/schemas/reservation.js +6 -3
  25. package/lib/chevre/repo/order.d.ts +21 -0
  26. package/lib/chevre/repo/order.js +54 -62
  27. package/lib/chevre/repo/place.d.ts +57 -16
  28. package/lib/chevre/repo/place.js +112 -167
  29. package/lib/chevre/repo/product.d.ts +2 -4
  30. package/lib/chevre/repo/product.js +52 -7
  31. package/lib/chevre/repo/productOffer.d.ts +19 -4
  32. package/lib/chevre/repo/productOffer.js +37 -14
  33. package/lib/chevre/repo/reservation.d.ts +33 -21
  34. package/lib/chevre/repo/reservation.js +97 -79
  35. package/lib/chevre/repo/seller.d.ts +4 -3
  36. package/lib/chevre/repo/seller.js +40 -38
  37. package/lib/chevre/repo/task.d.ts +1 -1
  38. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -2
  39. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +3 -2
  40. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +1 -1
  41. package/lib/chevre/service/assetTransaction/pay/account/validation.js +9 -1
  42. package/lib/chevre/service/assetTransaction/pay.js +9 -1
  43. package/lib/chevre/service/assetTransaction/registerService.js +2 -2
  44. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +10 -4
  45. package/lib/chevre/service/assetTransaction/reserve/factory.js +21 -40
  46. package/lib/chevre/service/assetTransaction/reserve.d.ts +0 -1
  47. package/lib/chevre/service/assetTransaction/reserve.js +7 -22
  48. package/lib/chevre/service/event/createEvent.d.ts +9 -0
  49. package/lib/chevre/service/event/createEvent.js +86 -0
  50. package/lib/chevre/service/event.d.ts +2 -0
  51. package/lib/chevre/service/event.js +26 -26
  52. package/lib/chevre/service/moneyTransfer.js +1 -1
  53. package/lib/chevre/service/offer/event/authorize.d.ts +0 -1
  54. package/lib/chevre/service/offer/event/authorize.js +6 -2
  55. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +16 -2
  56. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +1 -1
  57. package/lib/chevre/service/offer/product/searchProductOffers.js +1 -1
  58. package/lib/chevre/service/order/returnOrder.js +8 -1
  59. package/lib/chevre/service/order/sendOrder.js +8 -1
  60. package/lib/chevre/service/payment/creditCard.js +9 -1
  61. package/lib/chevre/service/payment/movieTicket/factory.d.ts +2 -1
  62. package/lib/chevre/service/payment/movieTicket/validation.js +9 -1
  63. package/lib/chevre/service/payment/movieTicket.js +19 -2
  64. package/lib/chevre/service/payment/paymentCard.js +1 -3
  65. package/lib/chevre/service/reserve/cancelReservation.js +15 -28
  66. package/lib/chevre/service/reserve/confirmReservation.js +12 -30
  67. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +3 -0
  68. package/lib/chevre/service/reserve/verifyToken4reservation.js +3 -1
  69. package/lib/chevre/service/task/{syncScreeningRooms.d.ts → createEvent.d.ts} +1 -1
  70. package/lib/chevre/service/task/{syncScreeningRooms.js → createEvent.js} +10 -4
  71. package/lib/chevre/service/task/onAuthorizationCreated.js +1 -0
  72. package/lib/chevre/service/task/returnPayTransaction.js +1 -0
  73. package/lib/chevre/service/transaction/moneyTransfer.js +9 -1
  74. package/lib/chevre/service/transaction/orderProgramMembership/findCreditCard.js +1 -1
  75. package/lib/chevre/service/transaction/placeOrderInProgress.js +9 -6
  76. package/lib/chevre/service/transaction/returnOrder.js +9 -3
  77. package/package.json +3 -3
  78. package/example/src/chevre/findByOrderNumberAndReservationId.ts +0 -20
  79. package/example/src/chevre/findScreeningRoomsByBranchCode.ts +0 -27
  80. package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +0 -90
  81. package/example/src/chevre/migrateEventOffersItemOfferedTypeOf.ts +0 -75
  82. package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +0 -64
  83. package/example/src/chevre/migrateScreeningEventSeriesVersion.ts +0 -79
  84. package/example/src/chevre/searchScreeningRooms.ts +0 -33
  85. package/example/src/chevre/syncScreeningRooms.ts +0 -21
  86. 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,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,117 @@
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 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('2023-06-09T00:00:00Z')
26
+ // .toDate()
27
+ // }
28
+ 'provider.id': { $exists: false }
29
+ },
30
+ {
31
+ _id: 1,
32
+ project: 1,
33
+ provider: 1,
34
+ bookingTime: 1,
35
+ reservationFor: 1
36
+ }
37
+ );
38
+ console.log('reservations found');
39
+
40
+ let i = 0;
41
+ let updateCount = 0;
42
+ await cursor.eachAsync(async (doc) => {
43
+ i += 1;
44
+ const reservation: Pick<
45
+ chevre.factory.reservation.IReservation<chevre.factory.reservationType.EventReservation>,
46
+ 'id' | 'project' | 'provider' | 'bookingTime' | 'reservationFor'
47
+ > = doc.toObject();
48
+
49
+ const providerId = reservation.provider?.id;
50
+ const alreadyMigrated = typeof providerId === 'string';
51
+
52
+ if (alreadyMigrated) {
53
+ console.log('already exist...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i);
54
+ } else {
55
+ const movieTheaterId: string = reservation.reservationFor.superEvent.location.id;
56
+ const movieTheaterBranchCode: string = reservation.reservationFor.superEvent.location.branchCode;
57
+ const movieTheaters = <Pick<
58
+ chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
59
+ 'parentOrganization' | 'branchCode'
60
+ >[]>
61
+ await placeRepo.searchMovieTheaters(
62
+ {
63
+ limit: 1,
64
+ page: 1,
65
+ project: { id: { $eq: reservation.project.id } },
66
+ id: { $eq: movieTheaterId }
67
+ },
68
+ ['parentOrganization', 'branchCode'],
69
+ []
70
+ );
71
+ const movieTheater = movieTheaters.shift();
72
+ const sellerId = movieTheater?.parentOrganization?.id;
73
+ console.log(
74
+ 'movieTheater found',
75
+ reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
76
+ 'movieTheaterId:', movieTheaterId,
77
+ 'movieTheaterBranchCode:', movieTheaterBranchCode,
78
+ i
79
+ );
80
+ if (typeof sellerId !== 'string') {
81
+ console.error(
82
+ 'movieTheater not found',
83
+ reservation.project.id, reservation.id, reservation.bookingTime, providerId, 'sellerId:', sellerId,
84
+ 'movieTheaterId:', movieTheaterId,
85
+ 'movieTheaterBranchCode:', movieTheaterBranchCode,
86
+ i
87
+ );
88
+ // throw new Error('movieTheater not found');
89
+
90
+ return;
91
+ }
92
+ if (typeof sellerId === 'string') {
93
+ const newProvider: chevre.factory.reservation.IProvider = {
94
+ id: sellerId,
95
+ typeOf: chevre.factory.organizationType.Corporation
96
+ };
97
+ console.log(
98
+ 'updating reservation...', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
99
+ await reservationRepo.updatePartiallyById({
100
+ id: reservation.id,
101
+ update: <any>{
102
+ provider: newProvider
103
+ }
104
+ });
105
+ updateCount += 1;
106
+ console.log('updated.', reservation.project.id, reservation.id, reservation.bookingTime, providerId, i, updateCount);
107
+ }
108
+ }
109
+ });
110
+
111
+ console.log(i, 'reservations checked');
112
+ console.log(updateCount, 'reservations updated');
113
+ }
114
+
115
+ main()
116
+ .then()
117
+ .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);
@@ -69,7 +69,6 @@ async function main() {
69
69
  validateEvent: false,
70
70
  validateEventOfferPeriod: false,
71
71
  validateAppliesToMovieTicket: true,
72
- disablePendingReservations: true,
73
72
  stockHoldUntilDaysAfterEventEnd: 31,
74
73
  useHoldStockByTransactionNumber: true
75
74
  })({
@@ -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: { $in: ['al6aff83y'] }
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()
@@ -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;
@@ -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
  */
@@ -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
  * 取引を確定する