@chevre/domain 22.5.0-alpha.8 → 22.5.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.
Files changed (160) hide show
  1. package/example/src/chevre/activateOptionalAggregationSettings.ts +19 -0
  2. package/example/src/chevre/aggregateAllEvents2.ts +7 -5
  3. package/example/src/chevre/aggregateEventPublicFields.ts +47 -0
  4. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +32 -0
  5. package/example/src/chevre/findReservationByCode.ts +11 -10
  6. package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +101 -0
  7. package/example/src/chevre/migrateProjectMakesOfferAvailableAt.ts +85 -0
  8. package/example/src/chevre/person/cleanUpCognitoUsers.ts +90 -0
  9. package/example/src/chevre/searchCategoryCodesByAggregate.ts +1 -2
  10. package/example/src/chevre/searchOfferCatalogItems.ts +3 -2
  11. package/example/src/chevre/searchProjects.ts +2 -4
  12. package/example/src/chevre/searchSellersByAggregate.ts +4 -6
  13. package/example/src/chevre/unsetUnnecessaryFields.ts +17 -19
  14. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +25 -14
  15. package/example/src/chevre/upsertProductsByProductId.ts +1 -1
  16. package/example/src/createMongooseConnection.ts +26 -0
  17. package/lib/chevre/repo/action.d.ts +41 -41
  18. package/lib/chevre/repo/action.js +5 -39
  19. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  20. package/lib/chevre/repo/categoryCode.d.ts +4 -8
  21. package/lib/chevre/repo/categoryCode.js +8 -36
  22. package/lib/chevre/repo/creativeWork.js +1 -20
  23. package/lib/chevre/repo/customer.d.ts +1 -1
  24. package/lib/chevre/repo/customer.js +4 -4
  25. package/lib/chevre/repo/event.d.ts +21 -12
  26. package/lib/chevre/repo/event.js +135 -37
  27. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +54 -0
  28. package/lib/chevre/repo/eventSellerMakesOffer.js +73 -0
  29. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -3
  30. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +0 -3
  31. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +0 -3
  32. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +0 -3
  33. package/lib/chevre/repo/mongoose/schemas/customer.js +0 -3
  34. package/lib/chevre/repo/mongoose/schemas/event.js +9 -54
  35. package/lib/chevre/repo/mongoose/schemas/member.js +0 -3
  36. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +0 -3
  37. package/lib/chevre/repo/mongoose/schemas/paymentService.js +0 -3
  38. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +0 -3
  39. package/lib/chevre/repo/mongoose/schemas/productModel.js +0 -3
  40. package/lib/chevre/repo/mongoose/schemas/project.js +0 -3
  41. package/lib/chevre/repo/mongoose/schemas/reservation.js +0 -3
  42. package/lib/chevre/repo/mongoose/schemas/seller.js +0 -3
  43. package/lib/chevre/repo/mongoose/schemas/trip.js +0 -3
  44. package/lib/chevre/repo/paymentService.d.ts +1 -1
  45. package/lib/chevre/repo/paymentService.js +0 -19
  46. package/lib/chevre/repo/place/movieTheater.js +1 -25
  47. package/lib/chevre/repo/product.js +1 -6
  48. package/lib/chevre/repo/project.d.ts +8 -2
  49. package/lib/chevre/repo/project.js +25 -26
  50. package/lib/chevre/repo/projectMakesOffer.d.ts +3 -1
  51. package/lib/chevre/repo/projectMakesOffer.js +5 -2
  52. package/lib/chevre/repo/role.js +0 -7
  53. package/lib/chevre/repo/seller.d.ts +18 -16
  54. package/lib/chevre/repo/seller.js +13 -31
  55. package/lib/chevre/repo/task.d.ts +12 -12
  56. package/lib/chevre/repo/transaction.d.ts +1 -1
  57. package/lib/chevre/repository.d.ts +5 -0
  58. package/lib/chevre/repository.js +15 -2
  59. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +4 -18
  60. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +28 -13
  61. package/lib/chevre/service/aggregation/project.js +1 -2
  62. package/lib/chevre/service/assetTransaction/cancelReservation.js +2 -4
  63. package/lib/chevre/service/assetTransaction/registerService.js +1 -2
  64. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +2 -1
  65. package/lib/chevre/service/assetTransaction/reserve/start.js +11 -38
  66. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +4 -1
  67. package/lib/chevre/service/event.js +2 -2
  68. package/lib/chevre/service/moneyTransfer.js +1 -2
  69. package/lib/chevre/service/notification.d.ts +2 -4
  70. package/lib/chevre/service/notification.js +30 -9
  71. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +2 -1
  72. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +2 -2
  73. package/lib/chevre/service/offer/event/authorize.d.ts +2 -1
  74. package/lib/chevre/service/offer/event/authorize.js +2 -2
  75. package/lib/chevre/service/offer/event/importFromCOA.js +2 -2
  76. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +1 -85
  77. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +21 -257
  78. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.d.ts +38 -0
  79. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +97 -0
  80. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.d.ts +48 -0
  81. package/lib/chevre/service/offer/event/searchOfferCatalogItemAvailability.js +109 -0
  82. package/lib/chevre/service/offer/event/searchOfferCatalogItems.d.ts +38 -0
  83. package/lib/chevre/service/offer/event/searchOfferCatalogItems.js +95 -0
  84. package/lib/chevre/service/offer/event/searchOffersByIds.js +26 -20
  85. package/lib/chevre/service/offer/event.d.ts +4 -1
  86. package/lib/chevre/service/offer/event.js +6 -3
  87. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  88. package/lib/chevre/service/offer/eventServiceByCOA/authorizeByAcceptAction.js +1 -1
  89. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +4 -4
  90. package/lib/chevre/service/offer/onEventChanged.d.ts +1 -13
  91. package/lib/chevre/service/offer/onEventChanged.js +64 -71
  92. package/lib/chevre/service/offer.d.ts +6 -0
  93. package/lib/chevre/service/offer.js +12 -15
  94. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  95. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDelivered/factory.js +7 -8
  96. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  97. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.js +7 -8
  98. package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/factory.js +8 -11
  99. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.js +7 -8
  101. package/lib/chevre/service/order/onOrderUpdated/factory.d.ts +1 -4
  102. package/lib/chevre/service/order/onOrderUpdated/factory.js +4 -7
  103. package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +2 -2
  104. package/lib/chevre/service/order/placeOrder.js +1 -1
  105. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
  106. package/lib/chevre/service/payment/any.js +1 -1
  107. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +1 -1
  108. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +0 -3
  109. package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +1 -1
  110. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +1 -1
  111. package/lib/chevre/service/payment/creditCard/voidTransaction.js +1 -1
  112. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +50 -57
  113. package/lib/chevre/service/payment/movieTicket/validation.js +1 -1
  114. package/lib/chevre/service/payment/paymentCard.js +0 -5
  115. package/lib/chevre/service/payment.d.ts +1 -1
  116. package/lib/chevre/service/report/telemetry.js +1 -1
  117. package/lib/chevre/service/reserve/cancelReservation.d.ts +1 -1
  118. package/lib/chevre/service/reserve/cancelReservation.js +14 -6
  119. package/lib/chevre/service/reserve/confirmReservation.js +1 -1
  120. package/lib/chevre/service/reserve/factory.d.ts +2 -61
  121. package/lib/chevre/service/reserve/factory.js +0 -11
  122. package/lib/chevre/service/reserve/findByCode.js +0 -1
  123. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.d.ts +19 -0
  124. package/lib/chevre/service/reserve/potentialActions/onPendingReservationCanceled.js +64 -0
  125. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -4
  126. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +37 -61
  127. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +22 -76
  128. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +26 -28
  129. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +0 -3
  130. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +17 -50
  131. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.d.ts +18 -0
  132. package/lib/chevre/service/reserve/potentialActions/onReservationsCreated.js +66 -0
  133. package/lib/chevre/service/reserve/useReservation.d.ts +1 -1
  134. package/lib/chevre/service/reserve/useReservation.js +4 -4
  135. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +0 -7
  136. package/lib/chevre/service/reserve/verifyToken4reservation.js +17 -12
  137. package/lib/chevre/service/task/aggregateScreeningEvent.js +4 -2
  138. package/lib/chevre/service/task/aggregateUseActionsOnEvent.d.ts +1 -1
  139. package/lib/chevre/service/task/aggregateUseActionsOnEvent.js +1 -5
  140. package/lib/chevre/service/task/deletePerson.d.ts +6 -0
  141. package/lib/chevre/service/task/deletePerson.js +420 -0
  142. package/lib/chevre/service/task/handleNotification.d.ts +3 -0
  143. package/lib/chevre/service/task/handleNotification.js +26 -0
  144. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  145. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  146. package/lib/chevre/service/task/triggerWebhook.js +2 -2
  147. package/lib/chevre/service/task.d.ts +3 -0
  148. package/lib/chevre/service/task.js +2 -0
  149. package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
  150. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +1 -3
  151. package/lib/chevre/service/transaction/placeOrder/start/validateStartRequest.js +4 -2
  152. package/lib/chevre/service/transaction/returnOrder/preStart.js +4 -3
  153. package/lib/chevre/settings/aggregation.d.ts +23 -0
  154. package/lib/chevre/settings/aggregation.js +17 -0
  155. package/lib/chevre/settings.d.ts +52 -38
  156. package/lib/chevre/settings.js +12 -13
  157. package/package.json +5 -7
  158. package/example/src/chevre/migratePayTransactionRecipes.ts +0 -252
  159. package/example/src/chevre/migrateProductHasOfferCatalog.ts +0 -80
  160. package/example/src/chevre/migrateProjectMakesOffer.ts +0 -78
