@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,101 +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 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);
@@ -1,69 +0,0 @@
1
- // tslint:disable:no-console
2
- import 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 identityRepo = await chevre.repository.Identity.createInstance(mongoose.connection);
14
-
15
- const cursor = identityRepo.getCursor(
16
- {
17
- // _id: { $eq: '67de46777ec0510590b68922' }
18
- },
19
- {
20
- _id: 1,
21
- about: 1,
22
- project: 1,
23
- typeOf: 1,
24
- issuedBy: 1
25
- }
26
- );
27
- console.log('docs found');
28
-
29
- let i = 0;
30
- let updateCount = 0;
31
- await cursor.eachAsync(async (doc) => {
32
- i += 1;
33
- const identity: Pick<
34
- chevre.factory.creativeWork.certification.webApplication.ICertification,
35
- 'about' | 'project' | 'typeOf' | 'id' | 'issuedBy'
36
- > = doc.toObject();
37
-
38
- const issuedBy = identity.issuedBy;
39
- const numIssuedBy = (Array.isArray(identity.issuedBy)) ? identity.issuedBy.length : 1;
40
-
41
- // console.log(
42
- // 'alreadyMigrated?', identity.project.id, identity.about.id, numIssuedBy, i);
43
- const alreadyMigrated = Array.isArray(issuedBy);
44
-
45
- if (alreadyMigrated) {
46
- console.log(
47
- 'already migrated.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
48
- } else {
49
- if (typeof identity.id !== 'string') {
50
- throw new Error(`id undefined ${identity.id}`);
51
- }
52
-
53
- await identityRepo.updateIssuedBy2array({
54
- id: identity.id,
55
- issuedBy: [issuedBy]
56
- });
57
- updateCount += 1;
58
- console.log(
59
- 'updated.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
60
- }
61
- });
62
-
63
- console.log(i, 'docs checked');
64
- console.log(updateCount, 'docs updated');
65
- }
66
-
67
- main()
68
- .then()
69
- .catch(console.error);
@@ -1,64 +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 projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
11
-
12
- const cursor = projectRepo.getCursor(
13
- {
14
- // _id: { $eq: 'cinerino' }
15
- },
16
- {
17
- _id: 1,
18
- settings: 1,
19
- typeOf: 1
20
- }
21
- );
22
- console.log('docs found');
23
-
24
- let i = 0;
25
- let updateCount = 0;
26
- await cursor.eachAsync(async (doc) => {
27
- i += 1;
28
- const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf' | 'settings'> = doc.toObject();
29
-
30
- console.log(
31
- 'alreadyMigrated?', project.id, i);
32
- const includeCustomerAsFindByConfirmationNumberResult = project.settings?.includeCustomerAsFindByConfirmationNumberResult;
33
- let alreadyMigrated = false;
34
- if (typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean') {
35
- alreadyMigrated = true;
36
- }
37
-
38
- if (alreadyMigrated) {
39
- console.log(
40
- 'already migrated.', project.id, i);
41
- } else {
42
- console.log(
43
- 'updating project...',
44
- project.id, i);
45
- await projectRepo.updateById({
46
- id: project.id,
47
- settings: {
48
- includeCustomerAsFindByConfirmationNumberResult: true
49
- }
50
- });
51
- updateCount += 1;
52
- console.log(
53
- 'updated.',
54
- project.id, i);
55
- }
56
- });
57
-
58
- console.log(i, 'docs checked');
59
- console.log(updateCount, 'docs updated');
60
- }
61
-
62
- main()
63
- .then()
64
- .catch(console.error);
@@ -1,118 +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 placeRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
16
-
17
- const cursor = placeRepo.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('places 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 screeningRoom: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
41
-
42
- const additionalPropertyNamesOnResource = (Array.isArray(screeningRoom.additionalProperty))
43
- ? screeningRoom.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
- screeningRoom.project.id,
51
- screeningRoom.branchCode
52
- );
53
- additionalPropertyNames.push(...additionalPropertyNamesOnResource);
54
- projectIds.push(screeningRoom.project.id);
55
- additionalPropertyNamesOnResource.forEach((name) => {
56
- if (!name.match(/^[a-zA-Z]*$/)) {
57
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
58
- unexpextedprojectIds.push(screeningRoom.project.id);
59
- }
60
- // tslint:disable-next-line:no-magic-numbers
61
- if (name.length < 5) {
62
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
63
- unexpextedprojectIds.push(screeningRoom.project.id);
64
- }
65
- });
66
-
67
- for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
68
- checked += 1;
69
- const existingAdditionalProperties = <{ id: string }[]>await additionalPropertyRepo.projectFields(
70
- {
71
- limit: 1,
72
- project: { id: { $eq: screeningRoom.project.id } },
73
- codeValue: { $eq: additionalPropertyNameOnResource },
74
- inCodeSet: { identifier: { $eq: screeningRoom.typeOf } }
75
- },
76
- ['id']);
77
- if (existingAdditionalProperties.length === 0) {
78
- const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
79
- project: screeningRoom.project,
80
- // id?: string;
81
- typeOf: 'CategoryCode',
82
- codeValue: additionalPropertyNameOnResource,
83
- inCodeSet: {
84
- typeOf: 'CategoryCodeSet',
85
- identifier: screeningRoom.typeOf
86
- },
87
- name: { ja: additionalPropertyNameOnResource }
88
- };
89
- await additionalPropertyRepo.save({ attributes: additionalProperty });
90
- created += 1;
91
- console.log(
92
- 'additionalProerty created',
93
- additionalPropertyNameOnResource,
94
- screeningRoom.project.id,
95
- screeningRoom.branchCode
96
- );
97
- } else {
98
- console.log(
99
- 'additionalProerty existed',
100
- additionalPropertyNameOnResource,
101
- screeningRoom.project.id,
102
- screeningRoom.branchCode
103
- );
104
- }
105
- }
106
- }
107
- });
108
- console.log(i, 'places checked');
109
- console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
110
- console.log('projectIds:', [...new Set(projectIds)]);
111
- console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
112
- console.log('checked:', checked);
113
- console.log('created:', created);
114
- }
115
-
116
- main()
117
- .then()
118
- .catch(console.error);
@@ -1,121 +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 placeRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
16
-
17
- const cursor = placeRepo.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('places 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 screeningRoom: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
41
- const sections: Pick<chevre.factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'typeOf'>[] =
42
- screeningRoom.containsPlace;
43
- for (const section of sections) {
44
- const additionalPropertyNamesOnResource = (Array.isArray(section.additionalProperty))
45
- ? section.additionalProperty?.map((p) => p.name)
46
- : [];
47
- if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
48
- console.log(
49
- additionalPropertyNamesOnResource.join(','),
50
- additionalPropertyNamesOnResource.length,
51
- 'additionalPropertyNamesOnResource found',
52
- screeningRoom.project.id,
53
- section.branchCode
54
- );
55
- additionalPropertyNames.push(...additionalPropertyNamesOnResource);
56
- projectIds.push(screeningRoom.project.id);
57
- additionalPropertyNamesOnResource.forEach((name) => {
58
- if (!name.match(/^[a-zA-Z]*$/)) {
59
- // throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
60
- unexpextedprojectIds.push(screeningRoom.project.id);
61
- }
62
- // tslint:disable-next-line:no-magic-numbers
63
- if (name.length < 5) {
64
- // throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
65
- unexpextedprojectIds.push(screeningRoom.project.id);
66
- }
67
- });
68
-
69
- for (const additionalPropertyNameOnResource of additionalPropertyNamesOnResource) {
70
- checked += 1;
71
- const existingAdditionalProperties = <{ id: string }[]>await additionalPropertyRepo.projectFields(
72
- {
73
- limit: 1,
74
- project: { id: { $eq: screeningRoom.project.id } },
75
- codeValue: { $eq: additionalPropertyNameOnResource },
76
- inCodeSet: { identifier: { $eq: section.typeOf } }
77
- },
78
- ['id']);
79
- if (existingAdditionalProperties.length === 0) {
80
- const additionalProperty: chevre.factory.additionalProperty.IAdditionalProperty = {
81
- project: screeningRoom.project,
82
- // id?: string;
83
- typeOf: 'CategoryCode',
84
- codeValue: additionalPropertyNameOnResource,
85
- inCodeSet: {
86
- typeOf: 'CategoryCodeSet',
87
- identifier: section.typeOf
88
- },
89
- name: { ja: additionalPropertyNameOnResource }
90
- };
91
- await additionalPropertyRepo.save({ attributes: additionalProperty });
92
- created += 1;
93
- console.log(
94
- 'additionalProerty created',
95
- additionalPropertyNameOnResource,
96
- screeningRoom.project.id,
97
- section.branchCode
98
- );
99
- } else {
100
- console.log(
101
- 'additionalProerty existed',
102
- additionalPropertyNameOnResource,
103
- screeningRoom.project.id,
104
- section.branchCode
105
- );
106
- }
107
- }
108
- }
109
- }
110
- });
111
- console.log(i, 'places checked');
112
- console.log('additionalPropertyNames:', [...new Set(additionalPropertyNames)]);
113
- console.log('projectIds:', [...new Set(projectIds)]);
114
- console.log('unexpextedprojectIds:', [...new Set(unexpextedprojectIds)]);
115
- console.log('checked:', checked);
116
- console.log('created:', created);
117
- }
118
-
119
- main()
120
- .then()
121
- .catch(console.error);
@@ -1,34 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- // tslint:disable-next-line:max-func-body-length
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
13
- const notes = await noteRepo.findNotes(
14
- {
15
- limit: 10,
16
- page: 1,
17
- project: { id: { $eq: project.id } },
18
- hasDigitalDocumentPermission: {
19
- grantee: {
20
- audienceType: {
21
- $eq: chevre.factory.creativeWork.noteDigitalDocument.PermissionGranteeAudienceType.Public
22
- }
23
- }
24
- }
25
- },
26
- ['about', 'identifier']
27
- );
28
- // tslint:disable-next-line:no-null-keyword
29
- console.dir(notes, { depth: null });
30
- }
31
-
32
- main()
33
- .then()
34
- .catch(console.error);
@@ -1,63 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- // tslint:disable-next-line:max-func-body-length
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
13
-
14
- const creatingNote: Pick<
15
- chevre.factory.creativeWork.noteDigitalDocument.INoteAboutProduct,
16
- 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'
17
- > = {
18
- about: {
19
- id: '656038908b1cd5ce629f5992',
20
- typeOf: chevre.factory.product.ProductType.EventService
21
- },
22
- creator: { id: 'xxx', typeOf: chevre.factory.personType.Person },
23
- identifier: 'abcdefgh',
24
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
25
- provider: { id: project.id, typeOf: chevre.factory.organizationType.Project },
26
- text: 'sample note text...',
27
- version: '1',
28
- hasDigitalDocumentPermission: []
29
-
30
- };
31
- const createResult = await noteRepo.upsertNotesByIdentifier(
32
- [
33
- {
34
- $set: creatingNote
35
- // $unset: {}
36
- }
37
- // {
38
- // $set: creatingNote
39
- // }
40
- ],
41
- { update: false }
42
- );
43
- // tslint:disable-next-line:no-null-keyword
44
- console.dir(createResult, { depth: null });
45
-
46
- const updateResult = await noteRepo.upsertNotesByIdentifier(
47
- [
48
- {
49
- $set: creatingNote
50
- }
51
- // {
52
- // $set: creatingNote
53
- // }
54
- ],
55
- { update: true }
56
- );
57
- // tslint:disable-next-line:no-null-keyword
58
- console.dir(updateResult, { depth: null });
59
- }
60
-
61
- main()
62
- .then()
63
- .catch(console.error);
@@ -1,56 +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 taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
13
- const sendGridCredentials = await chevre.credentials.SendGrid.createInstance({
14
- apiKey: <string>process.env.SENDGRID_API_KEY,
15
- alert: {
16
- sender: {
17
- name: 'xxx',
18
- email: 'xxx'
19
- },
20
- toRecipient: [
21
- { email: 'xxx' }
22
- ]
23
- }
24
- });
25
- const chevreSettings = new chevre.settings.Settings(<any>{
26
- abortedTasksWithoutReport: [
27
- chevre.factory.taskName.ImportEventCapacitiesFromCOA,
28
- chevre.factory.taskName.ImportEventsFromCOA,
29
- chevre.factory.taskName.ImportOffersFromCOA
30
- ]
31
- });
32
-
33
- const result = await (await chevre.service.notification.createService()).notifyAbortedTasksByEmail({
34
- dateAbortedGte: moment()
35
- // tslint:disable-next-line:no-magic-numbers
36
- .add(-10, 'days')
37
- .toDate()
38
- })(
39
- {
40
- task: taskRepo
41
- },
42
- chevreSettings,
43
- {
44
- sendGrid: sendGridCredentials
45
- }
46
- );
47
- // tslint:disable-next-line:no-null-keyword
48
- console.dir(result, { depth: null });
49
- }
50
-
51
- main()
52
- .then(console.log)
53
- .catch((error) => {
54
- // tslint:disable-next-line:no-null-keyword
55
- console.dir(error, { depth: null });
56
- });
@@ -1,43 +0,0 @@
1
- // tslint:disable:no-console
2
- import 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 sendGridCredentials = await chevre.credentials.SendGrid.createInstance({
12
- apiKey: <string>process.env.SENDGRID_API_KEY,
13
- alert: {
14
- sender: {
15
- name: 'sample',
16
- email: String(process.env.SENDGRID_ALERT_SENDER_EMAIL)
17
- },
18
- toRecipient: [
19
- { email: String(process.env.SENDGRID_ALERT_RECIPIENT_EMAIL) }
20
- ]
21
- }
22
- });
23
-
24
- const result = await (await chevre.service.notification.createService()).notifyByEmail({
25
- subject: 'sample',
26
- content: 'sample',
27
- logLevel: 'error'
28
- })(
29
- {},
30
- {
31
- sendGrid: sendGridCredentials
32
- }
33
- );
34
- // tslint:disable-next-line:no-null-keyword
35
- console.dir(result, { depth: null });
36
- }
37
-
38
- main()
39
- .then(console.log)
40
- .catch((error) => {
41
- // tslint:disable-next-line:no-null-keyword
42
- console.dir(error, { depth: null });
43
- });