@chevre/domain 21.8.0-alpha.6 → 21.8.0-alpha.60

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 (129) hide show
  1. package/example/src/chevre/countOffers.ts +32 -0
  2. package/example/src/chevre/findItemListElementByCatalogId.ts +23 -0
  3. package/example/src/chevre/importOffersFromCOA.ts +7 -1
  4. package/example/src/chevre/migrateAggregateOffers.ts +89 -0
  5. package/example/src/chevre/migrateOrderPaymentMethodIdentifier.ts +81 -0
  6. package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
  7. package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +78 -0
  8. package/example/src/chevre/processPay.ts +3 -4
  9. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +56 -0
  10. package/example/src/chevre/pullAddOnsFromOffer.ts +26 -0
  11. package/example/src/chevre/searchAggregateOffers.ts +48 -0
  12. package/example/src/chevre/searchEventTicketOffers.ts +3 -1
  13. package/example/src/chevre/searchEvents.ts +9 -7
  14. package/example/src/chevre/searchOffersByCatalog.ts +9 -5
  15. package/example/src/chevre/searchOffersFromAggregateOffer.ts +168 -0
  16. package/example/src/chevre/searchOrders.ts +9 -7
  17. package/example/src/chevre/sync2aggregateOffer.ts +27 -0
  18. package/example/src/chevre/syncAggregateOffer.ts +25 -0
  19. package/lib/chevre/emailMessageBuilder.js +6 -5
  20. package/lib/chevre/repo/aggregateOffer.d.ts +62 -0
  21. package/lib/chevre/repo/aggregateOffer.js +534 -0
  22. package/lib/chevre/repo/assetTransaction.d.ts +16 -1
  23. package/lib/chevre/repo/assetTransaction.js +54 -2
  24. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.d.ts +74 -0
  25. package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +177 -0
  26. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +3 -3
  27. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +3 -3
  28. package/lib/chevre/repo/mongoose/schemas/event.d.ts +3 -3
  29. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +24 -33
  30. package/lib/chevre/repo/mongoose/schemas/offer.js +4 -3
  31. package/lib/chevre/repo/mongoose/schemas/order.d.ts +3 -0
  32. package/lib/chevre/repo/mongoose/schemas/order.js +7 -0
  33. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +9 -9
  34. package/lib/chevre/repo/mongoose/schemas/product.d.ts +3 -3
  35. package/lib/chevre/repo/mongoose/schemas/project.d.ts +3 -3
  36. package/lib/chevre/repo/mongoose/schemas/task.d.ts +3 -0
  37. package/lib/chevre/repo/mongoose/schemas/task.js +8 -0
  38. package/lib/chevre/repo/offer.d.ts +82 -47
  39. package/lib/chevre/repo/offer.js +1279 -289
  40. package/lib/chevre/repo/offerCatalog.d.ts +6 -0
  41. package/lib/chevre/repo/offerCatalog.js +13 -0
  42. package/lib/chevre/repo/order.d.ts +15 -0
  43. package/lib/chevre/repo/order.js +58 -26
  44. package/lib/chevre/repo/task.d.ts +7 -1
  45. package/lib/chevre/repo/task.js +100 -0
  46. package/lib/chevre/repository.d.ts +3 -0
  47. package/lib/chevre/repository.js +5 -1
  48. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +2 -1
  49. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +2 -1
  50. package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
  51. package/lib/chevre/service/assetTransaction/pay/factory.js +26 -18
  52. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
  53. package/lib/chevre/service/assetTransaction/pay.js +65 -46
  54. package/lib/chevre/service/assetTransaction/refund/factory.js +8 -2
  55. package/lib/chevre/service/assetTransaction/registerService.js +2 -1
  56. package/lib/chevre/service/assetTransaction/reserve.js +111 -35
  57. package/lib/chevre/service/delivery.js +17 -0
  58. package/lib/chevre/service/offer/event/authorize.js +39 -35
  59. package/lib/chevre/service/offer/event/factory.d.ts +1 -1
  60. package/lib/chevre/service/offer/event/factory.js +8 -8
  61. package/lib/chevre/service/offer/event/importFromCOA.d.ts +2 -0
  62. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -0
  63. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +6 -3
  64. package/lib/chevre/service/offer/event/voidTransaction.js +57 -36
  65. package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
  66. package/lib/chevre/service/offer/eventServiceByCOA/factory.js +7 -11
  67. package/lib/chevre/service/offer/eventServiceByCOA.js +55 -27
  68. package/lib/chevre/service/offer/factory.d.ts +12 -4
  69. package/lib/chevre/service/offer/factory.js +9 -11
  70. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +8 -1
  71. package/lib/chevre/service/offer/product/searchProductOffers.js +10 -3
  72. package/lib/chevre/service/offer/product.d.ts +1 -0
  73. package/lib/chevre/service/offer/product.js +3 -2
  74. package/lib/chevre/service/offer.d.ts +1 -0
  75. package/lib/chevre/service/offer.js +7 -1
  76. package/lib/chevre/service/order/confirmPayTransaction.d.ts +0 -2
  77. package/lib/chevre/service/order/confirmPayTransaction.js +29 -40
  78. package/lib/chevre/service/order/onAssetTransactionStatusChanged.d.ts +27 -0
  79. package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +226 -0
  80. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +8 -6
  81. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +80 -57
  82. package/lib/chevre/service/order/onOrderStatusChanged.js +81 -54
  83. package/lib/chevre/service/order/payOrder.d.ts +2 -10
  84. package/lib/chevre/service/order/payOrder.js +4 -45
  85. package/lib/chevre/service/order/placeOrder.js +11 -13
  86. package/lib/chevre/service/order.d.ts +3 -1
  87. package/lib/chevre/service/order.js +6 -2
  88. package/lib/chevre/service/payment/any/factory.js +33 -8
  89. package/lib/chevre/service/payment/any.js +30 -21
  90. package/lib/chevre/service/payment/creditCard.js +12 -12
  91. package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
  92. package/lib/chevre/service/payment/movieTicket.js +10 -11
  93. package/lib/chevre/service/payment/paymentCard.js +9 -12
  94. package/lib/chevre/service/project.js +1 -1
  95. package/lib/chevre/service/reserve/checkInReservation.d.ts +8 -0
  96. package/lib/chevre/service/reserve/checkInReservation.js +3 -2
  97. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +3 -0
  98. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +4 -5
  99. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.d.ts +8 -0
  100. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +16 -11
  101. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -1
  102. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +3 -0
  103. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +3 -5
  104. package/lib/chevre/service/task/confirmPayTransaction.js +1 -3
  105. package/lib/chevre/service/task/importOffersFromCOA.js +3 -0
  106. package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +6 -0
  107. package/lib/chevre/service/task/onAssetTransactionStatusChanged.js +37 -0
  108. package/lib/chevre/service/task/onAuthorizationCreated.js +5 -1
  109. package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +6 -0
  110. package/lib/chevre/service/task/onOrderPaymentCompleted.js +35 -0
  111. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  112. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -0
  113. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +17 -0
  114. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +60 -0
  115. package/lib/chevre/service/task/onResourceUpdated.js +12 -0
  116. package/lib/chevre/service/task/returnPayTransaction.js +8 -3
  117. package/lib/chevre/service/task/syncAggregateOffer.d.ts +7 -0
  118. package/lib/chevre/service/task/syncAggregateOffer.js +23 -0
  119. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +32 -16
  120. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +13 -11
  121. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +53 -17
  122. package/lib/chevre/service/transaction/placeOrderInProgress.js +4 -1
  123. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +7 -6
  124. package/lib/chevre/service/transaction/returnOrder.js +5 -1
  125. package/lib/chevre/settings.d.ts +5 -3
  126. package/lib/chevre/settings.js +6 -6
  127. package/package.json +3 -3
  128. package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +0 -83
  129. package/example/src/chevre/migrateEventOrganizer.ts +0 -154