@@ -0,0 +1,19 @@
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
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
12
+
13
+ await projectRepo.activateOptionalAggregationSettings({ id: PROJECT_ID });
14
+ console.log('activated.');
15
+ }
16
+
17
+ main()
18
+ .then(console.log)
19
+ .catch(console.error);
@@ -58,20 +58,22 @@ export async function aggregateScreeningEvent() {
58
58
  },
59
59
  notification: {
60
60
  timeout: 1000,
61
- useFetchAPI: true
61
+ useFetchAPI: true,
62
+ secretKey: 'xx',
63
+ headerIdentifier: 'xx'
62
64
  },
63
65
  userPoolIdOld: '',
64
66
  userPoolIdNew: '',
65
- useAggregateEntranceGateProjects: [],
66
- useAggregateOfferProjects: [],
67
- useOfferRateLimitProjects: [],
67
+ // useAggregateEntranceGateProjects: [],
68
+ // useAggregateOfferProjects: [],
69
+ // useOfferRateLimitProjects: [],
68
70
  defaultSenderEmail: 'test@example.com',
69
71
  deliverOrderLimit: 1,
70
72
  transaction: { informUrls: [], confirmedStoragePeriodInDays: 365, canceledStoragePeriodInDays: 365 },
71
73
  abortedTasksWithoutReport: [],
