@chevre/domain 21.7.0-alpha.0 → 21.7.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +83 -0
  2. package/example/src/chevre/searchOffers.ts +20 -20
  3. package/example/src/chevre/unsetUnnecessaryFields.ts +17 -11
  4. package/lib/chevre/emailMessageBuilder.d.ts +1 -1
  5. package/lib/chevre/repo/action.d.ts +4 -0
  6. package/lib/chevre/repo/action.js +6 -0
  7. package/lib/chevre/repo/event.d.ts +12 -0
  8. package/lib/chevre/repo/event.js +11 -0
  9. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +4 -4
  10. package/lib/chevre/repo/mongoose/schemas/offer.js +6 -6
  11. package/lib/chevre/repo/offer.js +11 -7
  12. package/lib/chevre/repo/product.d.ts +1 -1
  13. package/lib/chevre/repo/product.js +1 -0
  14. package/lib/chevre/repo/transaction.d.ts +4 -1
  15. package/lib/chevre/repo/transaction.js +7 -1
  16. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  17. package/lib/chevre/service/assetTransaction/pay/factory.js +49 -27
  18. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +39 -18
  19. package/lib/chevre/service/assetTransaction/refund/factory.js +2 -2
  20. package/lib/chevre/service/order/deleteOrder.d.ts +2 -0
  21. package/lib/chevre/service/order/deleteOrder.js +42 -0
  22. package/lib/chevre/service/payment/any/factory.js +18 -7
  23. package/lib/chevre/service/payment/creditCard.js +3 -1
  24. package/lib/chevre/service/payment/paymentCard.js +6 -2
  25. package/lib/chevre/service/task/deleteTransaction.js +2 -0
  26. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  27. package/lib/chevre/service/transaction/moneyTransfer/factory.js +1 -5
  28. package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
  29. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +0 -4
  30. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +11 -9
  31. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +6 -4
  32. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +6 -20
  33. package/lib/chevre/service/transaction/placeOrderInProgress.js +0 -3
  34. package/lib/chevre/service/transaction/returnOrder.js +0 -1
  35. package/lib/chevre/settings.d.ts +2 -0
  36. package/lib/chevre/settings.js +3 -1
  37. package/package.json +3 -3
  38. package/example/src/chevre/migrateReservationProvider.ts +0 -119
@@ -1,119 +0,0 @@
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);