@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,200 +0,0 @@
1
- // tslint:disable:no-console
2
- // tslint:disable:no-console
3
- import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider';
4
- // tslint:disable-next-line:no-submodule-imports
5
- import type { UserPoolClientType } from '@aws-sdk/client-cognito-identity-provider/dist-types/models/models_0';
6
- import { fromEnv } from '@aws-sdk/credential-providers';
7
- import * as fs from 'fs';
8
- // tslint:disable-next-line:no-implicit-dependencies
9
- import * as json2csv from 'json2csv';
10
- import mongoose from 'mongoose';
11
-
12
- import { chevre } from '../../../../lib/index';
13
-
14
- // const project = { id: String(process.env.PROJECT_ID) };
15
- // const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
16
- const userPoolId = `${process.env.COGNITO_USER_POOL_ID}`;
17
- const oldProvider = `https://cognito-idp.ap-northeast-1.amazonaws.com/${userPoolId}`;
18
- const NEW_ISS = process.env.NEW_ISS;
19
-
20
- // tslint:disable-next-line:max-func-body-length
21
- async function main() {
22
- if (typeof NEW_ISS !== 'string') {
23
- throw new Error('process.env.NEW_ISS undefined');
24
- }
25
-
26
- const awsCredentials = fromEnv();
27
- const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
28
- apiVersion: 'latest',
29
- region: 'ap-northeast-1',
30
- credentials: awsCredentials
31
- });
32
-
33
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
34
-
35
- const identityRepo = await chevre.repository.Identity.createInstance(mongoose.connection);
36
- const identityProviderRepo = await chevre.repository.IdentityProvider.createInstance(mongoose.connection);
37
- const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
38
-
39
- const cursor = identityRepo.getCursor(
40
- {
41
- 'issuedBy.identifier': { $eq: oldProvider }
42
- // _id: { $eq: '67de46777ec0510590b68922' }
43
- },
44
- {
45
- _id: 1,
46
- about: 1,
47
- project: 1,
48
- typeOf: 1,
49
- issuedBy: 1
50
- }
51
- );
52
- console.log('docs found');
53
-
54
- let i = 0;
55
- let updateCount = 0;
56
- const creatingClients: {
57
- projectId: string;
58
- clientId: string;
59
- clientSecret: string;
60
- name: string;
61
- memberName: string;
62
- }[] = [];
63
- // tslint:disable-next-line:max-func-body-length
64
- await cursor.eachAsync(async (doc) => {
65
- i += 1;
66
- const identity: Pick<
67
- chevre.factory.creativeWork.certification.webApplication.ICertification,
68
- 'about' | 'project' | 'typeOf' | 'id' | 'issuedBy'
69
- > = doc.toObject();
70
-
71
- const iamMember = (await memberRepo.projectFieldsByProjectId(
72
- { id: identity.project.id },
73
- {
74
- limit: 1,
75
- member: {
76
- id: { $eq: identity.about.id },
77
- typeOf: { $eq: chevre.factory.creativeWorkType.WebApplication }
78
- }
79
- },
80
- ['member']
81
- )).shift();
82
- if (iamMember === undefined) {
83
- throw new Error(`iamMember not found ${identity.project.id} ${identity.about.id}`);
84
- }
85
-
86
- const client = await new Promise<UserPoolClientType>(async (resolve, reject) => {
87
- cognitoIdentityServiceProvider.describeUserPoolClient(
88
- {
89
- ClientId: identity.about.id,
90
- UserPoolId: userPoolId
91
- },
92
- {},
93
- (err, data) => {
94
- if (err instanceof Error) {
95
- reject(err);
96
- } else {
97
- if (data?.UserPoolClient === undefined) {
98
- reject(new chevre.factory.errors.NotFound('UserPoolClient'));
99
- } else {
100
- resolve(data.UserPoolClient);
101
- }
102
- }
103
- }
104
- );
105
- });
106
-
107
- if (typeof client.ClientId !== 'string'
108
- || typeof client.ClientSecret !== 'string'
109
- || typeof client.ClientName !== 'string') {
110
- throw new Error('invalid client');
111
- }
112
-
113
- creatingClients.push({
114
- projectId: identity.project.id,
115
- clientId: client.ClientId,
116
- clientSecret: client.ClientSecret,
117
- name: client.ClientName,
118
- memberName: String(iamMember.member.name)
119
- });
120
-
121
- const issuedBy = identity.issuedBy;
122
- const numIssuedBy = (Array.isArray(identity.issuedBy)) ? identity.issuedBy.length : 1;
123
-
124
- const alreadyMigrated = (Array.isArray(issuedBy))
125
- // tslint:disable-next-line:no-magic-numbers
126
- && issuedBy.length === 2
127
- && issuedBy.some(({ identifier }) => identifier === NEW_ISS);
128
-
129
- if (alreadyMigrated) {
130
- console.log('already migrated.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
131
- } else {
132
- if (typeof identity.id !== 'string') {
133
- throw new Error(`id undefined ${identity.id}`);
134
- }
135
-
136
- // プロバイダー追加
137
- const existingProvider = (await identityProviderRepo.projectFields(
138
- {
139
- limit: 1,
140
- project: { id: { $eq: identity.project.id } },
141
- identifier: { $eq: NEW_ISS }
142
- },
143
- ['identifier']
144
- )).shift();
145
- if (existingProvider === undefined) {
146
- await identityProviderRepo.save({
147
- attributes: {
148
- identifier: NEW_ISS,
149
- project: { id: identity.project.id, typeOf: chevre.factory.organizationType.Project },
150
- typeOf: chevre.factory.organizationType.Organization
151
- }
152
- });
153
- console.log('provider saved.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
154
- }
155
-
156
- // identity更新
157
- const newIssuedBy = (Array.isArray(issuedBy)) ? issuedBy : [issuedBy];
158
- if (newIssuedBy.length !== 1) {
159
- throw new Error('newIssuedBy.length must be 1');
160
- }
161
- newIssuedBy.push({
162
- identifier: NEW_ISS,
163
- typeOf: chevre.factory.organizationType.Organization
164
- });
165
- console.log(newIssuedBy);
166
- await identityRepo.updateIssuedBy2array({
167
- id: identity.id,
168
- issuedBy: newIssuedBy
169
- });
170
- updateCount += 1;
171
- console.log(
172
- 'updated.', identity.project.id, identity.about.id, identity.id, numIssuedBy, i);
173
- }
174
- });
175
-
176
- console.log(creatingClients.map(({ clientId }) => clientId));
177
- // tslint:disable-next-line:non-literal-fs-path no-null-keyword
178
- // fs.writeFileSync(`${__dirname}/../../../creatingClients.json`, JSON.stringify(creatingClients, null, ' '));
179
- // tslint:disable-next-line:non-literal-fs-path no-null-keyword
180
- const json = JSON.stringify(creatingClients, null, '');
181
- // tslint:disable-next-line:non-literal-fs-path
182
- fs.writeFileSync(`${__dirname}/../../../creatingClients.json`, json);
183
- console.log(i, 'docs checked');
184
- console.log(updateCount, 'docs updated');
185
-
186
- const parser = new json2csv.Parser({
187
- fields: ['projectId', 'clientId', 'clientSecret', 'name', 'memberName']
188
- });
189
- const csv = parser.parse(creatingClients.sort(
190
- (a, b) => {
191
- return (a.projectId > b.projectId) ? 1 : -1;
192
- }
193
- ));
194
- // tslint:disable-next-line:non-literal-fs-path
195
- fs.writeFileSync(`${__dirname}/../../../creatingClients.csv`, csv);
196
- }
197
-
198
- main()
199
- .then()
200
- .catch(console.error);
@@ -1,34 +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);
10
-
11
- const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
12
- const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
13
- endpoint: '',
14
- refreshToken: '',
15
- useFetch: true
16
- });
17
- const masterService = new (await chevre.loadCOA()).service.Master(
18
- {
19
- endpoint: '',
20
- auth: coaAuthClient
21
- },
22
- { timeout: 20000 }
23
- );
24
-
25
- await (await chevre.service.offer.createService()).event.importCategoryCodesFromCOA({
26
- project,
27
- theaterCode: '120'
28
- })({ categoryCode: categoryCodeRepo, masterService });
29
- console.log('imported');
30
- }
31
-
32
- main()
33
- .then(console.log)
34
- .catch(console.error);
@@ -1,66 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as redis from 'redis';
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
-
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
14
- const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
15
- const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
16
- const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
17
- const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
18
- const screeningRoomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
19
- const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
20
- const sellerRepo = await chevre.repository.Seller.createInstance(mongoose.connection);
21
-
22
- const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
23
- endpoint: String(process.env.COA_ENDPOINT),
24
- refreshToken: process.env.COA_REFRESH_TOKEN,
25
- useFetch: true
26
- });
27
- const masterService = new (await chevre.loadCOA()).service.Master(
28
- {
29
- endpoint: String(process.env.COA_ENDPOINT),
30
- auth: coaAuthClient
31
- },
32
- { timeout: 20000 }
33
- );
34
-
35
- await (await chevre.service.event.createService()).importFromCOA({
36
- project: {
37
- id: project.id,
38
- typeOf: chevre.factory.organizationType.Project
39
- },
40
- locationBranchCode: '016',
41
- importFrom: moment('2025-12-10T04:45:00.181Z')
42
- .toDate(),
43
- importThrough: moment('2025-12-11T04:45:00.181Z')
44
- // .add(1, 'day')
45
- .toDate(),
46
- saveMovieTheater: false,
47
- saveScreeningEventSeries: true,
48
- // saveScreeningEventSeries: true,
49
- saveScreeningEventSeriesPeriodInMonth: 3
50
- })({
51
- action: actionRepo,
52
- categoryCode: categoryCodeRepo,
53
- creativeWork: creativeWorkRepo,
54
- event: eventRepo,
55
- eventSeries: eventSeriesRepo,
56
- movieTheater: movieTheaterRepo,
57
- screeningRoom: screeningRoomRepo,
58
- seller: sellerRepo,
59
- masterService
60
- });
61
- console.log('imported');
62
- }
63
-
64
- main()
65
- .then(console.log)
66
- .catch(console.error);
@@ -1,86 +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 eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
-
13
- const cursor = eventRepo.getCursor(
14
- {
15
- 'project.id': {
16
- $nin: [
17
- 'sskts-test',
18
- 'sskts-production'
19
- ]
20
- },
21
- startDate: { $gte: new Date('2025-04-10T00:00:00Z') }
22
- },
23
- {
24
- offers: 1,
25
- project: 1,
26
- typeOf: 1,
27
- startDate: 1,
28
- location: 1,
29
- aggregateReservation: 1
30
- }
31
- );
32
- console.log('docs found');
33
-
34
- let i = 0;
35
- let hasNoSeatsCount = 0;
36
- let tooManyReservationCount = 0;
37
- let maxReservationCount = 0;
38
- const targetIds: string[] = [];
39
- const projectIds: string[] = [];
40
- await cursor.eachAsync(async (doc) => {
41
- i += 1;
42
- const event: Pick<
43
- chevre.factory.event.screeningEvent.IEvent, 'id' | 'offers' | 'startDate' | 'typeOf' | 'location' | 'project' | 'aggregateReservation'
44
- > = doc.toObject();
45
-
46
- // const hasMax = typeof event.location.maximumAttendeeCapacity === 'number';
47
- const hasSeats = event.offers.itemOffered.serviceOutput?.reservedTicket?.ticketedSeat?.typeOf === chevre.factory.placeType.Seat;
48
- if (!hasSeats) {
49
- hasNoSeatsCount += 1;
50
- targetIds.push(event.id);
51
- projectIds.push(event.project.id);
52
- console.log(
53
- 'hasNoSeatsCount:', hasNoSeatsCount,
54
- event.id, event.project.id, event.startDate, i);
55
- } else {
56
- console.log(
57
- 'no', hasNoSeatsCount,
58
- event.id, event.project.id, event.startDate, i);
59
- }
60
-
61
- const reservationCount = event.aggregateReservation?.reservationCount;
62
- if (typeof reservationCount === 'number') {
63
- maxReservationCount = Math.max(reservationCount, maxReservationCount);
64
- }
65
- const tooManyReservation = typeof event.aggregateReservation?.reservationCount === 'number'
66
- // tslint:disable-next-line:no-magic-numbers
67
- && event.aggregateReservation?.reservationCount > 2000;
68
- if (tooManyReservation) {
69
- tooManyReservationCount += 1;
70
- console.log(
71
- 'tooManyReservationCount:', tooManyReservationCount,
72
- event.id, event.project.id, event.startDate, i);
73
- }
74
-
75
- });
76
-
77
- console.log(targetIds);
78
- console.log(i, 'docs checked');
79
- console.log(hasNoSeatsCount, 'docs hasNoSeatsCount');
80
- console.log('projectIds:', [...new Set(projectIds)]);
81
- console.log('maxReservationCount:', maxReservationCount);
82
- }
83
-
84
- main()
85
- .then()
86
- .catch(console.error);
@@ -1,66 +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 cursor = transactionRepo.getCursor(
15
- {
16
- 'project.id': { $eq: project.id },
17
- typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
18
- status: {
19
- $in: [
20
- chevre.factory.transactionStatusType.Canceled,
21
- chevre.factory.transactionStatusType.Expired
22
- ]
23
- },
24
- startDate: {
25
- $gte: moment('2025-04-10T15:00:00Z')
26
- .toDate(),
27
- $lte: moment('2025-04-11T01:00:00Z')
28
- .toDate()
29
- }
30
- },
31
- {
32
- project: 1,
33
- typeOf: 1,
34
- startDate: 1,
35
- object: 1,
36
- result: 1,
37
- agent: 1
38
- }
39
- );
40
- console.log('transactions found');
41
-
42
- let i = 0;
43
- let transactionByMemberCount = 0;
44
- await cursor.eachAsync(async (doc) => {
45
- i += 1;
46
- const transaction: Pick<
47
- chevre.factory.transaction.ITransaction<chevre.factory.transactionType.PlaceOrder>,
48
- 'project' | 'object' | 'startDate' | 'result' | 'typeOf' | 'agent'
49
- > = doc.toObject();
50
-
51
- if (transaction.agent.id === '28v3ml7b8f74h2dqdvni7ntf25') {
52
- const publishedPaymentMethodId = transaction.object.paymentMethods?.paymentMethodId;
53
- if (typeof publishedPaymentMethodId === 'string') {
54
- console.log(transaction.project.id, transaction.agent.id, publishedPaymentMethodId, transaction.startDate, i);
55
- transactionByMemberCount += 1;
56
- }
57
- }
58
- });
59
-
60
- console.log(i, 'transactions checked');
61
- console.log(transactionByMemberCount, 'transactionByMember found');
62
- }
63
-
64
- main()
65
- .then()
66
- .catch(console.error);
@@ -1,24 +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 SELLER_ID = '59d20831e53ebc2b4e774466';
8
- const PAYMENT_METHOD_TYPE = 'Cash';
9
-
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
12
-
13
- const paymentAcceptedRepo = await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection);
14
-
15
- const paymentAccepted = await paymentAcceptedRepo.isAcceptedBySeller({
16
- seller: { id: SELLER_ID },
17
- codeValue: PAYMENT_METHOD_TYPE
18
- });
19
- console.log('paymentAccepted:', paymentAccepted);
20
- }
21
-
22
- main()
23
- .then()
24
- .catch(console.error);
@@ -1,55 +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 IDENTIFIER = 'DefaultMemberProgram';
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const memberProgramRepo = await chevre.repository.MemberProgram.createInstance(mongoose.connection);
13
-
14
- const memberPrograms = await memberProgramRepo.projectMemberPrograms(
15
- {
16
- project: { id: { $eq: project.id } },
17
- identifier: { $eq: IDENTIFIER }
18
- }
19
- );
20
- console.log('docs:', memberPrograms);
21
- console.log(memberPrograms.length, 'docs found');
22
-
23
- if (memberPrograms.length > 0) {
24
- const memberProgram = memberPrograms[0];
25
- await memberProgramRepo.updateOne({
26
- project: { id: project.id },
27
- identifier: memberProgram.identifier,
28
- hostingOrganization: { id: 'xxx' },
29
- hasTiers: [
30
- { identifier: 'bronze' },
31
- { identifier: 'silver' },
32
- { identifier: 'gold' }
33
- ]
34
- });
35
- console.log('updated.');
36
-
37
- const tiers = await memberProgramRepo.projectMemberProgramTiers(
38
- {
39
- limit: 10,
40
- page: 1,
41
- project: { id: { $eq: project.id } },
42
- isTierOf: {
43
- identifier: { $eq: memberProgram.identifier }
44
- }
45
- }
46
- );
47
- // tslint:disable-next-line:no-null-keyword
48
- console.dir(tiers, { depth: null });
49
- console.log(tiers.length, 'tiers found');
50
- }
51
- }
52
-
53
- main()
54
- .then()
55
- .catch(console.error);
@@ -1,62 +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 issuerRepo = await chevre.repository.Issuer.createInstance(mongoose.connection);
11
-
12
- const cursor = issuerRepo.getCursor(
13
- {
14
- // 'project.id': { $ne: EXCLUDED_PROJECT_ID }
15
- },
16
- {
17
- _id: 1,
18
- project: 1,
19
- identifier: 1,
20
- url: 1,
21
- name: 1
22
- }
23
- );
24
- console.log('docs found');
25
-
26
- let i = 0;
27
- let updateCount = 0;
28
- await cursor.eachAsync(async (doc) => {
29
- i += 1;
30
- const issuer: chevre.factory.issuer.IIssuer = doc.toObject();
31
-
32
- const alreadyMigrated = typeof issuer.url === 'string';
33
-
34
- if (alreadyMigrated) {
35
- console.log(
36
- 'already migrated.',
37
- issuer.id, issuer.project.id, issuer.identifier, i);
38
- } else {
39
- console.log(
40
- 'updating...',
41
- issuer.id, issuer.project.id, issuer.identifier, i);
42
- await issuerRepo.saveIssuer({
43
- id: issuer.id,
44
- identifier: issuer.identifier,
45
- name: { ja: issuer.identifier },
46
- project: issuer.project,
47
- url: issuer.identifier
48
- });
49
- updateCount += 1;
50
- console.log(
51
- 'updated.',
52
- issuer.id, issuer.project.id, issuer.identifier, i);
53
- }
54
- });
55
-
56
- console.log(i, 'docs checked');
57
- console.log(updateCount, 'docs updated');
58
- }
59
-
60
- main()
61
- .then()
62
- .catch(console.error);
@@ -1,61 +0,0 @@
1
- // tslint:disable:no-console
2
- import mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../../lib/index';
5
-
6
- const NEW_IDENTIFIER = 'DefaultTokenIssuer';
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 issuerRepo = await chevre.repository.Issuer.createInstance(mongoose.connection);
13
-
14
- const cursor = issuerRepo.getCursor(
15
- {
16
- // 'project.id': { $ne: EXCLUDED_PROJECT_ID }
17
- },
18
- {
19
- _id: 1,
20
- project: 1,
21
- identifier: 1,
22
- url: 1,
23
- name: 1
24
- }
25
- );
26
- console.log('docs found');
27
-
28
- let i = 0;
29
- let updateCount = 0;
30
- await cursor.eachAsync(async (doc) => {
31
- i += 1;
32
- const issuer: chevre.factory.issuer.IIssuer = doc.toObject();
33
-
34
- const alreadyMigrated = issuer.identifier === NEW_IDENTIFIER;
35
-
36
- if (alreadyMigrated) {
37
- console.log(
38
- 'already migrated.',
39
- issuer.id, issuer.project.id, issuer.identifier, i);
40
- } else {
41
- console.log(
42
- 'updating...',
43
- issuer.id, issuer.project.id, issuer.identifier, i);
44
- await issuerRepo.renameIssuerIdentifier({
45
- id: issuer.id,
46
- identifier: NEW_IDENTIFIER
47
- });
48
- updateCount += 1;
49
- console.log(
50
- 'updated.',
51
- issuer.id, issuer.project.id, issuer.identifier, i);
52
- }
53
- });
54
-
55
- console.log(i, 'docs checked');
56
- console.log(updateCount, 'docs updated');
57
- }
58
-
59
- main()
60
- .then()
61
- .catch(console.error);