72
74
  coa: { timeout: 1000 },
73
75
  gmo: { timeout: 1000, timeoutBackground: 1000, useFetch: true },
74
- movieticketReserve: { timeout: 1000, timeoutCheck: 1000 },
76
+ movieticketReserve: { timeout: 1000, timeoutCheck: 1000, minIntervalBetweenPayAndRefund: 0 },
75
77
  numTryConfirmReserveTransaction: 10,
76
78
  useAssetTransactionSyncProcessing: true,
77
79
  useExperimentalFeature: false
@@ -0,0 +1,47 @@
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
+
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
13
+ const result = await eventRepo.aggregatePublicFields<chevre.factory.eventType.ScreeningEvent>(
14
+ {
15
+ limit: 10,
16
+ page: 1,
17
+ sort: { startDate: chevre.factory.sortType.Ascending },
18
+ // id: { $eq: 'bm0f0cadu' },
19
+ typeOf: chevre.factory.eventType.ScreeningEvent,
20
+ project: { id: { $eq: project.id } },
21
+ startFrom: new Date(),
22
+ startThrough: moment()
23
+ // tslint:disable-next-line:no-magic-numbers
24
+ .add(3, 'days')
25
+ .toDate()
26
+ // availableAtOrFrom: { id: { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' } },
27
+ // itemOffered: {
28
+ // serviceOutput: { reservationFor: { id: { $in: ['bm0f0cadu', 'blco2394l'] } } }
29
+ // }
30
+ },
31
+ ['eventStatus', 'startDate'],
32
+ {
33
+ includeOffers: true,
34
+ includeSellerMakesOffer: false,
35
+ // includeOffers: false,
36
+ sellerMakesOfferAvailableAtIn: ['51qbjcfr72h62m06vtv5kkhgje', 'g']
37
+ }
38
+ );
39
+ // tslint:disable-next-line:no-null-keyword
40
+ console.dir(result, { depth: null });
41
+ console.log(result.length, 'results found');
42
+ console.log(result.at(0)?.offers?.seller?.makesOffer?.length, 'makesOffer found');
43
+ }
44
+
45
+ main()
46
+ .then(console.log)
47
+ .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
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const eventSellerMakesOfferRepo = await chevre.repository.EventSellerMakesOffer.createInstance(mongoose.connection);
12
+ const result = await eventSellerMakesOfferRepo.aggregateMakesOffer(
13
+ {
14
+ limit: 10,
15
+ page: 1,
16
+ // id: { $eq: 'bm0f0cadu' },
17
+ // typeOf: chevre.factory.eventType.ScreeningEvent,
18
+ project: { id: { $eq: project.id } },
19
+ availableAtOrFrom: { id: { $eq: '3eo6okferrsdpfd9j2ce1iv9k7' } },
20
+ itemOffered: {
21
+ serviceOutput: { reservationFor: { id: { $in: ['bm0f0cadu', 'blco2394l'] } } }
22
+ }
23
+ }
24
+ );
25
+ // tslint:disable-next-line:no-null-keyword
26
+ console.dir(result, { depth: null });
27
+ console.dir(result.length, 'results found');
28
+ }
29
+
30
+ main()
31
+ .then(console.log)
32
+ .catch(console.error);
@@ -32,17 +32,18 @@ async function main() {
32
32
  authorization: authorizationRepo,
33
33
  order: orderRepo,
34
34
  ticket: ticketRepo
35
- },
36
- {
37
- jwt: await chevre.credentials.JWT.createInstance({
38
- secret: <string>process.env.TOKEN_SECRET,
39
- issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
40
- ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
41
- : [],
42
- version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
43
- payloadTypPrefix: (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
44
- })
45
35
  }
36
+ // {
37
+ // jwt: await chevre.credentials.JWT.createInstance({
38
+ // secret: <string>process.env.TOKEN_SECRET,
39
+ // issuers: (typeof process.env.TOKEN_ISSUERS_BY_AUTHORIZATION === 'string')
40
+ // ? process.env.TOKEN_ISSUERS_BY_AUTHORIZATION.split(' ')
41
+ // : [],
42
+ // version: (typeof process.env.TOKEN_VERSION === 'string') ? process.env.TOKEN_VERSION : '2024-05-02',
43
+ // payloadTypPrefix:
44
+ // (typeof process.env.TOKEN_PAYLOAD_TYP_PREFIX === 'string') ? process.env.TOKEN_PAYLOAD_TYP_PREFIX : 'chevre'
45
+ // })
46
+ // }
46
47
  );
