@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,30 +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
- mongoose.Model.on('index', (...args) => {
9
- console.error('******** index event emitted. ********\n', args);
10
- });
11
-
12
- async function main() {
13
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
14
-
15
- const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
16
-
17
- const { count } = await transactionRepo.count<chevre.factory.transactionType.PlaceOrder>({
18
- limit: 5000,
19
- // page: 1,
20
- // project: { id: { $eq: project.id } },
21
- typeOf: chevre.factory.transactionType.PlaceOrder,
22
- statuses: [chevre.factory.transactionStatusType.InProgress],
23
- startThrough: new Date()
24
- });
25
- console.log('count:', count);
26
- }
27
-
28
- main()
29
- .then()
30
- .catch(console.error);
@@ -1,19 +0,0 @@
1
- // tslint:disable:no-console
2
- import mongoose from 'mongoose';
3
- import { chevre } from '../../../lib/index';
4
-
5
- async function main() {
6
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
7
-
8
- const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
9
- const result = await projectRepo.createById({
10
- id: 'xxx',
11
- typeOf: chevre.factory.organizationType.Project
12
- });
13
- // tslint:disable-next-line:no-null-keyword
14
- console.dir(result, { depth: null });
15
- }
16
-
17
- main()
18
- .then(console.log)
19
- .catch(console.error);
@@ -1,57 +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
- chevre.eventEmitter.task.taskEventEmitter.onTaskStatusChanged((event) => {
9
- console.log('onTaskStatusChanged', event);
10
- });
11
-
12
- async function main() {
13
- const now = new Date();
14
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
15
-
16
- const taskIdentifier: string = `${project.id}:${chevre.factory.taskName.TriggerWebhook}:sample:2025032801`;
17
- const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
18
- const creatingTask = {
19
- alternateName: taskIdentifier,
20
- identifier: taskIdentifier,
21
- name: chevre.factory.taskName.TriggerWebhook,
22
- status: chevre.factory.taskStatus.Ready,
23
- runsAt: now,
24
- remainingNumberOfTries: 1,
25
- numberOfTried: 0,
26
- executionResults: [],
27
- data: {
28
- object: {
29
- sample: 'sample'
30
- },
31
- recipient: {
32
- id: '',
33
- name: 'telemetry',
34
- typeOf: 'WebApplication'
35
- },
36
- target: {
37
- httpMethod: 'POST',
38
- encodingType: 'application/json',
39
- typeOf: 'EntryPoint',
40
- urlTemplate: 'https://smart-theater-telemetry-api.an.r.appspot.com/webhooks/lineNotify'
41
- },
42
- identifier: 'sampleNotificationIdentifier'
43
- // about: {
44
- // id: '67e62b0b28817948355a671c',
45
- // typeOf: 'PlaceOrder'
46
- // }
47
- },
48
- project: { id: project.id, typeOf: <chevre.factory.organizationType.Project>chevre.factory.organizationType.Project }
49
- };
50
- taskRepo.createIfNotExistByAlternateName(creatingTask, { emitImmediately: true });
51
- taskRepo.createIfNotExistByAlternateName(creatingTask, { emitImmediately: true });
52
- console.log('success!');
53
- }
54
-
55
- main()
56
- .then()
57
- .catch(console.error);
@@ -1,35 +0,0 @@
1
- // tslint:disable:no-console
2
- import mongoose from 'mongoose';
3
-
4
- const KILO_BYTES = 1024;
5
- async function main() {
6
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
7
-
8
- let storageStats;
9
- // const stats = await mongoose.connection.db.collection('tasks')
10
- // .stats({
11
- // scale: KILO_BYTES * KILO_BYTES
12
- // });
13
- storageStats = (await mongoose.connection.db.collection('tasks')
14
- .aggregate([{
15
- $collStats: {
16
- storageStats: {
17
- scale: KILO_BYTES * KILO_BYTES
18
- }
19
- }
20
- }])
21
- .limit(1)
22
- .toArray())
23
- .at(0)?.storageStats;
24
-
25
- console.log('scaleFactor:', storageStats.scaleFactor);
26
- console.log('avgObjSize:', storageStats.avgObjSize);
27
- console.log('count:', storageStats.count);
28
- console.log('size:', storageStats.size);
29
- }
30
-
31
- main()
32
- .then(() => {
33
- console.log('success!');
34
- })
35
- .catch(console.error);
@@ -1,153 +0,0 @@
1
- // tslint:disable:no-console
2
- import moment from 'moment';
3
- import mongoose from 'mongoose';
4
- import { call as deletePerson } from '../../../lib/chevre/service/task/deletePerson';
5
- import { chevre } from '../../../lib/index';
6
-
7
- // tslint:disable-next-line:max-func-body-length
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
12
- const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
13
- if (typeof setting?.userPoolIdNew !== 'string') {
14
- throw new chevre.factory.errors.NotFound('setting.userPoolIdNew');
15
- }
16
-
17
- const DISCONTINUE_PEOPLE_PROJECT = process.env.USE_DISCONTINUE_PEOPLE_PROJECT;
18
- if (typeof DISCONTINUE_PEOPLE_PROJECT === 'string' && DISCONTINUE_PEOPLE_PROJECT.length > 0) {
19
- const ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
20
- // const deletingOwnershipInfos = (await ownershipInfoRepo.projectFields({
21
- // limit: NUM_TASKS,
22
- // page: 1,
23
- // sort: { ownedFrom: chevre.factory.sortType.Ascending },
24
- // project: { id: { $eq: DISCONTINUE_PEOPLE_PROJECT } },
25
- // ownedBy: {
26
- // typeOf: { $eq: chevre.factory.personType.Person }
27
- // },
28
- // typeOfGood: {
29
- // issuedThrough: {
30
- // typeOf: {
31
- // $eq: chevre.factory.product.ProductType.EventService
32
- // }
33
- // }
34
- // }
35
- // }));
36
- // console.log(deletingOwnershipInfos.length, 'deletingOwnershipInfos found');
37
-
38
- const cursor = ownershipInfoRepo.getCursor(
39
- {
40
- // sort: { ownedFrom: chevre.factory.sortType.Ascending },
41
- 'project.id': { $eq: DISCONTINUE_PEOPLE_PROJECT },
42
- 'ownedBy.typeOf': {
43
- $exists: true,
44
- $eq: chevre.factory.personType.Person
45
- },
46
- 'typeOfGood.issuedThrough.typeOf': {
47
- $exists: true,
48
- $eq: chevre.factory.product.ProductType.EventService
49
- },
50
- ownedFrom: {
51
- $lte: moment('2024-02-25T00:00:00Z')
52
- .toDate()
53
- }
54
- },
55
- {
56
- _id: 1,
57
- ownedBy: 1,
58
- ownedFrom: 1,
59
- project: 1
60
- }
61
- );
62
- console.log('docs found');
63
-
64
- const runsAt: Date = new Date();
65
- const userPoolId: string = setting.userPoolIdNew;
66
-
67
- let i = 0;
68
- // tslint:disable-next-line:max-func-body-length
69
- await cursor.eachAsync(async (doc) => {
70
- i += 1;
71
-
72
- const deletingOwnershipInfo: Pick<
73
- chevre.factory.ownershipInfo.IOwnershipInfo<any>,
74
- 'id' | 'ownedBy' | 'ownedFrom' | 'project'
75
- > = doc.toObject();
76
- const personId: string = (Array.isArray(deletingOwnershipInfo.ownedBy))
77
- ? deletingOwnershipInfo.ownedBy[0]?.id
78
- : deletingOwnershipInfo.ownedBy.id;
79
- console.log(deletingOwnershipInfo);
80
-
81
- console.log(
82
- 'deleting person...',
83
- personId, deletingOwnershipInfo.project.id, deletingOwnershipInfo.id, deletingOwnershipInfo.ownedFrom, i
84
- );
85
- try {
86
- await deletePerson({
87
- id: '',
88
- project: { typeOf: chevre.factory.organizationType.Project, id: DISCONTINUE_PEOPLE_PROJECT },
89
- name: chevre.factory.taskName.DeletePerson,
90
- status: chevre.factory.taskStatus.Ready,
91
- runsAt,
92
- remainingNumberOfTries: 10,
93
- numberOfTried: 0,
94
- data: {
95
- id: personId,
96
- agent: {
97
- id: DISCONTINUE_PEOPLE_PROJECT,
98
- typeOf: chevre.factory.organizationType.Project,
99
- name: 'example'
100
- },
101
- physically: true,
102
- userPoolId,
103
- migrate: false,
104
- useUsernameAsGMOMemberId: true,
105
- paymentMethodType4creditCard: 'CreditCard',
106
- executeBackground: true
107
- }
108
- })(
109
- {
110
- connection: mongoose.connection,
111
- settings: new chevre.settings.Settings({
112
- abortedTasksWithoutReport: [],
113
- numTryConfirmReserveTransaction: 10,
114
- deliverOrderLimit: 1,
115
- coa: {
116
- timeout: 20000
117
- },
118
- gmo: {
119
- timeout: 5000,
120
- timeoutBackground: 5000,
121
- useFetch: true
122
- },
123
- movieticketReserve: {
124
- timeout: 1000,
125
- timeoutCheck: 1000,
126
- minIntervalBetweenPayAndRefund: 1000,
127
- credentialsExpireInSeconds: 1000
128
- },
129
- useExperimentalFeature: false
130
- }),
131
- credentials: <any>{}
132
- },
133
- {
134
- executeById: false,
135
- executeByName: true
136
- }
137
- );
138
- console.log(
139
- 'deleted',
140
- personId, deletingOwnershipInfo.project.id, deletingOwnershipInfo.id, deletingOwnershipInfo.ownedFrom, i
141
- );
142
- } catch (error) {
143
- // no op
144
- }
145
- });
146
-
147
- console.log(i, 'docs checked');
148
- }
149
- }
150
-
151
- main()
152
- .then(console.log)
153
- .catch(console.error);
@@ -1,38 +0,0 @@
1
- // tslint:disable:no-console
2
- // import moment from 'moment';
3
-
4
- const TIMEOUT_MS = 5000;
5
- const INTERVAL_MS = 3000;
6
-
7
- let i = 0;
8
- setInterval(
9
- async () => {
10
- i += 1;
11
- try {
12
- const url = String(process.env.DISCONTINUE_PEOPLE_URL);
13
- const res = await fetch(
14
- url,
15
- {
16
- signal: AbortSignal.timeout(TIMEOUT_MS),
17
- method: 'GET'
18
- }
19
- );
20
- const result = await res.text();
21
- console.log('result', result, i);
22
- console.log('res.status', res.status, i);
23
- } catch (err) {
24
- console.error(err);
25
- if (err.name === 'TimeoutError') {
26
- console.error('Timeout: It took more than 5 seconds to get the result!');
27
- } else if (err.name === 'AbortError') {
28
- console.error('Fetch aborted by user action (browser stop button, closing tab, etc.');
29
- } else if (err.name === 'TypeError') {
30
- console.error('AbortSignal.timeout() method is not supported');
31
- } else {
32
- // A network error, or some other problem.
33
- console.error(`Error: type: ${err.name}, message: ${err.message}`);
34
- }
35
- }
36
- },
37
- INTERVAL_MS
38
- );
@@ -1,79 +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
- // 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 ownershipInfoRepo = await chevre.repository.OwnershipInfo.createInstance(mongoose.connection);
14
-
15
- const ownedThroughLt = moment()
16
- .add(-1, 'year')
17
- .toDate();
18
- const cursor = ownershipInfoRepo.getCursor(
19
- {
20
- ownedThrough: {
21
- $exists: true,
22
- $lt: ownedThroughLt
23
- }
24
- },
25
- {
26
- }
27
- );
28
- console.log('infos found');
29
-
30
- let i = 0;
31
- let updateCount = 0;
32
- await cursor.eachAsync(async (doc) => {
33
- i += 1;
34
- const ownershipInfo: Pick<
35
- chevre.factory.ownershipInfo.IOwnershipInfo<chevre.factory.ownershipInfo.IGood>,
36
- 'id' | 'project' | 'identifier' | 'ownedBy' | 'ownedFrom' | 'ownedThrough'
37
- > = doc.toObject();
38
-
39
- let noNeedToDelete = true;
40
- let ownedById: string | undefined;
41
- if (ownershipInfo.ownedThrough instanceof Date
42
- && moment(ownedThroughLt)
43
- .isAfter(moment(ownershipInfo.ownedThrough))) {
44
- noNeedToDelete = false;
45
- ownedById = (Array.isArray(ownershipInfo.ownedBy)) ? ownershipInfo.ownedBy[0].id : ownershipInfo.ownedBy.id;
46
- }
47
-
48
- if (noNeedToDelete) {
49
- console.log(
50
- 'noNeedToDelete.',
51
- ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownershipInfo.ownedFrom, ownershipInfo.ownedThrough,
52
- i, updateCount);
53
- } else {
54
- console.log(
55
- 'deleting...',
56
- ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownershipInfo.ownedFrom, ownershipInfo.ownedThrough,
57
- i, updateCount);
58
- if (typeof ownedById === 'string') {
59
- // await ownershipInfoRepo.deleteByIdAndOwnedById({
60
- // project: { id: ownershipInfo.project.id },
61
- // id: ownershipInfo.id,
62
- // ownedBy: { id: ownedById }
63
- // });
64
- }
65
- updateCount += 1;
66
- console.log(
67
- 'deleted.',
68
- ownershipInfo.project.id, ownershipInfo.identifier, ownershipInfo.id, ownershipInfo.ownedFrom, ownershipInfo.ownedThrough,
69
- i, updateCount);
70
- }
71
- });
72
-
73
- console.log(i, 'infos checked');
74
- console.log(updateCount, 'infos updated');
75
- }
76
-
77
- main()
78
- .then()
79
- .catch(console.error);
@@ -1,27 +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
- 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
-
12
- const lt: Date = moment()
13
- // tslint:disable-next-line:no-magic-numbers
14
- .add(-16, 'months')
15
- .toDate();
16
- let result: any;
17
- result = await actionRepo.deleteStartDatePassedCertainPeriod({
18
- $lt: lt
19
- });
20
- console.log('result:', result, lt);
21
- }
22
-
23
- main()
24
- .then(() => {
25
- console.log('success!');
26
- })
27
- .catch(console.error);
@@ -1,30 +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
-
14
- const result = await taskRepo.deleteByName({
15
- name: <any>'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
- // }
23
- });
24
-
25
- console.log('deleted', result);
26
- }
27
-
28
- main()
29
- .then()
30
- .catch(console.error);
@@ -1,63 +0,0 @@
1
- // tslint:disable:no-console
2
- // import moment from 'moment';
3
- import * as fs from 'fs';
4
- import mongoose from 'mongoose';
5
-
6
- import { createSendOrderMessage } from '../../../../lib/chevre/emailMessageBuilder';
7
- import { chevre } from '../../../../lib/index';
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
- const emailMessageRepo = await chevre.repository.EmailMessage.createInstance(mongoose.connection);
13
- const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
14
-
15
- const order = (await orderRepo.projectFields(
16
- {
17
- limit: 1,
18
- page: 1,
19
- orderNumbers: ['CA60-9911941-1096810']
20
- },
21
- {
22
- inclusion: ['confirmationNumber', 'customer', 'identifier', 'orderDate', 'orderNumber', 'orderStatus', 'orderedItem', 'paymentMethods', 'price', 'priceCurrency', 'project', 'seller', 'typeOf']
23
- }
24
- )).shift();
25
- if (order === undefined) {
26
- throw new Error('order not found');
27
- }
28
- console.trace(order);
29
-
30
- // デフォルトEメールメッセージを検索
31
- let emailMessageOnOrderSent: chevre.factory.creativeWork.message.email.ICreativeWork | undefined;
32
- const searchEmailMessagesResult = await emailMessageRepo.search({
33
- limit: 1,
34
- page: 1,
35
- project: { id: { $eq: order.project.id } },
36
- about: { identifier: { $eq: chevre.factory.creativeWork.message.email.AboutIdentifier.OnOrderSent } }
37
- });
38
- emailMessageOnOrderSent = searchEmailMessagesResult.shift();
39
- console.trace(emailMessageOnOrderSent);
40
-
41
- const emailMessage = await createSendOrderMessage(
42
- {
43
- order,
44
- // email: {
45
- // template: ''
46
- // },
47
- // emailMessage?: factory.creativeWork.message.email.ICreativeWork;
48
- index: 0,
49
- ...(emailMessageOnOrderSent !== undefined) ? { emailMessage: emailMessageOnOrderSent } : undefined
50
- },
51
- {
52
- defaultSenderEmail: 'defaultSenderEmail@example.com'
53
- }
54
- );
55
-
56
- console.trace(emailMessage);
57
- // tslint:disable-next-line:non-literal-fs-path no-null-keyword
58
- fs.writeFileSync(`${__dirname}/../../../emailMessage.json`, JSON.stringify(emailMessage, null, ' '));
59
- }
60
-
61
- main()
62
- .then()
63
- .catch(console.error);
@@ -1,108 +0,0 @@
1
- // tslint:disable:no-console no-magic-numbers
2
- import { webcrypto } from 'crypto';
3
- import moment from 'moment';
4
- import mongoose from 'mongoose';
5
-
6
- import { chevre } from '../../../../lib/index';
7
-
8
- // const project = { id: String(process.env.PROJECT_ID) };
9
- const PROPERTY_NAME = 'createId';
10
-
11
- async function additionalProperty2identifier(raw: string) {
12
- const data = new TextEncoder().encode(raw);
13
- const hashBuffer = await webcrypto.subtle.digest('SHA-256', data);
14
- const bytes = Array.from(new Uint8Array(hashBuffer));
15
-
16
- // 0-9 + a-z の36文字セット
17
- const chars = '0123456789abcdefghijklmnopqrstuvwxyz';
18
- // tslint:disable-next-line:no-magic-numbers
19
- const id = bytes.map((b) => chars[b % 36])
20
- .join('');
21
-
22
- // tslint:disable-next-line:no-magic-numbers
23
- return id.slice(0, 16);
24
- }
25
-
26
- const identifierMustMatch = /^[0-9a-zA-Z]+$/;
27
- function validateIdentifier(identifier: string) {
28
- if (!identifierMustMatch.test(identifier)) {
29
- throw new Error(`not matched ${identifier}`);
30
- }
31
-
32
- if (identifier.length < 8 || identifier.length > 32) {
33
- throw new Error(`invalid length ${identifier}`);
34
- }
35
- }
36
-
37
- // tslint:disable-next-line:max-func-body-length
38
- async function main() {
39
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
40
-
41
- const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
42
-
43
- const cursor = eventRepo.getCursor(
44
- {
45
- // _id: { $eq: '68f5d32176b5f6b689ff24a6' },
46
- // 'project.id': { $eq: project.id },
47
- 'additionalProperty.name': { $exists: true, $eq: PROPERTY_NAME },
48
- startDate: {
49
- $gte: moment()
50
- .add(-1, 'days')
51
- .toDate()
52
- }
53
- },
54
- {
55
- _id: 1,
56
- startDate: 1,
57
- project: 1,
58
- identifier: 1,
59
- additionalProperty: 1,
60
- typeOf: 1
61
- }
62
- );
63
- console.log('events found');
64
-
65
- let i = 0;
66
- await cursor.eachAsync(async (doc) => {
67
- i += 1;
68
- const event: Pick<
69
- chevre.factory.event.screeningEvent.IEvent,
70
- 'id' | 'identifier' | 'startDate' | 'project' | 'additionalProperty' | 'typeOf'
71
- > = doc.toObject();
72
-
73
- console.log(
74
- 'alreadyMigrated?', event.project.id, event.id, event.startDate, i);
75
- const eventIdentifier = event.identifier;
76
- const additionalPropertyValue = event.additionalProperty?.find(({ name }) => name === PROPERTY_NAME)?.value;
77
- if (typeof additionalPropertyValue !== 'string') {
78
- throw new Error('additionalPropertyValue not found');
79
- }
80
- const identifierMustBe = await additionalProperty2identifier(additionalPropertyValue);
81
- validateIdentifier(identifierMustBe);
82
-
83
- // const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier.length > 0;
84
- // const alreadyMigrated = typeof eventIdentifier === 'string' && eventIdentifier === identifierMustBe;
85
-
86
- console.log(
87
- 'checking...',
88
- identifierMustBe, event.project.id, eventIdentifier, additionalPropertyValue, event.id, event.startDate, i);
89
- const existingEvents = await eventRepo.findByAdditionalProperty(
90
- {
91
- // limit: 2,
92
- // page: 1,
93
- project: { id: event.project.id },
94
- additionalProperty: { name: PROPERTY_NAME, value: additionalPropertyValue }
95
- }
96
- );
97
- console.log('existingEvents found.', existingEvents.length, existingEvents);
98
- if (existingEvents.length !== 1 || existingEvents[0]._id !== event.id) {
99
- throw new Error(`not unique! ${event.id} ${additionalPropertyValue}`);
100
- }
101
- });
102
-
103
- console.log(i, 'events checked');
104
- }
105
-
106
- main()
107
- .then()
108
- .catch(console.error);