@chevre/domain 23.2.0 → 24.0.0-alpha.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 (240) hide show
  1. package/lib/chevre/index.d.ts +2 -1
  2. package/lib/chevre/index.js +3 -1
  3. package/lib/chevre/repo/assetTransaction.d.ts +1 -1
  4. package/lib/chevre/repo/identityProvider.d.ts +4 -4
  5. package/lib/chevre/repo/potentialAction.d.ts +4 -4
  6. package/lib/chevre/repo/seller.d.ts +8 -8
  7. package/lib/chevre/repo/task.d.ts +25 -28
  8. package/lib/chevre/repo/transaction.d.ts +5 -5
  9. package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +3 -2
  10. package/lib/chevre/service/assetTransaction/reserve/start/factory/addOffers2seat.d.ts +14 -0
  11. package/lib/chevre/service/assetTransaction/reserve/start/factory/addOffers2seat.js +63 -0
  12. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  13. package/lib/chevre/service/offer.d.ts +0 -12
  14. package/lib/chevre/service/offer.js +0 -37
  15. package/lib/chevre/service/task.d.ts +1 -1
  16. package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.d.ts +2 -1
  17. package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +2 -1
  18. package/lib/chevre/service/taskHandler.d.ts +2 -20
  19. package/lib/chevre/settings.d.ts +1 -2
  20. package/lib/chevre/settings.js +1 -3
  21. package/lib/chevre/taskSettings.d.ts +58 -0
  22. package/package.json +14 -16
  23. package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +0 -76
  24. package/example/src/chevre/actions/checkAcceptPayActions.ts +0 -60
  25. package/example/src/chevre/actions/checkAuthorizePaymentActions.ts +0 -55
  26. package/example/src/chevre/activateOptionalAggregationSettings.ts +0 -19
  27. package/example/src/chevre/adminIdentities.ts +0 -71
  28. package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +0 -24
  29. package/example/src/chevre/aggregateEventPublicFields.ts +0 -47
  30. package/example/src/chevre/aggregateOfferCatalogItemList.ts +0 -36
  31. package/example/src/chevre/aggregateScreeningEventMaxVersion.ts +0 -36
  32. package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +0 -86
  33. package/example/src/chevre/aggregation/aggregateOrderOfCustomer.ts +0 -138
  34. package/example/src/chevre/aggregation/aggregateOrderOfCustomerGlobally.ts +0 -34
  35. package/example/src/chevre/aggregation/aggregateOrderOfSeatByRoyalCustomers.ts +0 -172
  36. package/example/src/chevre/aggregation/aggregateOrderOnSystem.ts +0 -40
  37. package/example/src/chevre/aggregation/aggregateReservationByProject.ts +0 -79
  38. package/example/src/chevre/aggregation/aggregateSystem.ts +0 -201
  39. package/example/src/chevre/aggregation/aggregateTasks.ts +0 -41
  40. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +0 -71
  41. package/example/src/chevre/aggregation/searchAggregateReservations.ts +0 -33
  42. package/example/src/chevre/assetTransaction/checkPayTransactionsTicketToken.ts +0 -67
  43. package/example/src/chevre/assetTransaction/processReserve.ts +0 -149
  44. package/example/src/chevre/attendIfNotAttended.ts +0 -31
  45. package/example/src/chevre/authorizeEventServiceOffer.ts +0 -122
  46. package/example/src/chevre/categoryCode/checkUniqueness.ts +0 -69
  47. package/example/src/chevre/changeOrderStatus.ts +0 -29
  48. package/example/src/chevre/checkCustomerAttributesLength.ts +0 -109
  49. package/example/src/chevre/checkEventDuration.ts +0 -59
  50. package/example/src/chevre/checkPaymentServiceUniqueness.ts +0 -79
  51. package/example/src/chevre/checkProjectMembers.ts +0 -55
  52. package/example/src/chevre/checkReserveTransactionSizes.ts +0 -46
  53. package/example/src/chevre/cleanActions.ts +0 -23
  54. package/example/src/chevre/cleanReservations.ts +0 -69
  55. package/example/src/chevre/cleanTransactions.ts +0 -39
  56. package/example/src/chevre/concurrentLock/lockOfferRateLimit.ts +0 -64
  57. package/example/src/chevre/concurrentLock/lockTransactionProcess.ts +0 -44
  58. package/example/src/chevre/confirmationNumber/testRandomness.ts +0 -49
  59. package/example/src/chevre/countPotentiallyExportTasks.ts +0 -42
  60. package/example/src/chevre/countTransactions.ts +0 -30
  61. package/example/src/chevre/createProject.ts +0 -19
  62. package/example/src/chevre/createTaskIfNotExistByAlternateName.ts +0 -57
  63. package/example/src/chevre/db/stats.ts +0 -35
  64. package/example/src/chevre/deleteDiscontinuedPeople.ts +0 -153
  65. package/example/src/chevre/deleteDiscontinuedPeopleByFetch.ts +0 -38
  66. package/example/src/chevre/deleteOwnershipInfosByOwnedThrough.ts +0 -79
  67. package/example/src/chevre/deleteStartDatePassedCertainPeriod.ts +0 -27
  68. package/example/src/chevre/deleteTasksByName.ts +0 -30
  69. package/example/src/chevre/emailMessage/createEmailMessageText.ts +0 -63
  70. package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +0 -108
  71. package/example/src/chevre/event/importEventSeriesFromCOAByTitle.ts +0 -83
  72. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +0 -148
  73. package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +0 -121
  74. package/example/src/chevre/event/migrateEventMaximumPhysicalAttendeeCapacity.ts +0 -76
  75. package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +0 -30
  76. package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +0 -106
  77. package/example/src/chevre/eventSeries/unsetVideoFormat.ts +0 -31
  78. package/example/src/chevre/eventSeries/upsertScreeningEventSeriesByVersion.ts +0 -106
  79. package/example/src/chevre/findAnyEventById.ts +0 -24
  80. package/example/src/chevre/findAuthorizePaymentAction.ts +0 -34
  81. package/example/src/chevre/findAvailableChannelMovieTicket.ts +0 -25
  82. package/example/src/chevre/findCheckAction.ts +0 -34
  83. package/example/src/chevre/findCustomerByOrderNumber.ts +0 -19
  84. package/example/src/chevre/findItemListElementByCatalogId.ts +0 -30
  85. package/example/src/chevre/findItemListElementById.ts +0 -23
  86. package/example/src/chevre/findJWTSetting.ts +0 -19
  87. package/example/src/chevre/findOneAvailableHours.ts +0 -39
  88. package/example/src/chevre/findReservationByCode.ts +0 -64
  89. package/example/src/chevre/findSchedule.ts +0 -43
  90. package/example/src/chevre/giveUpStartDatePassedCertainPeriod.ts +0 -56
  91. package/example/src/chevre/identity/getCommonClients.ts +0 -126
  92. package/example/src/chevre/identity/migrateClients2oauth.ts +0 -200
  93. package/example/src/chevre/importCategoryCodesFromCOA.ts +0 -34
  94. package/example/src/chevre/importEventsFromCOA.ts +0 -66
  95. package/example/src/chevre/investigateEvents.ts +0 -86
  96. package/example/src/chevre/investigateTransaction.ts +0 -66
  97. package/example/src/chevre/isPaymentAcceptedBySeller.ts +0 -24
  98. package/example/src/chevre/issuer/adminMemberProgramTiers.ts +0 -55
  99. package/example/src/chevre/issuer/migrateIssuerUrls.ts +0 -62
  100. package/example/src/chevre/issuer/renameIssuerIdentifier.ts +0 -61
  101. package/example/src/chevre/maintenance/checkTransactionStatuses.ts +0 -105
  102. package/example/src/chevre/makeExpiredManyTasks.ts +0 -27
  103. package/example/src/chevre/makeTransactionExpired.ts +0 -28
  104. package/example/src/chevre/member/migrateMemberIdentifier.ts +0 -99
  105. package/example/src/chevre/migrateAuthorizeEventServiceOfferChevre.ts +0 -84
  106. package/example/src/chevre/migrateCancelReservationObject.ts +0 -71
  107. package/example/src/chevre/migrateCognitoUser.ts +0 -153
  108. package/example/src/chevre/migrateCustomerAdditionalProperties.ts +0 -116
  109. package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +0 -101
  110. package/example/src/chevre/migrateIdentities.ts +0 -69
  111. package/example/src/chevre/migrateProjectSettings.ts +0 -64
  112. package/example/src/chevre/migrateRoomAdditionalProperties.ts +0 -118
  113. package/example/src/chevre/migrateRoomSectionAdditionalProperties.ts +0 -121
  114. package/example/src/chevre/note/findNotes.ts +0 -34
  115. package/example/src/chevre/note/upsertNotesByIdentifier.ts +0 -63
  116. package/example/src/chevre/notifyAbortedTasksByEmail.ts +0 -56
  117. package/example/src/chevre/notifyByEmail.ts +0 -43
  118. package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +0 -49
  119. package/example/src/chevre/offerCatalog/upsertOfferCatalogItemsByIdentifier.ts +0 -49
  120. package/example/src/chevre/offerCatalog/upsertOfferCatalogsByIdentifier.ts +0 -51
  121. package/example/src/chevre/offers/checkIncludedInCatalogCount.ts +0 -47
  122. package/example/src/chevre/offers/projectItemListElement.ts +0 -54
  123. package/example/src/chevre/offers/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +0 -51
  124. package/example/src/chevre/offers/searchByOfferCatalogIdWithSortIndex.ts +0 -44
  125. package/example/src/chevre/offers/searchOfferCatalogItemAvailability.ts +0 -68
  126. package/example/src/chevre/offers/upsertOffersByIdentifier.ts +0 -63
  127. package/example/src/chevre/optimizeActions.ts +0 -61
  128. package/example/src/chevre/orderNumber/testRandomness.ts +0 -54
  129. package/example/src/chevre/orders/searchOrders.ts +0 -28
  130. package/example/src/chevre/orders/searchWithUnwoundAcceptedOffers.ts +0 -73
  131. package/example/src/chevre/paymentServices/findPaymentServices.ts +0 -37
  132. package/example/src/chevre/pendingReservation/findEventSeatOffersBySection.ts +0 -46
  133. package/example/src/chevre/person/checkUserPoolClients.ts +0 -120
  134. package/example/src/chevre/person/cleanUpCognitoUsers.ts +0 -140
  135. package/example/src/chevre/person/cleanUpCognitoUsersByFetch.ts +0 -162
  136. package/example/src/chevre/person/cleanUpCreditCard.ts +0 -113
  137. package/example/src/chevre/person/updateProfile.ts +0 -56
  138. package/example/src/chevre/place/adminEntranceGates.ts +0 -69
  139. package/example/src/chevre/place/adminHasPOS.ts +0 -44
  140. package/example/src/chevre/place/aggregateSeatingTypes.ts +0 -29
  141. package/example/src/chevre/place/checkEntranceGatesCount.ts +0 -82
  142. package/example/src/chevre/place/checkSectionCount.ts +0 -27
  143. package/example/src/chevre/place/findRooms.ts +0 -24
  144. package/example/src/chevre/place/findSections.ts +0 -28
  145. package/example/src/chevre/place/findSectionsByRoom.ts +0 -50
  146. package/example/src/chevre/place/migrateSectionIdentifier.ts +0 -92
  147. package/example/src/chevre/place/seatsJson2csv.ts +0 -63
  148. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +0 -41
  149. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +0 -40
  150. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +0 -56
  151. package/example/src/chevre/processAction.ts +0 -44
  152. package/example/src/chevre/processOrder.ts +0 -90
  153. package/example/src/chevre/product/findHasOfferCatalog.ts +0 -31
  154. package/example/src/chevre/productOffer/publishMemberTierToken.ts +0 -92
  155. package/example/src/chevre/project/unsetProjectSettings.ts +0 -73
  156. package/example/src/chevre/projectEventFieldsById.ts +0 -23
  157. package/example/src/chevre/projectFields.ts +0 -28
  158. package/example/src/chevre/projectFieldsById.ts +0 -30
  159. package/example/src/chevre/projectOwnershipInfoFieldsById.ts +0 -24
  160. package/example/src/chevre/pushIncludedInDataCatalog.ts +0 -47
  161. package/example/src/chevre/reExportAction.ts +0 -40
  162. package/example/src/chevre/reIndex.ts +0 -20
  163. package/example/src/chevre/recreateRefundTasks.ts +0 -187
  164. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +0 -33
  165. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +0 -33
  166. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +0 -49
  167. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +0 -49
  168. package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +0 -48
  169. package/example/src/chevre/roles/addAdminPaymentServiceReadPermissionIfNotExists.ts +0 -49
  170. package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +0 -33
  171. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +0 -34
  172. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +0 -34
  173. package/example/src/chevre/roles/addAdminSellerEventOfferIfNotExists.ts +0 -48
  174. package/example/src/chevre/roles/addProjectCreatorRole.ts +0 -48
  175. package/example/src/chevre/roles/assignGlobalRoles.ts +0 -72
  176. package/example/src/chevre/roles/findPermissions.ts +0 -84
  177. package/example/src/chevre/roles/findRoleNames.ts +0 -117
  178. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +0 -34
  179. package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +0 -46
  180. package/example/src/chevre/roles/removePermissionIfExists.ts +0 -34
  181. package/example/src/chevre/saveOfferCatalogItem.ts +0 -40
  182. package/example/src/chevre/saveWebSite.ts +0 -56
  183. package/example/src/chevre/searchAcceptedOfferIds.ts +0 -57
  184. package/example/src/chevre/searchActionsByOrderNumber.ts +0 -29
  185. package/example/src/chevre/searchActionsByPurpose.ts +0 -38
  186. package/example/src/chevre/searchActionsBySameAs.ts +0 -27
  187. package/example/src/chevre/searchAggregateOffers.ts +0 -51
  188. package/example/src/chevre/searchAggregations.ts +0 -50
  189. package/example/src/chevre/searchAuthorizations.ts +0 -36
  190. package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +0 -56
  191. package/example/src/chevre/searchEventHasOfferCatalog.ts +0 -43
  192. package/example/src/chevre/searchEventSeats.ts +0 -45
  193. package/example/src/chevre/searchIdsByReservationNumber.ts +0 -16
  194. package/example/src/chevre/searchMembers.ts +0 -55
  195. package/example/src/chevre/searchOfferCatalogItemListElement.ts +0 -26
  196. package/example/src/chevre/searchOffers.ts +0 -68
  197. package/example/src/chevre/searchProducts.ts +0 -28
  198. package/example/src/chevre/searchProjects.ts +0 -36
  199. package/example/src/chevre/searchReservationsByOrder.ts +0 -42
  200. package/example/src/chevre/searchSellersByAggregate.ts +0 -33
  201. package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +0 -31
  202. package/example/src/chevre/seller/adminMakesOffer.ts +0 -113
  203. package/example/src/chevre/sendEmailMessage.ts +0 -60
  204. package/example/src/chevre/sendGrid/filterEmailActivity.ts +0 -31
  205. package/example/src/chevre/settings/addOrderNumberSetting.ts +0 -44
  206. package/example/src/chevre/settings/addTransactionNumberSetting.ts +0 -40
  207. package/example/src/chevre/stockHolder/findSeatsBySection.ts +0 -59
  208. package/example/src/chevre/stockHolder/getSize.ts +0 -97
  209. package/example/src/chevre/stockHolder/projectPendingReservation.ts +0 -43
  210. package/example/src/chevre/stockHolder/searchSeats.ts +0 -61
  211. package/example/src/chevre/task/countPotentiallyRunning.ts +0 -41
  212. package/example/src/chevre/task/countTasks.ts +0 -51
  213. package/example/src/chevre/task/deleteRunsAtPassedCertainPeriod.ts +0 -43
  214. package/example/src/chevre/task/deleteUnexpectedTasks.ts +0 -23
  215. package/example/src/chevre/task/emitRunning.ts +0 -89
  216. package/example/src/chevre/transaction/processPlaceOrder.ts +0 -57
  217. package/example/src/chevre/transaction/processReturnOrder.ts +0 -43
  218. package/example/src/chevre/transaction/startExportTasks.ts +0 -21
  219. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +0 -23
  220. package/example/src/chevre/transactionNumber/testRandomness.ts +0 -42
  221. package/example/src/chevre/unsetUnnecessaryFields.ts +0 -35
  222. package/example/src/chevre/updateEventPartiallyById.ts +0 -22
  223. package/example/src/chevre/updateProjectAggregateReservation.ts +0 -21
  224. package/example/src/chevre/validateCheckMovieTicketActions.ts +0 -70
  225. package/example/src/customSearch.ts +0 -48
  226. package/example/src/duration.ts +0 -22
  227. package/example/src/fetch.ts +0 -45
  228. package/example/src/moment.ts +0 -22
  229. package/example/src/mongoConnectionList.ts +0 -81
  230. package/example/src/mvtkMessage.ts +0 -11
  231. package/example/src/objectId.ts +0 -12
  232. package/example/src/redisClientList.ts +0 -80
  233. package/example/src/redisMulti.ts +0 -63
  234. package/example/src/regex.ts +0 -31
  235. package/example/src/signPayload.ts +0 -50
  236. package/example/src/verifyToken.ts +0 -44
  237. package/lib/chevre/repo/mongoose/onIndexCreated.d.ts +0 -2
  238. package/lib/chevre/repo/mongoose/onIndexCreated.js +0 -10
  239. package/lib/chevre/settings/aggregation.d.ts +0 -35
  240. /package/lib/chevre/{settings/aggregation.js → taskSettings.js} +0 -0