47
48
  console.log('verified.');
48
49
 
@@ -0,0 +1,101 @@
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 excludedProject = { id: String(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 = await chevre.repository.Event.createInstance(mongoose.connection);
15
+
16
+ const cursor = eventRepo.getCursor(
17
+ {
18
+ 'project.id': { $ne: excludedProject.id },
19
+ startDate: {
20
+ $gte: moment()
21
+ .add(-1, 'days')
22
+ .toDate()
23
+ },
24
+ typeOf: { $eq: chevre.factory.eventType.ScreeningEvent }
25
+ // _id: { $eq: 'blyk9q24f' }
26
+ },
27
+ {
28
+ _id: 1,
29
+ offers: 1,
30
+ startDate: 1,
31
+ project: 1,
32
+ typeOf: 1
33
+ }
34
+ );
35
+ console.log('events found');
36
+
37
+ let i = 0;
38
+ let updateCount = 0;
39
+ await cursor.eachAsync(async (doc) => {
40
+ i += 1;
41
+ const event: Pick<
42
+ chevre.factory.event.screeningEvent.IEvent,
43
+ 'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
44
+ > = doc.toObject();
45
+
46
+ console.log(
47
+ 'alreadyMigrated?', event.project.id, event.typeOf, event.id, event.startDate, i);
48
+ const originMakesOffer = event.offers.seller.makesOffer;
49
+ const alreadyMigrated = !Array.isArray(originMakesOffer)
50
+ || (Array.isArray(originMakesOffer)
51
+ && originMakesOffer.every(
52
+ ({ availableAtOrFrom }) => !Array.isArray(availableAtOrFrom) && typeof availableAtOrFrom?.id === 'string'
53
+ ));
54
+
55
+ if (alreadyMigrated) {
56
+ console.log(
57
+ 'already migrated.', event.project.id, event.typeOf, event.id, event.startDate, i);
58
+ } else {
59
+ if (Array.isArray(originMakesOffer)) {
60
+ const newMakesOffer: chevre.factory.event.screeningEvent.ISellerMakesOffer[] = originMakesOffer.map((offer) => {
61
+ let newAvailableAtOrFrom: { id: string } | undefined;
62
+ if (Array.isArray(offer.availableAtOrFrom)) {
63
+ newAvailableAtOrFrom = offer.availableAtOrFrom.at(0);
64
+ }
65
+ if (newAvailableAtOrFrom === undefined) {
66
+ throw new Error('newAvailableAtOrFrom undefined');
67
+ }
68
+
69
+ return {
70
+ ...offer,
71
+ availableAtOrFrom: newAvailableAtOrFrom
72
+ };
73
+ });
74
+ console.log(
75
+ 'updating project...',
76
+ event.project.id, event.typeOf, event.id, event.startDate, i);
77
+ await eventRepo.updatePartiallyById({
78
+ project: { id: event.project.id },
79
+ id: event.id,
80
+ attributes: {
81
+ typeOf: event.typeOf,
82
+ ...{
83
+ 'offers.seller.makesOffer': newMakesOffer
84
+ }
85
+ }
86
+ });
87
+ updateCount += 1;
88
+ console.log(
89
+ 'updated.',
90
+ event.project.id, event.typeOf, event.id, event.startDate, i);
91
+ }
92
+ }
93
+ });
94
+
95
+ console.log(i, 'events checked');
96
+ console.log(updateCount, 'events updated');
97
+ }
98
+
99
+ main()
100
+ .then()
101
+ .catch(console.error);
@@ -0,0 +1,85 @@
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 excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
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 projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
14
+
15
+ const cursor = projectRepo.getCursor(
16
+ {
17
+ // _id: { $eq: 'cinerino' }
18
+ },
19
+ {
20
+ _id: 1,
21
+ makesOffer: 1,
22
+ typeOf: 1
23
+ }
24
+ );
25
+ console.log('docs found');
26
+
27
+ let i = 0;
28
+ let updateCount = 0;
29
+ await cursor.eachAsync(async (doc) => {
30
+ i += 1;
31
+ const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf'
32
+ > & {
33
+ makesOffer: chevre.factory.project.IMakesOffer[];
34
+ } = doc.toObject();
35
+
36
+ console.log(
37
+ 'alreadyMigrated?', project.id, i);
38
+ const originMakesOffer = project.makesOffer;
39
+ const alreadyMigrated = !Array.isArray(originMakesOffer)
40
+ || (Array.isArray(originMakesOffer)
41
+ && originMakesOffer.every(
42
+ ({ availableAtOrFrom }) => !Array.isArray(availableAtOrFrom) && typeof availableAtOrFrom?.id === 'string'
43
+ ));
44
+
45
+ if (alreadyMigrated) {
46
+ console.log(
47
+ 'already migrated.', project.id, i);
48
+ } else {
49
+ if (Array.isArray(originMakesOffer)) {
50
+ const newMakesOffer: chevre.factory.project.IMakesOffer[] = originMakesOffer.map((offer) => {
51
+ let newAvailableAtOrFrom: { id: string } | undefined;
52
+ if (Array.isArray(offer.availableAtOrFrom)) {
53
+ newAvailableAtOrFrom = offer.availableAtOrFrom.at(0);
54
+ }
55
+ if (newAvailableAtOrFrom === undefined) {
56
+ throw new Error('newAvailableAtOrFrom undefined');
57
+ }
58
+
59
+ return {
60
+ ...offer,
61
+ availableAtOrFrom: newAvailableAtOrFrom
62
+ };
63
+ });
64
+ console.log(
65
+ 'updating project...',
66
+ project.id, i, newMakesOffer);
67
+ await projectRepo.updateMakesOfferById({
68
+ id: project.id,
69
+ makesOffer: newMakesOffer
70
+ });
71
+ updateCount += 1;
72
+ console.log(
73
+ 'updated.',
74
+ project.id, i);
75
+ }
76
+ }
77
+ });
78
+
79
+ console.log(i, 'docs checked');
80
+ console.log(updateCount, 'docs updated');
81
+ }
82
+
83
+ main()
84
+ .then()
85
+ .catch(console.error);
@@ -0,0 +1,90 @@
1
+ // tslint:disable:no-console
2
+ import { CognitoIdentityProvider, UserType } from '@aws-sdk/client-cognito-identity-provider';
3
+ import { fromEnv } from '@aws-sdk/credential-providers';
4
+ import * as moment from 'moment';
5
+
6
+ import { chevre } from '../../../../lib/index';
7
+
8
+ export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
9
+ export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
10
+ const USER_GROUP_NAME = String(process.env.USER_GROUP_NAME); // 'ap-northeast-1_XXXXXXXXX_SSKTS',
11
+ const NEW_USERPOOL_PROVIDER_NAME = 'SSKTS';
12
+
13
+ // tslint:disable-next-line:max-func-body-length
14
+ async function main(): Promise<void> {
15
+ const awsCredentials = fromEnv();
16
+ const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
17
+ apiVersion: 'latest',
18
+ region: 'ap-northeast-1',
19
+ credentials: awsCredentials
20
+ });
21
+
22
+ // create user
23
+ const newPersonRepo = await chevre.repository.Person.createInstance({
24
+ userPoolId: USERPOOL_ID_NEW,
25
+ cognitoIdentityServiceProvider
26
+ });
27
+
28
+ const users: UserType[] = [];
29
+ let nextToken: string | undefined = '';
30
+ let page: number = 0;
31
+ while (typeof nextToken === 'string') {
32
+ page += 1;
33
+ console.log('listUsersInGroup processing...', nextToken, page);
34
+ const listUsersInGroupResult = await newPersonRepo.cognitoIdentityServiceProvider.listUsersInGroup(
35
+ {
36
+ Limit: 50,
37
+ UserPoolId: USERPOOL_ID_NEW,
38
+ GroupName: USER_GROUP_NAME,
39
+ ...(typeof nextToken === 'string' && nextToken !== '') ? { NextToken: nextToken } : undefined
40
+ }
41
+ );
42
+ // tslint:disable-next-line:no-null-keyword
43
+ console.dir(listUsersInGroupResult.Users?.at(0), { depth: null });
44
+ nextToken = listUsersInGroupResult.NextToken;
45
+ if (Array.isArray(listUsersInGroupResult.Users)) {
46
+ users.push(...listUsersInGroupResult.Users);
47
+ }
48
+ }
49
+ console.log('listUsersInGroup processed', nextToken, page);
50
+ console.log(users.length, 'users found');
51
+
52
+ const oneMonthAgo = moment()
53
+ .add(-1, 'months');
54
+ for (const user of users) {
55
+ const isSSKTSMember = user.Username?.startsWith(NEW_USERPOOL_PROVIDER_NAME, 0);
56
+ if (!isSSKTSMember) {
57
+ console.error(user);
58
+ throw new Error('not ssktsMember');
59
+ }
60
+
61
+ const sub = user.Attributes?.find(({ Name }) => Name === 'sub')?.Value;
62
+ // if (user.Enabled === true && sub === '46686164-2c18-491a-8594-52c944d895e9') {
63
+ if (user.Enabled === true) {
64
+ console.log('disabling...', user.Username, sub);
65
+ // disable link provider
66
+ const adminDisableUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDisableUser({
67
+ UserPoolId: USERPOOL_ID_NEW,
68
+ Username: user.Username
69
+ });
70
+ console.log('disabled.', user.Username, sub, adminDisableUserResult);
71
+ } else {
72
+ if (user.UserLastModifiedDate instanceof Date) {
73
+ if (moment(user.UserLastModifiedDate)
74
+ .isBefore(oneMonthAgo)) {
75
+ console.log('adminDeleteUser prossing...', user.Username, sub);
76
+ const adminDeleteUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDeleteUser({
77
+ UserPoolId: USERPOOL_ID_NEW,
78
+ Username: user.Username
79
+ });
80
+ console.log('adminDeleteUser processed.', user.Username, sub, adminDeleteUserResult);
81
+ }
82
+ }
83
+
84
+ }
85
+ }
86
+ }
87
+
88
+ main()
89
+ .then()
90
+ .catch(console.error);
@@ -20,8 +20,7 @@ async function main() {
20
20
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
21
21
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
22
22
  },