@@ -1,154 +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 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: true },
28
- startDate: {
29
- $gte: moment()
30
- // tslint:disable-next-line:no-magic-numbers
31
- .add(-3, '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
- let invalidOrganizerCount = 0;
50
- await cursor.eachAsync(async (doc) => {
51
- i += 1;
52
- const event: Pick<
53
- chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
54
- 'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer' | 'superEvent'
55
- > | Pick<
56
- chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEventSeries>,
57
- 'id' | 'project' | 'location' | 'startDate' | 'typeOf' | 'organizer'
58
- > = doc.toObject();
59
-
60
- const organizerId = event.organizer?.id;
61
-
62
- let movieTheaterId: string;
63
- let movieTheaterBranchCode: string;
64
- if (event.typeOf === chevre.factory.eventType.ScreeningEventSeries) {
65
- movieTheaterId = event.location.id;
66
- movieTheaterBranchCode = event.location.branchCode;
67
- } else {
68
- movieTheaterId = event.superEvent.location.id;
69
- movieTheaterBranchCode = event.superEvent.location.branchCode;
70
- }
71
- const movieTheaters = <Pick<
72
- chevre.factory.place.movieTheater.IPlaceWithoutScreeningRoom,
73
- 'parentOrganization' | 'branchCode'
74
- >[]>
75
- await placeRepo.searchMovieTheaters(
76
- {
77
- limit: 1,
78
- page: 1,
79
- project: { id: { $eq: event.project.id } },
80
- id: { $eq: movieTheaterId }
81
- },
82
- ['parentOrganization', 'branchCode'],
83
- []
84
- );
85
- const movieTheater = movieTheaters.shift();
86
- const sellerId = movieTheater?.parentOrganization?.id;
87
- console.log(
88
- 'movieTheater found',
89
- event.project.id, event.id, event.startDate, 'sellerId:', sellerId,
90
- 'movieTheaterId:', movieTheaterId,
91
- 'movieTheaterBranchCode:', movieTheaterBranchCode,
92
- i
93
- );
94
-
95
- const alreadyMigrated = typeof organizerId === 'string';
96
-
97
- if (alreadyMigrated) {
98
- console.log('already exist...', event.project.id, event.id, event.startDate, organizerId, i);
99
- if (organizerId === sellerId) {
100
- console.log('organizerId is valid', event.project.id, event.id, event.startDate, organizerId, i);
101
- } else {
102
- invalidOrganizerCount += 1;
103
-
104
- // organizerを修正する
105
- if (typeof sellerId !== 'string') {
106
- throw new Error('movieTheater not found');
107
- }
108
- const fixedOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
109
- id: sellerId
110
- };
111
- console.log('updating event...', event.project.id, event.id, event.startDate, i);
112
- await eventRepo.updatePartiallyById({
113
- project: { id: event.project.id },
114
- id: event.id,
115
- attributes: <any>{
116
- typeOf: event.typeOf,
117
- organizer: fixedOrganizer
118
- }
119
- });
120
- updateCount += 1;
121
- console.log('updated.', event.project.id, event.id, event.startDate, i);
122
- }
123
- } else {
124
- throw new Error('organizer not found');
125
- // if (typeof sellerId !== 'string') {
126
- // throw new Error('movieTheater not found');
127
- // }
128
- // if (typeof sellerId === 'string') {
129
- // const newOrganizer: chevre.factory.event.screeningEventSeries.IOrganizer = {
130
- // id: sellerId
131
- // };
132
- // console.log('updating event...', event.project.id, event.id, event.startDate, i);
133
- // await eventRepo.updatePartiallyById({
134
- // project: { id: event.project.id },
135
- // id: event.id,
136
- // attributes: <any>{
137
- // typeOf: event.typeOf,
138
- // organizer: newOrganizer
139
- // }
140
- // });
141
- // updateCount += 1;
142
- // console.log('updated.', event.project.id, event.id, event.startDate, i);
143
- // }
144
- }
145
- });
146
-
147
- console.log(i, 'events checked');
148
- console.log(updateCount, 'events updated');
149
- console.log(invalidOrganizerCount, 'invalid');
150
- }
151
-
152
- main()
153
- .then()
154
- .catch(console.error);