@chevre/domain 21.2.0-alpha.8 → 21.2.0-alpha.81

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 (237) hide show
  1. package/example/src/chevre/aggregation/aggregateSystem.ts +58 -31
  2. package/example/src/chevre/countDelayedTransactions.ts +60 -0
  3. package/example/src/chevre/createManyEventsIfNotExist.ts +4 -1
  4. package/example/src/chevre/deleteTasksByName.ts +10 -2
  5. package/example/src/chevre/importEventsFromCOA.ts +3 -4
  6. package/example/src/chevre/migrateOrderAdditionalProperties.ts +85 -0
  7. package/example/src/chevre/processReserve.ts +2 -1
  8. package/example/src/chevre/saveTasks.ts +13 -10
  9. package/example/src/chevre/searchAbortedTasks.ts +36 -0
  10. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +37 -1
  11. package/example/src/chevre/searchSellers.ts +32 -0
  12. package/example/src/chevre/searchSendEmailActions.ts +44 -0
  13. package/example/src/chevre/task/executeTasks.ts +26 -0
  14. package/example/src/chevre/transaction/findCreditCard.ts +1 -1
  15. package/example/src/chevre/transaction/orderMembershipService.ts +1 -1
  16. package/example/src/chevre/transaction/processReturnOrder.ts +40 -0
  17. package/example/src/chevre/transaction/startExportTasks.ts +20 -0
  18. package/example/src/chevre/updateTransaction.ts +1 -1
  19. package/example/src/playOnMoment.ts +24 -0
  20. package/lib/chevre/credentials.d.ts +1 -0
  21. package/lib/chevre/credentials.js +2 -1
  22. package/lib/chevre/eventEmitter/assetTransaction.d.ts +21 -0
  23. package/lib/chevre/eventEmitter/assetTransaction.js +25 -0
  24. package/lib/chevre/eventEmitter/task.d.ts +18 -0
  25. package/lib/chevre/eventEmitter/task.js +25 -0
  26. package/lib/chevre/eventEmitter/transaction.d.ts +21 -0
  27. package/lib/chevre/eventEmitter/transaction.js +25 -0
  28. package/lib/chevre/eventEmitter.d.ts +4 -0
  29. package/lib/chevre/eventEmitter.js +9 -0
  30. package/lib/chevre/index.d.ts +3 -2
  31. package/lib/chevre/index.js +5 -3
  32. package/lib/chevre/repo/accountTransaction.d.ts +3 -11
  33. package/lib/chevre/repo/accountTransaction.js +1 -54
  34. package/lib/chevre/repo/action.d.ts +29 -1
  35. package/lib/chevre/repo/action.js +32 -25
  36. package/lib/chevre/repo/assetTransaction.d.ts +25 -9
  37. package/lib/chevre/repo/assetTransaction.js +237 -80
  38. package/lib/chevre/repo/comment.d.ts +4 -1
  39. package/lib/chevre/repo/comment.js +20 -5
  40. package/lib/chevre/repo/confirmationNumber.d.ts +0 -1
  41. package/lib/chevre/repo/confirmationNumber.js +3 -15
  42. package/lib/chevre/repo/creativeWork.d.ts +1 -3
  43. package/lib/chevre/repo/emailMessage.d.ts +1 -27
  44. package/lib/chevre/repo/event.d.ts +5 -1
  45. package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -3
  46. package/lib/chevre/repo/mongoose/schemas/account.d.ts +5 -2
  47. package/lib/chevre/repo/mongoose/schemas/account.js +1 -0
  48. package/lib/chevre/repo/mongoose/schemas/accountTitle.d.ts +30 -3
  49. package/lib/chevre/repo/mongoose/schemas/accountTitle.js +1 -0
  50. package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +32 -3
  51. package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +2 -1
  52. package/lib/chevre/repo/mongoose/schemas/accountingReport.d.ts +14 -3
  53. package/lib/chevre/repo/mongoose/schemas/accountingReport.js +1 -0
  54. package/lib/chevre/repo/mongoose/schemas/action.d.ts +44 -3
  55. package/lib/chevre/repo/mongoose/schemas/action.js +2 -1
  56. package/lib/chevre/repo/mongoose/schemas/additionalProperty.d.ts +18 -3
  57. package/lib/chevre/repo/mongoose/schemas/additionalProperty.js +1 -0
  58. package/lib/chevre/repo/mongoose/schemas/aggregation.d.ts +5 -2
  59. package/lib/chevre/repo/mongoose/schemas/aggregation.js +1 -0
  60. package/lib/chevre/repo/mongoose/schemas/assetTransaction.d.ts +45 -3
  61. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +27 -19
  62. package/lib/chevre/repo/mongoose/schemas/authorization.d.ts +20 -3
  63. package/lib/chevre/repo/mongoose/schemas/authorization.js +2 -1
  64. package/lib/chevre/repo/mongoose/schemas/categoryCode.d.ts +26 -3
  65. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +1 -0
  66. package/lib/chevre/repo/mongoose/schemas/comments.d.ts +28 -3
  67. package/lib/chevre/repo/mongoose/schemas/comments.js +2 -1
  68. package/lib/chevre/repo/mongoose/schemas/creativeWork.d.ts +44 -3
  69. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +1 -0
  70. package/lib/chevre/repo/mongoose/schemas/customer.d.ts +26 -3
  71. package/lib/chevre/repo/mongoose/schemas/customer.js +1 -0
  72. package/lib/chevre/repo/mongoose/schemas/emailMessages.d.ts +22 -3
  73. package/lib/chevre/repo/mongoose/schemas/emailMessages.js +1 -0
  74. package/lib/chevre/repo/mongoose/schemas/event.d.ts +72 -3
  75. package/lib/chevre/repo/mongoose/schemas/event.js +1 -0
  76. package/lib/chevre/repo/mongoose/schemas/member.d.ts +14 -3
  77. package/lib/chevre/repo/mongoose/schemas/member.js +1 -0
  78. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.d.ts +22 -3
  79. package/lib/chevre/repo/mongoose/schemas/merchantReturnPolicy.js +1 -0
  80. package/lib/chevre/repo/mongoose/schemas/offer.d.ts +66 -3
  81. package/lib/chevre/repo/mongoose/schemas/offer.js +1 -0
  82. package/lib/chevre/repo/mongoose/schemas/offerCatalog.d.ts +28 -3
  83. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +1 -0
  84. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.d.ts +74 -0
  85. package/lib/chevre/repo/mongoose/schemas/offerItemCondition.js +45 -0
  86. package/lib/chevre/repo/mongoose/schemas/order.d.ts +52 -3
  87. package/lib/chevre/repo/mongoose/schemas/order.js +2 -1
  88. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.d.ts +26 -3
  89. package/lib/chevre/repo/mongoose/schemas/ownershipInfo.js +2 -1
  90. package/lib/chevre/repo/mongoose/schemas/place.d.ts +50 -3
  91. package/lib/chevre/repo/mongoose/schemas/place.js +1 -0
  92. package/lib/chevre/repo/mongoose/schemas/priceSpecification.d.ts +30 -3
  93. package/lib/chevre/repo/mongoose/schemas/priceSpecification.js +1 -0
  94. package/lib/chevre/repo/mongoose/schemas/product.d.ts +32 -3
  95. package/lib/chevre/repo/mongoose/schemas/product.js +1 -0
  96. package/lib/chevre/repo/mongoose/schemas/project.d.ts +24 -3
  97. package/lib/chevre/repo/mongoose/schemas/project.js +1 -0
  98. package/lib/chevre/repo/mongoose/schemas/reservation.d.ts +63 -4
  99. package/lib/chevre/repo/mongoose/schemas/reservation.js +2 -1
  100. package/lib/chevre/repo/mongoose/schemas/role.d.ts +12 -3
  101. package/lib/chevre/repo/mongoose/schemas/role.js +1 -0
  102. package/lib/chevre/repo/mongoose/schemas/seller.d.ts +32 -3
  103. package/lib/chevre/repo/mongoose/schemas/seller.js +7 -0
  104. package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +12 -3
  105. package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +2 -1
  106. package/lib/chevre/repo/mongoose/schemas/task.d.ts +31 -3
  107. package/lib/chevre/repo/mongoose/schemas/task.js +3 -1
  108. package/lib/chevre/repo/mongoose/schemas/telemetry.d.ts +22 -3
  109. package/lib/chevre/repo/mongoose/schemas/telemetry.js +1 -0
  110. package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +41 -3
  111. package/lib/chevre/repo/mongoose/schemas/transaction.js +3 -1
  112. package/lib/chevre/repo/mongoose/schemas/trip.d.ts +12 -3
  113. package/lib/chevre/repo/mongoose/schemas/trip.js +1 -0
  114. package/lib/chevre/repo/offerItemCondition.d.ts +22 -0
  115. package/lib/chevre/repo/offerItemCondition.js +120 -0
  116. package/lib/chevre/repo/order.d.ts +52 -2
  117. package/lib/chevre/repo/order.js +52 -4
  118. package/lib/chevre/repo/reservation.d.ts +8 -4
  119. package/lib/chevre/repo/reservation.js +8 -42
  120. package/lib/chevre/repo/seller.js +19 -19
  121. package/lib/chevre/repo/task.d.ts +42 -2
  122. package/lib/chevre/repo/task.js +90 -9
  123. package/lib/chevre/repo/transaction.d.ts +23 -3
  124. package/lib/chevre/repo/transaction.js +174 -54
  125. package/lib/chevre/repository.d.ts +5 -2
  126. package/lib/chevre/repository.js +8 -4
  127. package/lib/chevre/service/aggregation/system.d.ts +67 -22
  128. package/lib/chevre/service/aggregation/system.js +101 -89
  129. package/lib/chevre/service/assetTransaction/cancelReservation.js +1 -28
  130. package/lib/chevre/service/assetTransaction/moneyTransfer.js +1 -23
  131. package/lib/chevre/service/assetTransaction/pay/potentialActions.js +17 -1
  132. package/lib/chevre/service/assetTransaction/pay.js +10 -25
  133. package/lib/chevre/service/assetTransaction/refund.js +1 -23
  134. package/lib/chevre/service/assetTransaction/registerService.js +1 -25
  135. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +7 -2
  136. package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -22
  137. package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -1
  138. package/lib/chevre/service/assetTransaction/reserve.js +35 -40
  139. package/lib/chevre/service/assetTransaction.d.ts +6 -2
  140. package/lib/chevre/service/assetTransaction.js +9 -5
  141. package/lib/chevre/service/event.js +3 -1
  142. package/lib/chevre/service/notification/factory.js +2 -2
  143. package/lib/chevre/service/notification.d.ts +3 -1
  144. package/lib/chevre/service/notification.js +41 -7
  145. package/lib/chevre/service/offer/event/authorize.d.ts +1 -0
  146. package/lib/chevre/service/offer/event/authorize.js +5 -2
  147. package/lib/chevre/service/offer/event/factory.d.ts +2 -0
  148. package/lib/chevre/service/offer/event/factory.js +2 -2
  149. package/lib/chevre/service/offer/event/voidTransaction.d.ts +2 -0
  150. package/lib/chevre/service/offer/event/voidTransaction.js +17 -1
  151. package/lib/chevre/service/offer.js +1 -1
  152. package/lib/chevre/service/order/deleteOrder.d.ts +3 -1
  153. package/lib/chevre/service/order/deleteOrder.js +8 -8
  154. package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +0 -1
  155. package/lib/chevre/service/order/onOrderStatusChanged/factory.js +1 -48
  156. package/lib/chevre/service/order/onOrderStatusChanged.js +1 -3
  157. package/lib/chevre/service/order/placeOrder.js +1 -1
  158. package/lib/chevre/service/order/returnOrder.js +1 -5
  159. package/lib/chevre/service/order/sendOrder.js +1 -1
  160. package/lib/chevre/service/payment/any/onPaid.js +1 -1
  161. package/lib/chevre/service/payment/any/onRefund.js +1 -1
  162. package/lib/chevre/service/payment/any.js +60 -10
  163. package/lib/chevre/service/payment/movieTicket/validation.d.ts +3 -2
  164. package/lib/chevre/service/payment/movieTicket/validation.js +12 -25
  165. package/lib/chevre/service/payment/movieTicket.d.ts +1 -1
  166. package/lib/chevre/service/payment/movieTicket.js +4 -3
  167. package/lib/chevre/service/product.js +1 -5
  168. package/lib/chevre/service/report/telemetry.d.ts +0 -11
  169. package/lib/chevre/service/report/telemetry.js +21 -24
  170. package/lib/chevre/service/reserve/cancelReservation.d.ts +4 -2
  171. package/lib/chevre/service/reserve/cancelReservation.js +2 -4
  172. package/lib/chevre/service/reserve/checkInReservation.d.ts +0 -3
  173. package/lib/chevre/service/reserve/checkInReservation.js +24 -0
  174. package/lib/chevre/service/reserve/confirmReservation.d.ts +2 -0
  175. package/lib/chevre/service/reserve/confirmReservation.js +45 -9
  176. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.d.ts +0 -3
  177. package/lib/chevre/service/reserve/potentialActions/onReservationCanceled.js +20 -20
  178. package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -3
  179. package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +2 -31
  180. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +2 -3
  181. package/lib/chevre/service/reserve/useReservation.d.ts +4 -3
  182. package/lib/chevre/service/reserve/useReservation.js +14 -71
  183. package/lib/chevre/service/reserve/verifyToken4reservation.d.ts +15 -0
  184. package/lib/chevre/service/reserve/verifyToken4reservation.js +56 -0
  185. package/lib/chevre/service/reserve.d.ts +2 -1
  186. package/lib/chevre/service/reserve.js +3 -1
  187. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
  188. package/lib/chevre/service/task/deleteTransaction.js +10 -8
  189. package/lib/chevre/service/task/importOffersFromCOA.js +4 -0
  190. package/lib/chevre/service/task/onAuthorizationCreated.d.ts +7 -0
  191. package/lib/chevre/service/task/onAuthorizationCreated.js +101 -0
  192. package/lib/chevre/service/task/reserve.js +5 -6
  193. package/lib/chevre/service/task/returnPayTransaction.js +2 -12
  194. package/lib/chevre/service/task/useReservation.d.ts +7 -0
  195. package/lib/chevre/service/task/{deleteOrder.js → useReservation.js} +11 -12
  196. package/lib/chevre/service/task/voidReserveTransaction.js +3 -1
  197. package/lib/chevre/service/task.d.ts +9 -0
  198. package/lib/chevre/service/task.js +43 -4
  199. package/lib/chevre/service/transaction/deleteTransaction.d.ts +21 -0
  200. package/lib/chevre/service/transaction/deleteTransaction.js +232 -0
  201. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.js +11 -1
  202. package/lib/chevre/service/transaction/moneyTransfer/factory.js +3 -1
  203. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -0
  204. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.js +1 -1
  205. package/lib/chevre/service/transaction/moneyTransfer.js +9 -12
  206. package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +42 -30
  207. package/lib/chevre/service/transaction/placeOrder.js +1 -5
  208. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +1 -1
  209. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.d.ts +1 -0
  210. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/moneyTransfer.js +1 -1
  211. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +1 -0
  212. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +1 -1
  213. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +1 -0
  214. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.d.ts +3 -0
  215. package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +7 -3
  216. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -0
  217. package/lib/chevre/service/transaction/placeOrderInProgress/result.js +2 -2
  218. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.d.ts +1 -1
  219. package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateMovieTicket.js +2 -2
  220. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +2 -1
  221. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +23 -17
  222. package/lib/chevre/service/transaction/placeOrderInProgress.d.ts +0 -3
  223. package/lib/chevre/service/transaction/placeOrderInProgress.js +22 -11
  224. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +10 -1
  225. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.js +25 -17
  226. package/lib/chevre/service/transaction/returnOrder.d.ts +4 -0
  227. package/lib/chevre/service/transaction/returnOrder.js +225 -35
  228. package/lib/chevre/service/transaction.d.ts +8 -13
  229. package/lib/chevre/service/transaction.js +12 -145
  230. package/lib/chevre/settings.d.ts +4 -1
  231. package/lib/chevre/settings.js +15 -5
  232. package/package.json +5 -5
  233. package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +0 -96
  234. package/example/src/chevre/migrateMovieAdditionalProperties.ts +0 -98
  235. package/lib/chevre/service/task/deleteAssetTransaction.d.ts +0 -12
  236. package/lib/chevre/service/task/deleteAssetTransaction.js +0 -65
  237. package/lib/chevre/service/task/deleteOrder.d.ts +0 -6