@@ -1,105 +0,0 @@
1
- // tslint:disable:no-console
2
- import mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
7
-
8
- // tslint:disable-next-line:max-func-body-length
9
- async function main() {
10
- const now = new Date();
11
- console.log('--------', 'aggregating...', ' --------', now);
12
-
13
- const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
14
- const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
15
- const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
16
-
17
- // {status:"InProgress"}を確認
18
- // {"tasksExportAction.actionStatus":{$ne:"CompletedActionStatus"}}を確認
19
-
20
- for (const transactionType of [
21
- chevre.factory.transactionType.PlaceOrder,
22
- chevre.factory.transactionType.ReturnOrder
23
- ]) {
24
- const inProgressCount = await transactionRepo.count({
25
- limit: 1000,
26
- status: { $in: [chevre.factory.transactionStatusType.InProgress] },
27
- typeOf: transactionType
28
- });
29
- console.log(transactionType, 'inProgressCount:', inProgressCount.count, now);
30
-
31
- const unCompletedTasksExportCount = await transactionRepo.count({
32
- limit: 1000,
33
- tasksExportAction: {
34
- actionStatus: {
35
- $in: [
36
- chevre.factory.actionStatusType.ActiveActionStatus,
37
- chevre.factory.actionStatusType.CanceledActionStatus,
38
- chevre.factory.actionStatusType.FailedActionStatus,
39
- chevre.factory.actionStatusType.PotentialActionStatus
40
- ]
41
- }
42
- },
43
- typeOf: transactionType
44
- });
45
- console.log(transactionType, 'unCompletedTasksExportCount:', unCompletedTasksExportCount.count, now);
46
- }
47
-
48
- for (const assetTransactionType of [
49
- chevre.factory.assetTransactionType.Pay,
50
- chevre.factory.assetTransactionType.Refund,
51
- chevre.factory.assetTransactionType.Reserve,
52
- chevre.factory.assetTransactionType.CancelReservation
53
- ]) {
54
- const inProgressCount = await assetTransactionRepo.count({
55
- limit: 1000,
56
- status: { $in: [chevre.factory.transactionStatusType.InProgress] },
57
- typeOf: <any>assetTransactionType
58
- });
59
- console.log(assetTransactionType, 'inProgressCount:', inProgressCount.count, now);
60
-
61
- const unCompletedTasksExportCount = await assetTransactionRepo.count({
62
- limit: 1000,
63
- tasksExportAction: {
64
- actionStatus: {
65
- $in: [
66
- chevre.factory.actionStatusType.ActiveActionStatus,
67
- chevre.factory.actionStatusType.CanceledActionStatus,
68
- chevre.factory.actionStatusType.FailedActionStatus,
69
- chevre.factory.actionStatusType.PotentialActionStatus
70
- ]
71
- }
72
- },
73
- typeOf: <any>assetTransactionType
74
- });
75
- console.log(assetTransactionType, 'unCompletedTasksExportCount:', unCompletedTasksExportCount.count, now);
76
- }
77
-
78
- const readyTaskCount = await taskRepo.count({
79
- limit: 100,
80
- statuses: [
81
- chevre.factory.taskStatus.Ready,
82
- chevre.factory.taskStatus.Running
83
- ],
84
- name: {
85
- $nin: [
86
- chevre.factory.taskName.ImportEventCapacitiesFromCOA,
87
- chevre.factory.taskName.ImportEventsFromCOA,
88
- chevre.factory.taskName.ImportOffersFromCOA
89
- ]
90
- },
91
- runsThrough: now
92
- });
93
- console.log('readyTaskCount:', readyTaskCount.count, now);
94
- }
95
-
96
- const INTERVAL_MS = 60000;
97
- // const INTERVAL_MS = 5000;
98
- setInterval(
99
- () => {
100
- main()
101
- .then()
102
- .catch(console.error);
103
- },
104
- INTERVAL_MS
105
- );
@@ -1,27 +0,0 @@
1
- // tslint:disable:no-implicit-dependencies no-console
2
- import { chevre } from '../../../lib/index';
3
-
4
- import moment from 'moment';
5
- import * as mongoose from 'mongoose';
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 taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
13
-
14
- const expiresLt = moment()
15
- .add(-1, 'hour')
16
- .toDate();
17
- const result = await taskRepo.makeExpiredMany({
18
- expiresLt
19
- });
20
- console.log('result:', result);
21
- }
22
-
23
- main()
24
- .then(() => {
25
- console.log('success!');
26
- })
27
- .catch(console.error);
@@ -1,28 +0,0 @@
1
- // tslint:disable:no-console
2
- import moment from 'moment';
3
- import 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 transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
13
-
14
- const result = await transactionRepo.makeOneExpiredIfExists({
15
- expires: {
16
- $lt: moment()
17
- // tslint:disable-next-line:no-magic-numbers
18
- .add(-60, 'seconds')
19
- .toDate()
20
- }
21
- });
22
-
23
- console.log('result:', result);
24
- }
25
-
26
- main()
27
- .then()
28
- .catch(console.error);
@@ -1,99 +0,0 @@
1
- // tslint:disable:no-console
2
- // import moment from 'moment';
3
- import 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
- const identifierMap = [
10
- {
11
- id: '7divuoimobsfgq95tp1csorjqq',
12
- identifier: 'SmartTheaterTXNMember'
13
- },
14
- {
15
- id: '51qbjcfr72h62m06vtv5kkhgje',
16
- identifier: 'SmartTheaterTXN'
17
- },
18
- {
19
- id: 'ckevmf3fueqcunnideu6artt',
20
- identifier: 'SmartTheaterPOS'
21
- },
22
- {
23
- id: '3eo6okferrsdpfd9j2ce1iv9k7',
24
- identifier: 'SmartTheaterTVM'
25
- }
26
- ];
27
-
28
- // tslint:disable-next-line:max-func-body-length
29
- async function main() {
30
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
31
-
32
- const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
33
-
34
- const cursor = memberRepo.getCursor(
35
- {
36
- // typeOf: { $eq: chevre.factory.placeType.ScreeningRoom }
37
- 'project.id': { $eq: '*' }
38
- // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
39
- },
40
- {
41
- project: 1,
42
- member: 1
43
- // paymentMethods: 1,
44
- // project: 1,
45
- // orderDate: 1
46
- }
47
- );
48
- console.log('docs found');
49
-
50
- let updated: number = 0;
51
- let i = 0;
52
- await cursor.eachAsync(async (doc) => {
53
- i += 1;
54
- const iamMember: chevre.factory.iam.IMember = doc.toObject();
55
-
56
- const applicationIdentifier = iamMember.member.identifier;
57
- const updatingIdentifier = identifierMap.find(({ id }) => id === iamMember.member.id)?.identifier;
58
- if (typeof updatingIdentifier !== 'string') {
59
- throw new Error(`map not found. ${iamMember.member.name}`);
60
- }
61
- const identifierExists = typeof applicationIdentifier === 'string';
62
-
63
- if (identifierExists) {
64
- if (applicationIdentifier !== updatingIdentifier) {
65
- throw new Error(`unexpected application identifier. ${iamMember.member.name}`);
66
- }
67
-
68
- console.log(
69
- 'identifier exists',
70
- iamMember.project.id,
71
- iamMember.member.name,
72
- applicationIdentifier
73
- );
74
- } else {
75
- console.log(
76
- 'migrating identifier...',
77
- iamMember.project.id,
78
- iamMember.member.name,
79
- updatingIdentifier
80
- );
81
- await memberRepo.updateByMemberId({
82
- project: { id: iamMember.project.id },
83
- member: {
84
- id: iamMember.member.id,
85
- memberOf: iamMember.member.memberOf,
86
- identifier: updatingIdentifier
87
- },
88
- $unset: {}
89
- });
90
- updated += 1;
91
- }
92
- });
93
- console.log(i, 'docs checked');
94
- console.log('updated:', updated);
95
- }
96
-
97
- main()
98
- .then()
99
- .catch(console.error);
@@ -1,84 +0,0 @@
1
- // tslint:disable:no-console
2
- import mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // tslint:disable-next-line:max-func-body-length
7
- async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
-
10
- const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
11
- const cursor = actionRepo.getCursor(
12
- {
13
- // _id: { $eq: '666bf2f1903cf9f62b41ca6e' },
14
- typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
15
- // actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
16
- // startDate: {
17
- // $lte: moment()
18
- // // tslint:disable-next-line:no-magic-numbers
19
- // .add(-180, 'days'),
20
- // $gte: moment()
21
- // // tslint:disable-next-line:no-magic-numbers
22
- // .add(-180, 'days')
23
- // },
24
- 'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
25
- 'instrument.typeOf': { $exists: true, $eq: chevre.factory.assetTransactionType.Reserve }
26
- },
27
- {
28
- __id: 1, startDate: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
29
- }
30
- );
31
- console.log('actions found');
32
-
33
- let i = 0;
34
- let updateCount = 0;
35
- const saveResultCount = 0;
36
- // tslint:disable-next-line:max-func-body-length
37
- await cursor.eachAsync(async (doc) => {
38
- i += 1;
39
- const authorizeAction = <Pick<
40
- chevre.factory.action.authorize.offer.eventService.IAction,
41
- 'id' | 'startDate' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
42
- >>doc.toObject();
43
-
44
- let migrated = false;
45
- if (authorizeAction.instrument.typeOf === chevre.factory.assetTransactionType.COAReserveTransaction) {
46
- migrated = true;
47
- } else {
48
- const pendingTransaction = authorizeAction.object.pendingTransaction;
49
- if (pendingTransaction === undefined) {
50
- migrated = true;
51
- }
52
- }
53
-
54
- if (migrated) {
55
- console.log(
56
- 'already migrated.',
57
- authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate,
58
- i, updateCount, saveResultCount);
59
-
60
- } else {
61
- // optimize action
62
- let unsetResult: any;
63
- unsetResult = await actionRepo.unsetUnnecessaryFields({
64
- filter: { _id: { $eq: authorizeAction.id } },
65
- $unset: {
66
- 'object.pendingTransaction': 1
67
- }
68
- });
69
- updateCount += 1;
70
- console.log(
71
- 'result unset. unsetResult:', unsetResult,
72
- authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate, i,
73
- updateCount, saveResultCount);
74
- }
75
- });
76
-
77
- console.log(i, 'actions checked');
78
- console.log(updateCount, 'actions updated');
79
- console.log(saveResultCount, 'result saved');
80
- }
81
-
82
- main()
83
- .then()
84
- .catch(console.error);
@@ -1,71 +0,0 @@
1
- // tslint:disable:no-console
2
- import mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // tslint:disable-next-line:max-func-body-length
7
- async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
-
10
- const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
11
-
12
- const cursor = assetTransactionRepo.getCursor(
13
- {
14
- typeOf: { $eq: chevre.factory.assetTransactionType.CancelReservation }
15
- // 'project.id': { $ne: EXCLUDED_PROJECT_ID }
16
- },
17
- {}
18
- );
19
- console.log('assetTransactions found');
20
-
21
- let i = 0;
22
- let updateCount = 0;
23
- await cursor.eachAsync(async (doc) => {
24
- i += 1;
25
- const assetTransaction: chevre.factory.assetTransaction.cancelReservation.ITransaction = doc.toObject();
26
-
27
- const alreadyMigrated = assetTransaction.object.typeOf === chevre.factory.reservationType.ReservationPackage
28
- && typeof assetTransaction.object.reservationNumber === 'string'
29
- && assetTransaction.object.reservationNumber.length > 0;
30
-
31
- if (alreadyMigrated) {
32
- console.log(
33
- 'already migrated.',
34
- assetTransaction.project.id, assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, i);
35
- } else {
36
- let reservationNumber: string | undefined;
37
- if (typeof assetTransaction.object.transaction?.transactionNumber === 'string') {
38
- reservationNumber = assetTransaction.object.transaction.transactionNumber;
39
- } else if (typeof assetTransaction.object.reservations?.[0].reservationNumber === 'string') {
40
- reservationNumber = assetTransaction.object.reservations[0].reservationNumber;
41
- }
42
- if (typeof reservationNumber !== 'string') {
43
- console.error(
44
- 'reservationNumber not found.',
45
- assetTransaction.project.id,
46
- assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, i);
47
- throw new Error('reservationNumber not found');
48
- }
49
- console.log(
50
- 'updating assetTransaction...',
51
- assetTransaction.project.id,
52
- assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, reservationNumber, i);
53
- await assetTransactionRepo.migrateObjectReservationNumber({
54
- id: assetTransaction.id,
55
- object: { reservationNumber }
56
- });
57
- updateCount += 1;
58
- console.log(
59
- 'updated.',
60
- assetTransaction.project.id,
61
- assetTransaction.typeOf, assetTransaction.transactionNumber, assetTransaction.startDate, i);
62
- }
63
- });
64
-
65
- console.log(i, 'assetTransactions checked');
66
- console.log(updateCount, 'assetTransactions updated');
67
- }
68
-
69
- main()
70
- .then()
71
- .catch(console.error);
@@ -1,153 +0,0 @@
1
- // tslint:disable:no-console
2
- import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider';
3
- import { fromEnv } from '@aws-sdk/credential-providers';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
8
- export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
9
- const NEW_USERPOOL_PROVIDER_NAME = 'SSKTS';
10
-
11
- // tslint:disable-next-line:max-func-body-length
12
- export async function migrateUser(params: {
13
- id: string;
14
- }): 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
- // 旧会員を取得
23
- let oldPerson: chevre.factory.person.IPerson | undefined;
24
-
25
- try {
26
- const oldPersonRepo = await chevre.repository.Person.createInstance({
27
- userPoolId: USERPOOL_ID_OLD,
28
- cognitoIdentityServiceProvider
29
- });
30
- oldPerson = await oldPersonRepo.findById({ userId: params.id });
31
- console.log('oldPerson found', oldPerson.id, oldPerson.givenName, oldPerson.familyName);
32
- } catch (error) {
33
- let throwsError = true;
34
- if (error instanceof chevre.factory.errors.NotFound) {
35
- // 旧会員が存在しなければ何もしない
36
- throwsError = false;
37
- }
38
-
39
- if (throwsError) {
40
- throw error;
41
- }
42
- }
43
-
44
- if (oldPerson === undefined) {
45
- return;
46
- }
47
-
48
- // create user
49
- const newPersonRepo = await chevre.repository.Person.createInstance({
50
- userPoolId: USERPOOL_ID_NEW,
51
- cognitoIdentityServiceProvider
52
- });
53
- const newUsername = `${NEW_USERPOOL_PROVIDER_NAME}_${oldPerson.id}`;
54
- const newUserId = await new Promise<string>((resolve, reject) => {
55
- newPersonRepo.cognitoIdentityServiceProvider.adminCreateUser(
56
- {
57
- UserPoolId: USERPOOL_ID_NEW,
58
- Username: newUsername,
59
- UserAttributes: [
60
- { Name: 'email_verified', Value: 'true' },
61
- { Name: 'phone_number_verified', Value: 'false' },
62
- { Name: 'phone_number', Value: oldPerson?.telephone },
63
- { Name: 'given_name', Value: oldPerson?.givenName },
64
- { Name: 'family_name', Value: oldPerson?.familyName },
65
- { Name: 'email', Value: oldPerson?.email }
66
- ],
67
- // ValidationData?: AttributeListType;
68
- // TemporaryPassword?: PasswordType;
69
- // ForceAliasCreation?: ForceAliasCreation;
70
- MessageAction: 'SUPPRESS',
71
- DesiredDeliveryMediums: []
72
- // ClientMetadata?: ClientMetadataType;
73
- },
74
- (err, data) => {
75
- if (err) {
76
- console.error('user not created.', err);
77
- reject(err);
78
- } else {
79
- resolve(String(data?.User?.Attributes?.find((a) => a.Name === 'sub')?.Value));
80
- }
81
- }
82
- );
83
- });
84
- console.log('user created.', newUserId);
85
-
86
- // link provider
87
- await new Promise<void>((resolve, reject) => {
88
- newPersonRepo.cognitoIdentityServiceProvider.adminLinkProviderForUser(
89
- {
90
- UserPoolId: USERPOOL_ID_NEW,
91
- DestinationUser: {
92
- ProviderName: 'Cognito',
93
- // ProviderAttributeName: 'userId',
94
- ProviderAttributeValue: newUsername
95
- },
96
- SourceUser: {
97
- ProviderName: NEW_USERPOOL_PROVIDER_NAME,
98
- ProviderAttributeName: 'userId',
99
- ProviderAttributeValue: params.id
100
- }
101
- },
102
- (err, data) => {
103
- if (err) {
104
- console.error('user not linked.', err);
105
- reject(err);
106
- } else {
107
- console.log('user linked.', data);
108
- resolve();
109
- }
110
- });
111
- });
112
-
113
- // disable link provider
114
- await new Promise<void>((resolve, reject) => {
115
- newPersonRepo.cognitoIdentityServiceProvider.adminDisableProviderForUser(
116
- {
117
- UserPoolId: USERPOOL_ID_NEW,
118
- User: {
119
- ProviderName: 'Cognito',
120
- ProviderAttributeName: 'Cognito_Subject',
121
- ProviderAttributeValue: newUsername
122
- }
123
- },
124
- (err, data) => {
125
- if (err) {
126
- console.error('user not disabled password.', err);
127
- reject(err);
128
- } else {
129
- console.log('user linked.', data);
130
- resolve();
131
- }
132
- });
133
- });
134
-
135
- // add to group
136
- await new Promise<void>((resolve, reject) => {
137
- newPersonRepo.cognitoIdentityServiceProvider.adminAddUserToGroup(
138
- {
139
- UserPoolId: USERPOOL_ID_NEW,
140
- Username: newUsername,
141
- GroupName: `${USERPOOL_ID_NEW}_${NEW_USERPOOL_PROVIDER_NAME}`
142
- },
143
- (err, data) => {
144
- if (err) {
145
- console.error('user not added to group.', err);
146
- reject(err);
147
- } else {
148
- console.log('user added to group.', data);
149
- resolve();
150
- }
151
- });
152
- });
153
- }
@@ -1,116 +0,0 @@
1
- // tslint:disable:no-console
2
- // import moment from 'moment';
3
- import 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 additionalPropertyRepo = await chevre.repository.AdditionalProperty.createInstance(mongoose.connection);
15
- const customerRepo = await chevre.repository.Customer.createInstance(mongoose.connection);
16
-
17
- const cursor = customerRepo.getCursor(
18
- {
19
- // typeOf: { $eq: chevre.factory.placeType.ScreeningRoom }
20
- // 'project.id': { $eq: project.id },
21
- // 'project.id': { $ne: EXCLUDED_PROJECT_ID },
22
- },
23
- {
24
- // paymentMethods: 1,
25
- // project: 1,
26
- // orderDate: 1
27
- }
28
- );
29
- console.log('docs found');
30
-
31
- const additionalPropertyNames: string[] = [];
32
- const projectIds: string[] = [];
33
- const unexpextedprojectIds: string[] = [];
34
- let checked: number = 0;
35
- let created: number = 0;
36
-
37
- let i = 0;
38
- await cursor.eachAsync(async (doc) => {
39
- i += 1;
40
- const customer: chevre.factory.customer.ICustomer = doc.toObject();
41
-
42
- const additionalPropertyNamesOnResource = (Array.isArray(customer.additionalProperty))
43
- ? customer.additionalProperty?.map((p) => p.name)
44
- : [];
45
- if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
46
- console.log(
47
- additionalPropertyNamesOnResource.join(','),
48
- additionalPropertyNamesOnResource.length,
49
- 'additionalPropertyNamesOnResource found',
50
- customer.project.id,
51
- customer.branchCode
52
- );
53
- additionalPropertyNames.push(...additionalPropertyNamesOnResource);
54
- projectIds.push(customer.project.id);
55
- additionalPropertyNamesOnResource.forEach((name) => {
56
- if (!name.match(/^[a-zA-Z]*$/)) {
57
- unexpextedprojectIds.push(customer.project.id);
58
- }
59
- // tslint:disable-next-line:no-magic-numbers
60
- if (name.length < 5) {
61
- unexpextedprojectIds.push(customer.project.id);
62
- }
63
- });
64
-
65
- for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
66
- checked += 1;
67
- const existingAdditionalProperties = <{ id: string }[]>await additionalPropertyRepo.projectFields(
68
- {
69
- limit: 1,
70
- project: { id: { $eq: customer.project.id } },
71
- codeValue: { $eq: additionalPropertyNameOnResource },
72
- inCodeSet: { identifier: { $eq: customer.typeOf } }
73
- },
74
- ['id']);
75
- if (existingAdditionalProperties.length === 0) {
76
- const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
77
- project: customer.project,
78
- // id?: string;
79
- typeOf: 'CategoryCode',
80
- codeValue: additionalPropertyNameOnResource,
81
- inCodeSet: {
82
- typeOf: 'CategoryCodeSet',
83
- identifier: customer.typeOf
84
- },
85
- name: { ja: additionalPropertyNameOnResource }
86
- };
87
- await additionalPropertyRepo.save({ attributes: additionalProperty });
88
- created += 1;
89
- console.log(
90
- 'additionalProerty created',
91
- additionalPropertyNameOnResource,
92
- customer.project.id,
93
- customer.branchCode
94
- );
95
- } else {
96
- console.log(
97
- 'additionalProerty existed',
98
- additionalPropertyNameOnResource,
99
- customer.project.id,
100
- customer.branchCode
101
- );
102
- }
103
- }
104
- }
105
- });
106
- console.log(i, 'places checked');
107
- console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
108
- console.log('projectIds:', [...new Set(projectIds)]);
109
- console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
110
- console.log('checked:', checked);
111
- console.log('created:', created);
112
- }
113
-
114
- main()
115
- .then()
116
- .catch(console.error);