23
- ['_id'],
24
- []
23
+ ['id']
25
24
  );
26
25
  console.log('categoryCodes found', categoryCodes[0]);
27
26
  console.log(categoryCodes.length, 'categoryCodes found');
@@ -18,10 +18,11 @@ async function main() {
18
18
 
19
19
  const result = await (await chevre.service.offer.createService()).event.searchOfferCatalogItems({
20
20
  event: {
21
- id: 'cllkq475u'
21
+ id: 'bm0f0cadm'
22
22
  },
23
23
  limit: 10,
24
- page: 1
24
+ page: 1,
25
+ options: { includedInDataCatalog: { id: 'blpj322ni' } }
25
26
  })({
26
27
  event: eventRepo,
27
28
  offerCatalog: offerCatalogRepo,
@@ -12,8 +12,7 @@ async function main() {
12
12
 
13
13
  const project = await projectRepo.findById({
14
14
  id: PROJECT_ID,
15
- inclusion: [],
16
- exclusion: ['settings', 'hasMerchantReturnPolicy']
15
+ inclusion: ['settings']
17
16
  });
18
17
  console.log('project:', project);
19
18
 
@@ -23,8 +22,7 @@ async function main() {
23
22
  page: 1,
24
23
  id: { $eq: project.id }
25
24
  },
26
- ['typeOf'],
27
- []
25
+ ['typeOf']
28
26
  );
29
27
  console.log(projects);
30
28
  console.log(projects.length, 'projects found');
@@ -12,15 +12,14 @@ async function main() {
12
12
 
13
13
  const sellersByAggregate = await sellerRepo.searchByAggregate(
14
14
  {
15
- limit: 5,
15
+ limit: 1,
16
16
  page: 1,
17
- sort: { branchCode: chevre.factory.sortType.Descending },
18
- id: { $eq: '59d20831e53ebc2b4e774466' }
17
+ sort: { branchCode: chevre.factory.sortType.Descending }
18
+ // id: { $eq: '59d20831e53ebc2b4e774466' }
19
19
  // project: { id: { $eq: project.id } }
20
20
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
21
21
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
22
22
  },
23
- [],
24
23
  ['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
25
24
  );
26
25
  console.log('sellers found', sellersByAggregate, sellersByAggregate[0]?.hasMerchantReturnPolicy);
@@ -36,8 +35,7 @@ async function main() {
36
35
  // paymentAccepted: { paymentMethodType: { $eq: 'Cash' } },
37
36
  // hasMerchantReturnPolicy: { applicablePaymentMethod: {} }
38
37
  },
39
- [],
40
- ['hasMerchantReturnPolicy', 'additionalProperty', 'project', 'name', 'typeOf', 'url', 'telephone']
38
+ ['id', 'typeOf']
41
39
  );
42
40
  console.log('sellers found', sellers, sellers[0]?.hasMerchantReturnPolicy);
43
41
  console.log(sellers.length, 'sellers found');
@@ -1,35 +1,33 @@
1
1
  // tslint:disable:no-console
2
+ import * as moment from 'moment';
2
3
  import * as mongoose from 'mongoose';
3
4
 
4
5
  import { chevre } from '../../../lib/index';
5
6
 
7
+ const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
8
+
6
9
  async function main() {
7
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
11
 
9
- const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
10
- const offerItemConditionRepo = await chevre.repository.OfferItemCondition.createInstance(mongoose.connection);
12
+ const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
11
13
 
12
14
  let updateResult: any;
13
- updateResult = await creativeWorkRepo.unsetUnnecessaryFields({
14
- filter: {
15
- _id: { $exists: true }
16
- },
17
- $unset: <any>{
18
- createdAt: 1,
19
- updatedAt: 1,
20
- __v: 1
21
- }
22
- });
23
- console.log(updateResult);
24
-
25
- updateResult = await offerItemConditionRepo.unsetUnnecessaryFields({
15
+ updateResult = await eventRepo.unsetUnnecessaryFields({
26
16
  filter: {
27
- _id: { $exists: true }
17
+ 'project.id': { $ne: excludedProject.id },
18
+ 'offers.validFrom': { $exists: true },
19
+ startDate: {
20
+ $gte: moment()
21
+ .add(-1, 'days')
22
+ .toDate()
23
+ }
24
+ // _id: { $eq: 'blxd1grz3' }
28
25
  },
29
26
  $unset: <any>{
30
- createdAt: 1,
31
- updatedAt: 1,
32
- __v: 1
27
+ 'offers.availabilityEnds': 1,
28
+ 'offers.availabilityStarts': 1,
29
+ 'offers.validFrom': 1,
30
+ 'offers.validThrough': 1
33
31
  }
34
32
  });
35
33
  console.log(updateResult);
@@ -6,6 +6,7 @@ const PROJECT_ID = String(process.env.PROJECT_ID);
6
6
 
7
7
  // tslint:disable-next-line:max-func-body-length
8
8
  async function main() {
9
+ const now = new Date();
9
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
11
 
11
12
  const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
@@ -14,8 +15,8 @@ async function main() {
14
15
  {
15
16
  additionalProperty: [
16
17
  {
17
- name: 'createId',
18
- value: 'akeuu512i-10-202409151130-01'
18
+ name: 'sampleCreateId',
19
+ value: 'akeuu512i-202410171410-01'
19
20
  }
20
21
  ],
21
22
  project: {
@@ -23,10 +24,10 @@ async function main() {
23
24
  typeOf: chevre.factory.organizationType.Project
24
25
  },
25
26
  typeOf: chevre.factory.eventType.ScreeningEvent,
26
- doorTime: new Date('2024-09-15T02:30:00.000Z'),
27
- endDate: new Date('2024-09-15T11:45:00.000Z'),
28
- // eventStatus: chevre.factory.eventStatusType.EventScheduled,
29
- eventStatus: chevre.factory.eventStatusType.EventCancelled,
27
+ doorTime: new Date('2024-10-17T05:30:00.000Z'),
28
+ endDate: new Date('2024-10-17T05:45:00.000Z'),
29
+ eventStatus: chevre.factory.eventStatusType.EventScheduled,
30
+ // eventStatus: chevre.factory.eventStatusType.EventCancelled,
30
31
  location: {
31
32
  typeOf: chevre.factory.placeType.ScreeningRoom,
32
33
  branchCode: '10',
@@ -45,8 +46,8 @@ async function main() {
45
46
  },
46
47
  offers: {
47
48
  typeOf: chevre.factory.offerType.Offer,
48
- availabilityEnds: new Date('2024-09-15T11:45:00.000Z'),
49
- availabilityStarts: new Date('2024-09-01T15:00:00.000Z'),
49
+ // availabilityEnds: new Date('2024-09-15T11:45:00.000Z'),
50
+ // availabilityStarts: new Date('2024-09-01T15:00:00.000Z'),
50
51
  eligibleQuantity: {
51
52
  typeOf: 'QuantitativeValue',
52
53
  unitCode: chevre.factory.unitCode.C62,
@@ -97,8 +98,8 @@ async function main() {
97
98
  typeOf: 'CategoryCode'
98
99
  }
99
100
  },
100
- validFrom: new Date('2024-09-01T15:00:00.000Z'),
101
- validThrough: new Date('2024-09-15T11:45:00.000Z'),
101
+ // validFrom: new Date('2024-09-01T15:00:00.000Z'),
102
+ // validThrough: new Date('2024-09-15T11:45:00.000Z'),
102
103
  seller: {
103
104
  typeOf: chevre.factory.organizationType.Corporation,
104
105
  id: '59d20831e53ebc2b4e774466',
@@ -106,7 +107,16 @@ async function main() {
106
107
  ja: 'シネモーション赤坂',
107
108
  en: 'CineMotion Akasaka'
108
109
  },
109
- makesOffer: []
110
+ makesOffer: [
111
+ {
112
+ typeOf: chevre.factory.offerType.Offer,
113
+ availableAtOrFrom: { id: '51qbjcfr72h62m06vtv5kkhgje' },
114
+ availabilityEnds: now,
115
+ availabilityStarts: now,
116
+ validFrom: now,
117
+ validThrough: now
118
+ }
119
+ ]
110
120
  },
111
121
  unacceptedPaymentMethod: [
112
122
  'MovieTicket'
@@ -115,7 +125,7 @@ async function main() {
115
125
  organizer: {
116
126
  id: '59d20831e53ebc2b4e774466'
117
127
  },
118
- startDate: new Date('2024-09-15T02:30:00.000Z'),
128
+ startDate: new Date('2024-10-17T05:30:00.000Z'),
119
129
  superEvent: {
120
130
  typeOf: chevre.factory.eventType.ScreeningEventSeries,
121
131
  id: 'akeuu512i',
@@ -163,13 +173,14 @@ async function main() {
163
173
  }
164
174
  }
165
175
  ],
166
- additionalPropertyFilter: { name: 'createId' },
176
+ additionalPropertyFilter: { name: 'sampleCreateId' },
167
177
  eventSeries: {
168
178
  id: 'akeuu512i'
169
179
  },
170
180
  screeningRoom: {
171
181
  branchCode: '10'
172
- }
182
+ },
183
+ options: { updateOffersSeller: false }
173
184
  });
174
185
  // tslint:disable-next-line:no-null-keyword
175
186
  console.dir(result, { depth: null });