@@ -6,8 +6,10 @@ import { chevre } from '../../../../lib/index';
6
6
  const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
7
7
  const AGGREGATE_DAYS = Number(process.env.AGGREGATE_DAYS);
8
8
  const AGGREGATE_CLIENT_IDS = (typeof process.env.AGGREGATE_CLIENT_IDS === 'string') ? process.env.AGGREGATE_CLIENT_IDS.split(' ') : [];
9
+ const ONE_DAY_IN_HOURS = 24;
9
10
  console.log('AGGREGATE_CLIENT_IDS:', AGGREGATE_CLIENT_IDS);
10
11
 
12
+ // tslint:disable-next-line:max-func-body-length
11
13
  async function main() {
12
14
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
15
 
@@ -18,94 +20,119 @@ async function main() {
18
20
  const actionRepo = new chevre.repository.Action(mongoose.connection);
19
21
  const taskRepo = new chevre.repository.Task(mongoose.connection);
20
22
 
21
- await chevre.service.aggregation.system.aggregatePayMovieTicketAction({
22
- aggregationDays: AGGREGATE_DAYS,
23
- excludedProjectId: EXCLUDED_PROJECT_ID
23
+ let result: { aggregationCount: number; aggregateDuration: string };
24
+
25
+ result = await chevre.service.aggregation.system.aggregatePlaceOrder({
26
+ aggregateDurationUnit: 'hours',
27
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
28
+ excludedProjectId: EXCLUDED_PROJECT_ID,
29
+ clientIds: AGGREGATE_CLIENT_IDS
24
30
  })({
25
31
  agregation: aggregationRepo,
26
- action: actionRepo
32
+ transaction: transactionRepo
27
33
  });
34
+ console.log('aggregatePlaceOrder processed.', result);
35
+ // return;
28
36
 
29
- await chevre.service.aggregation.system.aggregatePayTransaction({
30
- aggregationDays: AGGREGATE_DAYS,
37
+ result = await chevre.service.aggregation.system.aggregateTask({
38
+ aggregateDurationUnit: 'hours',
39
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
31
40
  excludedProjectId: EXCLUDED_PROJECT_ID
32
41
  })({
33
42
  agregation: aggregationRepo,
34
- assetTransaction: assetTransactionRepo
43
+ task: taskRepo
35
44
  });
45
+ console.log('aggregateTask processed.', result);
36
46
 
37
- await chevre.service.aggregation.system.aggregateEvent({
38
- aggregationDays: AGGREGATE_DAYS,
47
+ result = await chevre.service.aggregation.system.aggregatePayMovieTicketAction({
48
+ aggregateDurationUnit: 'hours',
49
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
39
50
  excludedProjectId: EXCLUDED_PROJECT_ID
40
51
  })({
41
52
  agregation: aggregationRepo,
42
- event: eventRepo
53
+ action: actionRepo
43
54
  });
55
+ console.log('aggregatePayMovieTicketAction processed.', result);
44
56
 
45
- await chevre.service.aggregation.system.aggregateTask({
46
- aggregationDays: AGGREGATE_DAYS,
57
+ result = await chevre.service.aggregation.system.aggregatePayTransaction({
58
+ aggregateDurationUnit: 'hours',
59
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
47
60
  excludedProjectId: EXCLUDED_PROJECT_ID
48
61
  })({
49
62
  agregation: aggregationRepo,
50
- task: taskRepo
63
+ assetTransaction: assetTransactionRepo
51
64
  });
65
+ console.log('aggregatePayTransaction processed.', result);
52
66
 
53
- await chevre.service.aggregation.system.aggregateReserveTransaction({
54
- aggregationDays: AGGREGATE_DAYS,
67
+ result = await chevre.service.aggregation.system.aggregateEvent({
68
+ aggregateDurationUnit: 'hours',
69
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
55
70
  excludedProjectId: EXCLUDED_PROJECT_ID
56
71
  })({
57
72
  agregation: aggregationRepo,
58
- assetTransaction: assetTransactionRepo
73
+ event: eventRepo
59
74
  });
75
+ console.log('aggregateEvent processed.', result);
60
76
 
61
- await chevre.service.aggregation.system.aggregatePlaceOrder({
62
- aggregationDays: AGGREGATE_DAYS,
63
- excludedProjectId: EXCLUDED_PROJECT_ID,
64
- clientIds: AGGREGATE_CLIENT_IDS
77
+ result = await chevre.service.aggregation.system.aggregateReserveTransaction({
78
+ aggregateDurationUnit: 'hours',
79
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
80
+ excludedProjectId: EXCLUDED_PROJECT_ID
65
81
  })({
66
82
  agregation: aggregationRepo,
67
- transaction: transactionRepo
83
+ assetTransaction: assetTransactionRepo
68
84
  });
85
+ console.log('aggregateReserveTransaction processed.', result);
69
86
 
70
- await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
71
- aggregationDays: AGGREGATE_DAYS,
87
+ result = await chevre.service.aggregation.system.aggregateAuthorizeOrderAction({
88
+ aggregateDurationUnit: 'hours',
89
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
72
90
  excludedProjectId: EXCLUDED_PROJECT_ID
73
91
  })({
74
92
  agregation: aggregationRepo,
75
93
  action: actionRepo
76
94
  });
95
+ console.log('aggregateAuthorizeOrderAction processed.', result);
77
96
 
78
- await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
79
- aggregationDays: AGGREGATE_DAYS,
97
+ result = await chevre.service.aggregation.system.aggregateAuthorizeEventServiceOfferAction({
98
+ aggregateDurationUnit: 'hours',
99
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
80
100
  excludedProjectId: EXCLUDED_PROJECT_ID
81
101
  })({
82
102
  agregation: aggregationRepo,
83
103
  action: actionRepo
84
104
  });
105
+ console.log('aggregateAuthorizeEventServiceOfferAction processed.', result);
85
106
 
86
- await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
87
- aggregationDays: AGGREGATE_DAYS,
107
+ result = await chevre.service.aggregation.system.aggregateAuthorizePaymentAction({
108
+ aggregateDurationUnit: 'hours',
109
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
88
110
  excludedProjectId: EXCLUDED_PROJECT_ID
89
111
  })({
90
112
  agregation: aggregationRepo,
91
113
  action: actionRepo
92
114
  });
115
+ console.log('aggregateAuthorizePaymentAction processed.', result);
93
116
 
94
- await chevre.service.aggregation.system.aggregateUseAction({
95
- aggregationDays: AGGREGATE_DAYS,
117
+ result = await chevre.service.aggregation.system.aggregateUseAction({
118
+ aggregateDurationUnit: 'hours',
119
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
96
120
  excludedProjectId: EXCLUDED_PROJECT_ID
97
121
  })({
98
122
  agregation: aggregationRepo,
99
123
  action: actionRepo
100
124
  });
125
+ console.log('aggregateUseAction processed.', result);
101
126
 
102
- await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
103
- aggregationDays: AGGREGATE_DAYS,
127
+ result = await chevre.service.aggregation.system.aggregateCheckMovieTicketAction({
128
+ aggregateDurationUnit: 'hours',
129
+ aggregationCount: AGGREGATE_DAYS * ONE_DAY_IN_HOURS,
104
130
  excludedProjectId: EXCLUDED_PROJECT_ID
105
131
  })({
106
132
  agregation: aggregationRepo,
107
133
  action: actionRepo
108
134
  });
135
+ console.log('aggregateCheckMovieTicketAction processed.', result);
109
136
  }
110
137
 
111
138
  main()
@@ -0,0 +1,60 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ export async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
8
+
9
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
10
+ const transactionRepo = new chevre.repository.Transaction(mongoose.connection);
11
+
12
+ for (const typeOf of [
13
+ chevre.factory.transactionType.PlaceOrder,
14
+ chevre.factory.transactionType.ReturnOrder,
15
+ chevre.factory.transactionType.MoneyTransfer
16
+ ]) {
17
+ const count = await transactionRepo.count({
18
+ typeOf,
19
+ statuses: [
20
+ chevre.factory.transactionStatusType.Canceled,
21
+ chevre.factory.transactionStatusType.Confirmed,
22
+ chevre.factory.transactionStatusType.Expired
23
+ ],
24
+ tasksExportationStatuses: [
25
+ chevre.factory.transactionTasksExportationStatus.Exporting,
26
+ chevre.factory.transactionTasksExportationStatus.Unexported
27
+ ],
28
+ endThrough: new Date()
29
+ });
30
+ console.log('count:', count, typeOf);
31
+ }
32
+
33
+ for (const typeOf of [
34
+ chevre.factory.assetTransactionType.CancelReservation,
35
+ chevre.factory.assetTransactionType.MoneyTransfer,
36
+ chevre.factory.assetTransactionType.Pay,
37
+ chevre.factory.assetTransactionType.Refund,
38
+ chevre.factory.assetTransactionType.RegisterService,
39
+ chevre.factory.assetTransactionType.Reserve
40
+ ]) {
41
+ const count = await assetTransactionRepo.count({
42
+ typeOf,
43
+ statuses: [
44
+ chevre.factory.transactionStatusType.Canceled,
45
+ chevre.factory.transactionStatusType.Confirmed,
46
+ chevre.factory.transactionStatusType.Expired
47
+ ],
48
+ tasksExportationStatuses: [
49
+ chevre.factory.transactionTasksExportationStatus.Exporting,
50
+ chevre.factory.transactionTasksExportationStatus.Unexported
51
+ ],
52
+ endThrough: new Date()
53
+ });
54
+ console.log('count:', count, typeOf);
55
+ }
56
+ }
57
+
58
+ main()
59
+ .then()
60
+ .catch(console.error);
@@ -197,7 +197,10 @@ async function main() {
197
197
  }
198
198
  ]);
199
199
  console.log(result);
200
- console.log('upsertedIds:', (Array.isArray(result?.result.upserted)) ? result?.result.upserted.map((u: any) => u._id) : []);
200
+ console.log('upsertedIds:', (Array.isArray(result?.getUpsertedIds()))
201
+ ? result?.getUpsertedIds()
202
+ .map((u: any) => u._id)
203
+ : []);
201
204
  }
202
205
 
203
206
  main()
@@ -1,4 +1,5 @@
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';
@@ -6,12 +7,19 @@ import { chevre } from '../../../lib/index';
6
7
  // const project = { id: String(process.env.PROJECT_ID) };
7
8
 
8
9
  async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
11
 
11
12
  const taskRepo = new chevre.repository.Task(mongoose.connection);
12
13
 
13
14
  const result = await taskRepo.deleteByName({
14
- name: <any>'deleteAuthorization'
15
+ name: chevre.factory.taskName.OrderProgramMembership,
16
+ status: { $eq: chevre.factory.taskStatus.Ready }
17
+ // runsAt: {
18
+ // $gte: moment('2023-05-20T00:00:00Z')
19
+ // .toDate(),
20
+ // $lte: moment('2023-12-20T00:00:00Z')
21
+ // .toDate()
22
+ // }
15
23
  });
16
24
 
17
25
  console.log('deleted', result);
@@ -21,11 +21,10 @@ async function main() {
21
21
  id: project.id,
22
22
  typeOf: chevre.factory.organizationType.Project
23
23
  },
24
- locationBranchCode: '120',
25
- importFrom: moment()
24
+ locationBranchCode: '018',
25
+ importFrom: moment('2023-05-17T02:45:00.214Z')
26
26
  .toDate(),
27
- importThrough: moment()
28
- .add(1, 'day')
27
+ importThrough: moment('2023-05-20T02:45:00.214Z')
29
28
  .toDate(),
30
29
  saveMovieTheater: false,
31
30
  saveScreeningEventSeries: false
@@ -0,0 +1,85 @@
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 orderRepo = new chevre.repository.Order(mongoose.connection);
15
+
16
+ const cursor = orderRepo.getCursor(
17
+ {
18
+ // 'project.id': { $eq: project.id },
19
+ // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
20
+ orderDate: {
21
+ $gte: moment()
22
+ .add(-1, 'months')
23
+ .toDate()
24
+ }
25
+ },
26
+ {
27
+ paymentMethods: 1,
28
+ project: 1,
29
+ orderDate: 1
30
+ }
31
+ );
32
+ console.log('movies found');
33
+
34
+ const additionalPropertyNames: string[] = [];
35
+ const projectIds: string[] = [];
36
+ const unexpextedprojectIds: string[] = [];
37
+
38
+ let i = 0;
39
+ await cursor.eachAsync(async (doc) => {
40
+ i += 1;
41
+ const order: chevre.factory.order.IOrder = doc.toObject();
42
+
43
+ const additionalPropertyNamesOnOrder = order.paymentMethods.reduce<string[]>(
44
+ (a, b) => {
45
+ if (Array.isArray(b.additionalProperty)) {
46
+ return [...a, ...b.additionalProperty.map((p) => p.name)];
47
+ } else {
48
+ return a;
49
+ }
50
+ },
51
+ []
52
+ );
53
+ if (Array.isArray(additionalPropertyNamesOnOrder) && additionalPropertyNamesOnOrder.length > 0) {
54
+ console.log(
55
+ additionalPropertyNamesOnOrder.join(','),
56
+ additionalPropertyNamesOnOrder.length,
57
+ 'additionalPropertyNamesOnOrder found',
58
+ order.project.id,
59
+ order.id,
60
+ order.orderDate
61
+ );
62
+ additionalPropertyNames.push(...additionalPropertyNamesOnOrder);
63
+ projectIds.push(order.project.id);
64
+ additionalPropertyNamesOnOrder.forEach((name) => {
65
+ if (!name.match(/^[a-zA-Z]*$/)) {
66
+ // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
67
+ unexpextedprojectIds.push(order.project.id);
68
+ }
69
+ // tslint:disable-next-line:no-magic-numbers
70
+ if (name.length < 5) {
71
+ // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
72
+ unexpextedprojectIds.push(order.project.id);
73
+ }
74
+ });
75
+ }
76
+ });
77
+ console.log(i, 'orders checked');
78
+ console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
79
+ console.log('projectIds:', [...new Set(projectIds)]);
80
+ console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
81
+ }
82
+
83
+ main()
84
+ .then()
85
+ .catch(console.error);
@@ -68,7 +68,8 @@ async function main() {
68
68
  },
69
69
  validateEvent: false,
70
70
  validateEventOfferPeriod: false,
71
- validateAppliesToMovieTicket: true
71
+ validateAppliesToMovieTicket: true,
72
+ disablePendingReservations: true
72
73
  })({
73
74
  stockHolder: itemAvailabilityRepo,
74
75
  event: eventRepo,
@@ -10,16 +10,19 @@ async function main() {
10
10
 
11
11
  const taskRepo = new chevre.repository.Task(mongoose.connection);
12
12
 
13
- const result = await taskRepo.saveMany([{
14
- name: chevre.factory.taskName.TriggerWebhook,
15
- runsAt: new Date(),
16
- data: {},
17
- executionResults: [],
18
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
19
- numberOfTried: 0,
20
- remainingNumberOfTries: 1,
21
- status: chevre.factory.taskStatus.Ready
22
- }]);
13
+ const result = await taskRepo.saveMany(
14
+ [{
15
+ name: chevre.factory.taskName.TriggerWebhook,
16
+ runsAt: new Date(),
17
+ data: {},
18
+ executionResults: [],
19
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
20
+ numberOfTried: 0,
21
+ remainingNumberOfTries: 1,
22
+ status: chevre.factory.taskStatus.Ready
23
+ }],
24
+ { emitImmediately: false }
25
+ );
23
26
 
24
27
  console.log(result, 'tasks saved');
25
28
  }
@@ -0,0 +1,36 @@
1
+ // tslint:disable:no-console
2
+ import * as moment from 'moment-timezone';
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 taskRepo = new chevre.repository.Task(mongoose.connection);
11
+
12
+ const tasks = <chevre.factory.task.ITask<chevre.factory.taskName.ConfirmPayTransaction>[]>await taskRepo.search({
13
+ // limit: 100,
14
+ // page: 1,
15
+ name: {
16
+ $in: [chevre.factory.taskName.ConfirmPayTransaction]
17
+ // $nin: [
18
+ // chevre.factory.taskName.ImportEventsFromCOA,
19
+ // chevre.factory.taskName.ImportEventCapacitiesFromCOA
20
+ // ]
21
+ },
22
+ statuses: [chevre.factory.taskStatus.Aborted],
23
+ runsFrom: moment('2023-05-02T22:00:00Z')
24
+ .toDate(),
25
+ sort: { runsAt: chevre.factory.sortType.Ascending }
26
+ });
27
+ console.log(tasks.map((task) => `${task.project.id},${task.id},${task.name},${moment(task.runsAt)
28
+ .tz('Asia/Tokyo')
29
+ .format('YYYY-MM-DDTHH:mm:ssZ')},"${task.data.object[0]?.transactionNumber}"`)
30
+ .join('\n'));
31
+ console.log(tasks.length);
32
+ }
33
+
34
+ main()
35
+ .then(console.log)
36
+ .catch(console.error);
@@ -4,17 +4,53 @@ import * as mongoose from 'mongoose';
4
4
  import { chevre } from '../../../lib/index';
5
5
 
6
6
  // const project = { id: String(process.env.PROJECT_ID) };
7
+ const orderNumbers = ['TTT9-4703865-8892744', 'TTT9-4703865-8398074', 'SSK6-4815238-3010844'];
7
8
 
8
9
  async function main() {
9
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
11
 
11
12
  const orderRepo = new chevre.repository.Order(mongoose.connection);
12
13
 
14
+ const reservatioForIds = await orderRepo.searchReservationForIdsByOrderNumbers({
15
+ orderNumber: { $in: orderNumbers }
16
+ });
17
+ console.log('reservatioForIds found', reservatioForIds);
18
+ console.log(reservatioForIds.length, 'reservatioForIds found');
19
+
13
20
  const reservationNumbers = await orderRepo.searchReservationNumbersByOrderNumbers({
14
- orderNumber: { $in: ['CIN5-8118459-9364668', 'CIN7-9119652-8987979', 'SSK1-3992448-6733563'] }
21
+ orderNumber: { $in: orderNumbers }
15
22
  });
16
23
  console.log('reservationNumbers found', reservationNumbers);
17
24
  console.log(reservationNumbers.length, 'reservationNumbers found');
25
+
26
+ const offers = await orderRepo.searchAcceptedOffersByOrderNumbers({
27
+ orderNumber: { $in: orderNumbers }
28
+ });
29
+ console.log('offers found', offers);
30
+ console.log(offers.length, 'offers found');
31
+
32
+ const movieTickets: any[] = [];
33
+ offers.forEach((offer) => {
34
+ const movieTicketTypeChargeSpecExists = offer.priceSpecification.priceComponent.some((component) => {
35
+ return component.typeOf === chevre.factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
36
+ });
37
+ if (movieTicketTypeChargeSpecExists) {
38
+ offer.priceSpecification.priceComponent.forEach((component) => {
39
+ if (component.typeOf === chevre.factory.priceSpecificationType.UnitPriceSpecification) {
40
+ if (Array.isArray(component.appliesToMovieTicket)) {
41
+ component.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
42
+ movieTickets.push({
43
+ identifier: appliesToMovieTicket.identifier,
44
+ paymentMethodType: appliesToMovieTicket.serviceOutput.typeOf,
45
+ offerId: offer.id
46
+ });
47
+ });
48
+ }
49
+ }
50
+ });
51
+ }
52
+ });
53
+ console.log('movieTickets found', movieTickets);
18
54
  }
19
55
 
20
56
  main()
@@ -0,0 +1,32 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
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 sellerRepo = new chevre.repository.Seller(mongoose.connection);
12
+ const sellers = await sellerRepo.search({
13
+ hasMerchantReturnPolicy: { itemCondition: { id: { $eq: '646dc7848b3c1437d43dbfeb' } } }
14
+ });
15
+ console.log('sellers:', sellers);
16
+
17
+ const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
18
+ const reserveTransactions = await assetTransactionRepo.search({
19
+ limit: 1,
20
+ typeOf: chevre.factory.assetTransactionType.Reserve,
21
+ object: {
22
+ reservationFor: { id: { $eq: 'xxx' } }
23
+ }
24
+ });
25
+ console.log('reserveTransactions:', reserveTransactions);
26
+ }
27
+
28
+ main()
29
+ .then(() => {
30
+ console.log('success!');
31
+ })
32
+ .catch(console.error);
@@ -0,0 +1,44 @@
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 actions = <chevre.factory.action.transfer.send.message.email.IAction[]>await actionRepo.search(
13
+ {
14
+ limit: 1000,
15
+ page: 1,
16
+ typeOf: { $eq: chevre.factory.actionType.SendAction },
17
+ object: {
18
+ typeOf: { $eq: chevre.factory.creativeWorkType.EmailMessage }
19
+ }
20
+ // startFrom: moment()
21
+ // .add(-20, 'days')
22
+ // .toDate(),
23
+ // startThrough: moment()
24
+ // .add(-19, 'days')
25
+ // .toDate(),
26
+ },
27
+ ['project', '_id', 'object', 'purpose'],
28
+ []
29
+ );
30
+ const maxLenght = Math.max(...actions.map((action) => {
31
+ return (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
32
+ }));
33
+ actions.forEach((action) => {
34
+ const length = (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
35
+ if (typeof length !== 'number') {
36
+ throw new Error(`${action.project.id},${action.id},${action.purpose?.typeOf},${action.purpose?.orderNumber},${action.object.text?.length}`);
37
+ }
38
+ });
39
+ console.log('maxLenght:', maxLenght);
40
+ }
41
+
42
+ main()
43
+ .then(console.log)
44
+ .catch(console.error);
@@ -0,0 +1,26 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const taskRepo = new chevre.repository.Task(mongoose.connection);
10
+ const result = await taskRepo.executeTasks({
11
+ now: new Date(),
12
+ delayInSeconds: 60,
13
+ limit: 1,
14
+ name: {
15
+ $nin: [
16
+ chevre.factory.taskName.ImportEventCapacitiesFromCOA,
17
+ chevre.factory.taskName.ImportEventsFromCOA
18
+ ]
19
+ }
20
+ });
21
+ console.log(result);
22
+ }
23
+
24
+ main()
25
+ .then(console.log)
26
+ .catch(console.error);
@@ -11,7 +11,7 @@ async function main() {
11
11
 
12
12
  const projectRepo = new chevre.repository.Project(mongoose.connection);
13
13
  const productRepo = new chevre.repository.Product(mongoose.connection);
14
- const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.userPoolIdNew });
14
+ const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.settings.userPoolIdNew });
15
15
 
16
16
  const result = await findCreditCard({
17
17
  project: { id: project.id },
@@ -19,7 +19,7 @@ async function main() {
19
19
  });
20
20
  await redisClient.connect();
21
21
 
22
- const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.userPoolIdNew });
22
+ const personRepo = new chevre.repository.Person({ userPoolId: chevre.settings.settings.userPoolIdNew });
23
23
  const actionRepo = new chevre.repository.Action(mongoose.connection);
24
24
  const accountRepo = new chevre.repository.Account(mongoose.connection);
25
25
  const accountingReportRepo = new chevre.repository.AccountingReport(mongoose.connection);
@@ -0,0 +1,40 @@
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 result = await chevre.service.transaction.returnOrder.start({
12
+ project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
13
+ expiresInSeconds: 60,
14
+ agent: { id: 'xxx', typeOf: chevre.factory.creativeWorkType.WebApplication },
15
+ object: {
16
+ order: [{
17
+ confirmationNumber: '99916',
18
+ orderNumber: 'TTT2-8507485-9273468'
19
+ }],
20
+ reason: chevre.factory.transaction.returnOrder.Reason.Customer
21
+ },
22
+ seller: {
23
+ id: 'xxx'
24
+ }
25
+ })({
26
+ event: new chevre.repository.Event(mongoose.connection),
27
+ merchantReturnPolicy: new chevre.repository.MerchantReturnPolicy(mongoose.connection),
28
+ offer: new chevre.repository.Offer(mongoose.connection),
29
+ offerItemCondition: new chevre.repository.OfferItemCondition(mongoose.connection),
30
+ order: new chevre.repository.Order(mongoose.connection),
31
+ reservation: new chevre.repository.Reservation(mongoose.connection),
32
+ seller: new chevre.repository.Seller(mongoose.connection),
33
+ transaction: new chevre.repository.Transaction(mongoose.connection)
34
+ });
35
+ console.log(result);
36
+ }
37
+
38
+ main()
39
+ .then(console.log)
40
+ .catch(console.error);