@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.
- package/lib/chevre/index.d.ts +2 -1
- package/lib/chevre/index.js +3 -1
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/identityProvider.d.ts +4 -4
- package/lib/chevre/repo/potentialAction.d.ts +4 -4
- package/lib/chevre/repo/seller.d.ts +8 -8
- package/lib/chevre/repo/task.d.ts +25 -28
- package/lib/chevre/repo/transaction.d.ts +5 -5
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +3 -2
- package/lib/chevre/service/assetTransaction/reserve/start/factory/addOffers2seat.d.ts +14 -0
- package/lib/chevre/service/assetTransaction/reserve/start/factory/addOffers2seat.js +63 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/offer.d.ts +0 -12
- package/lib/chevre/service/offer.js +0 -37
- package/lib/chevre/service/task.d.ts +1 -1
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.d.ts +2 -1
- package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +2 -1
- package/lib/chevre/service/taskHandler.d.ts +2 -20
- package/lib/chevre/settings.d.ts +1 -2
- package/lib/chevre/settings.js +1 -3
- package/lib/chevre/taskSettings.d.ts +58 -0
- package/package.json +14 -16
- package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +0 -76
- package/example/src/chevre/actions/checkAcceptPayActions.ts +0 -60
- package/example/src/chevre/actions/checkAuthorizePaymentActions.ts +0 -55
- package/example/src/chevre/activateOptionalAggregationSettings.ts +0 -19
- package/example/src/chevre/adminIdentities.ts +0 -71
- package/example/src/chevre/aggreateOwnershipInfosByOrder.ts +0 -24
- package/example/src/chevre/aggregateEventPublicFields.ts +0 -47
- package/example/src/chevre/aggregateOfferCatalogItemList.ts +0 -36
- package/example/src/chevre/aggregateScreeningEventMaxVersion.ts +0 -36
- package/example/src/chevre/aggregation/aggregateOffersOnEvent.ts +0 -86
- package/example/src/chevre/aggregation/aggregateOrderOfCustomer.ts +0 -138
- package/example/src/chevre/aggregation/aggregateOrderOfCustomerGlobally.ts +0 -34
- package/example/src/chevre/aggregation/aggregateOrderOfSeatByRoyalCustomers.ts +0 -172
- package/example/src/chevre/aggregation/aggregateOrderOnSystem.ts +0 -40
- package/example/src/chevre/aggregation/aggregateReservationByProject.ts +0 -79
- package/example/src/chevre/aggregation/aggregateSystem.ts +0 -201
- package/example/src/chevre/aggregation/aggregateTasks.ts +0 -41
- package/example/src/chevre/aggregation/createAggregateEventTasks.ts +0 -71
- package/example/src/chevre/aggregation/searchAggregateReservations.ts +0 -33
- package/example/src/chevre/assetTransaction/checkPayTransactionsTicketToken.ts +0 -67
- package/example/src/chevre/assetTransaction/processReserve.ts +0 -149
- package/example/src/chevre/attendIfNotAttended.ts +0 -31
- package/example/src/chevre/authorizeEventServiceOffer.ts +0 -122
- package/example/src/chevre/categoryCode/checkUniqueness.ts +0 -69
- package/example/src/chevre/changeOrderStatus.ts +0 -29
- package/example/src/chevre/checkCustomerAttributesLength.ts +0 -109
- package/example/src/chevre/checkEventDuration.ts +0 -59
- package/example/src/chevre/checkPaymentServiceUniqueness.ts +0 -79
- package/example/src/chevre/checkProjectMembers.ts +0 -55
- package/example/src/chevre/checkReserveTransactionSizes.ts +0 -46
- package/example/src/chevre/cleanActions.ts +0 -23
- package/example/src/chevre/cleanReservations.ts +0 -69
- package/example/src/chevre/cleanTransactions.ts +0 -39
- package/example/src/chevre/concurrentLock/lockOfferRateLimit.ts +0 -64
- package/example/src/chevre/concurrentLock/lockTransactionProcess.ts +0 -44
- package/example/src/chevre/confirmationNumber/testRandomness.ts +0 -49
- package/example/src/chevre/countPotentiallyExportTasks.ts +0 -42
- package/example/src/chevre/countTransactions.ts +0 -30
- package/example/src/chevre/createProject.ts +0 -19
- package/example/src/chevre/createTaskIfNotExistByAlternateName.ts +0 -57
- package/example/src/chevre/db/stats.ts +0 -35
- package/example/src/chevre/deleteDiscontinuedPeople.ts +0 -153
- package/example/src/chevre/deleteDiscontinuedPeopleByFetch.ts +0 -38
- package/example/src/chevre/deleteOwnershipInfosByOwnedThrough.ts +0 -79
- package/example/src/chevre/deleteStartDatePassedCertainPeriod.ts +0 -27
- package/example/src/chevre/deleteTasksByName.ts +0 -30
- package/example/src/chevre/emailMessage/createEmailMessageText.ts +0 -63
- package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +0 -108
- package/example/src/chevre/event/importEventSeriesFromCOAByTitle.ts +0 -83
- package/example/src/chevre/event/importEventsFromCOAByTitle.ts +0 -148
- package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +0 -121
- package/example/src/chevre/event/migrateEventMaximumPhysicalAttendeeCapacity.ts +0 -76
- package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +0 -30
- package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +0 -106
- package/example/src/chevre/eventSeries/unsetVideoFormat.ts +0 -31
- package/example/src/chevre/eventSeries/upsertScreeningEventSeriesByVersion.ts +0 -106
- package/example/src/chevre/findAnyEventById.ts +0 -24
- package/example/src/chevre/findAuthorizePaymentAction.ts +0 -34
- package/example/src/chevre/findAvailableChannelMovieTicket.ts +0 -25
- package/example/src/chevre/findCheckAction.ts +0 -34
- package/example/src/chevre/findCustomerByOrderNumber.ts +0 -19
- package/example/src/chevre/findItemListElementByCatalogId.ts +0 -30
- package/example/src/chevre/findItemListElementById.ts +0 -23
- package/example/src/chevre/findJWTSetting.ts +0 -19
- package/example/src/chevre/findOneAvailableHours.ts +0 -39
- package/example/src/chevre/findReservationByCode.ts +0 -64
- package/example/src/chevre/findSchedule.ts +0 -43
- package/example/src/chevre/giveUpStartDatePassedCertainPeriod.ts +0 -56
- package/example/src/chevre/identity/getCommonClients.ts +0 -126
- package/example/src/chevre/identity/migrateClients2oauth.ts +0 -200
- package/example/src/chevre/importCategoryCodesFromCOA.ts +0 -34
- package/example/src/chevre/importEventsFromCOA.ts +0 -66
- package/example/src/chevre/investigateEvents.ts +0 -86
- package/example/src/chevre/investigateTransaction.ts +0 -66
- package/example/src/chevre/isPaymentAcceptedBySeller.ts +0 -24
- package/example/src/chevre/issuer/adminMemberProgramTiers.ts +0 -55
- package/example/src/chevre/issuer/migrateIssuerUrls.ts +0 -62
- package/example/src/chevre/issuer/renameIssuerIdentifier.ts +0 -61
- package/example/src/chevre/maintenance/checkTransactionStatuses.ts +0 -105
- package/example/src/chevre/makeExpiredManyTasks.ts +0 -27
- package/example/src/chevre/makeTransactionExpired.ts +0 -28
- package/example/src/chevre/member/migrateMemberIdentifier.ts +0 -99
- package/example/src/chevre/migrateAuthorizeEventServiceOfferChevre.ts +0 -84
- package/example/src/chevre/migrateCancelReservationObject.ts +0 -71
- package/example/src/chevre/migrateCognitoUser.ts +0 -153
- package/example/src/chevre/migrateCustomerAdditionalProperties.ts +0 -116
- package/example/src/chevre/migrateEventSellerMakesOfferAvailableAt.ts +0 -101
- package/example/src/chevre/migrateIdentities.ts +0 -69
- package/example/src/chevre/migrateProjectSettings.ts +0 -64
- package/example/src/chevre/migrateRoomAdditionalProperties.ts +0 -118
- package/example/src/chevre/migrateRoomSectionAdditionalProperties.ts +0 -121
- package/example/src/chevre/note/findNotes.ts +0 -34
- package/example/src/chevre/note/upsertNotesByIdentifier.ts +0 -63
- package/example/src/chevre/notifyAbortedTasksByEmail.ts +0 -56
- package/example/src/chevre/notifyByEmail.ts +0 -43
- package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +0 -49
- package/example/src/chevre/offerCatalog/upsertOfferCatalogItemsByIdentifier.ts +0 -49
- package/example/src/chevre/offerCatalog/upsertOfferCatalogsByIdentifier.ts +0 -51
- package/example/src/chevre/offers/checkIncludedInCatalogCount.ts +0 -47
- package/example/src/chevre/offers/projectItemListElement.ts +0 -54
- package/example/src/chevre/offers/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +0 -51
- package/example/src/chevre/offers/searchByOfferCatalogIdWithSortIndex.ts +0 -44
- package/example/src/chevre/offers/searchOfferCatalogItemAvailability.ts +0 -68
- package/example/src/chevre/offers/upsertOffersByIdentifier.ts +0 -63
- package/example/src/chevre/optimizeActions.ts +0 -61
- package/example/src/chevre/orderNumber/testRandomness.ts +0 -54
- package/example/src/chevre/orders/searchOrders.ts +0 -28
- package/example/src/chevre/orders/searchWithUnwoundAcceptedOffers.ts +0 -73
- package/example/src/chevre/paymentServices/findPaymentServices.ts +0 -37
- package/example/src/chevre/pendingReservation/findEventSeatOffersBySection.ts +0 -46
- package/example/src/chevre/person/checkUserPoolClients.ts +0 -120
- package/example/src/chevre/person/cleanUpCognitoUsers.ts +0 -140
- package/example/src/chevre/person/cleanUpCognitoUsersByFetch.ts +0 -162
- package/example/src/chevre/person/cleanUpCreditCard.ts +0 -113
- package/example/src/chevre/person/updateProfile.ts +0 -56
- package/example/src/chevre/place/adminEntranceGates.ts +0 -69
- package/example/src/chevre/place/adminHasPOS.ts +0 -44
- package/example/src/chevre/place/aggregateSeatingTypes.ts +0 -29
- package/example/src/chevre/place/checkEntranceGatesCount.ts +0 -82
- package/example/src/chevre/place/checkSectionCount.ts +0 -27
- package/example/src/chevre/place/findRooms.ts +0 -24
- package/example/src/chevre/place/findSections.ts +0 -28
- package/example/src/chevre/place/findSectionsByRoom.ts +0 -50
- package/example/src/chevre/place/migrateSectionIdentifier.ts +0 -92
- package/example/src/chevre/place/seatsJson2csv.ts +0 -63
- package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +0 -41
- package/example/src/chevre/place/upsertRoomsByBranchCode.ts +0 -40
- package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +0 -56
- package/example/src/chevre/processAction.ts +0 -44
- package/example/src/chevre/processOrder.ts +0 -90
- package/example/src/chevre/product/findHasOfferCatalog.ts +0 -31
- package/example/src/chevre/productOffer/publishMemberTierToken.ts +0 -92
- package/example/src/chevre/project/unsetProjectSettings.ts +0 -73
- package/example/src/chevre/projectEventFieldsById.ts +0 -23
- package/example/src/chevre/projectFields.ts +0 -28
- package/example/src/chevre/projectFieldsById.ts +0 -30
- package/example/src/chevre/projectOwnershipInfoFieldsById.ts +0 -24
- package/example/src/chevre/pushIncludedInDataCatalog.ts +0 -47
- package/example/src/chevre/reExportAction.ts +0 -40
- package/example/src/chevre/reIndex.ts +0 -20
- package/example/src/chevre/recreateRefundTasks.ts +0 -187
- package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +0 -33
- package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +0 -33
- package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +0 -49
- package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +0 -49
- package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +0 -48
- package/example/src/chevre/roles/addAdminPaymentServiceReadPermissionIfNotExists.ts +0 -49
- package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +0 -33
- package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +0 -34
- package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +0 -34
- package/example/src/chevre/roles/addAdminSellerEventOfferIfNotExists.ts +0 -48
- package/example/src/chevre/roles/addProjectCreatorRole.ts +0 -48
- package/example/src/chevre/roles/assignGlobalRoles.ts +0 -72
- package/example/src/chevre/roles/findPermissions.ts +0 -84
- package/example/src/chevre/roles/findRoleNames.ts +0 -117
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +0 -34
- package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +0 -46
- package/example/src/chevre/roles/removePermissionIfExists.ts +0 -34
- package/example/src/chevre/saveOfferCatalogItem.ts +0 -40
- package/example/src/chevre/saveWebSite.ts +0 -56
- package/example/src/chevre/searchAcceptedOfferIds.ts +0 -57
- package/example/src/chevre/searchActionsByOrderNumber.ts +0 -29
- package/example/src/chevre/searchActionsByPurpose.ts +0 -38
- package/example/src/chevre/searchActionsBySameAs.ts +0 -27
- package/example/src/chevre/searchAggregateOffers.ts +0 -51
- package/example/src/chevre/searchAggregations.ts +0 -50
- package/example/src/chevre/searchAuthorizations.ts +0 -36
- package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +0 -56
- package/example/src/chevre/searchEventHasOfferCatalog.ts +0 -43
- package/example/src/chevre/searchEventSeats.ts +0 -45
- package/example/src/chevre/searchIdsByReservationNumber.ts +0 -16
- package/example/src/chevre/searchMembers.ts +0 -55
- package/example/src/chevre/searchOfferCatalogItemListElement.ts +0 -26
- package/example/src/chevre/searchOffers.ts +0 -68
- package/example/src/chevre/searchProducts.ts +0 -28
- package/example/src/chevre/searchProjects.ts +0 -36
- package/example/src/chevre/searchReservationsByOrder.ts +0 -42
- package/example/src/chevre/searchSellersByAggregate.ts +0 -33
- package/example/src/chevre/searchSlicedAcceptedOffersByOrderNumber.ts +0 -31
- package/example/src/chevre/seller/adminMakesOffer.ts +0 -113
- package/example/src/chevre/sendEmailMessage.ts +0 -60
- package/example/src/chevre/sendGrid/filterEmailActivity.ts +0 -31
- package/example/src/chevre/settings/addOrderNumberSetting.ts +0 -44
- package/example/src/chevre/settings/addTransactionNumberSetting.ts +0 -40
- package/example/src/chevre/stockHolder/findSeatsBySection.ts +0 -59
- package/example/src/chevre/stockHolder/getSize.ts +0 -97
- package/example/src/chevre/stockHolder/projectPendingReservation.ts +0 -43
- package/example/src/chevre/stockHolder/searchSeats.ts +0 -61
- package/example/src/chevre/task/countPotentiallyRunning.ts +0 -41
- package/example/src/chevre/task/countTasks.ts +0 -51
- package/example/src/chevre/task/deleteRunsAtPassedCertainPeriod.ts +0 -43
- package/example/src/chevre/task/deleteUnexpectedTasks.ts +0 -23
- package/example/src/chevre/task/emitRunning.ts +0 -89
- package/example/src/chevre/transaction/processPlaceOrder.ts +0 -57
- package/example/src/chevre/transaction/processReturnOrder.ts +0 -43
- package/example/src/chevre/transaction/startExportTasks.ts +0 -21
- package/example/src/chevre/transactionNumber/publishByTimestamp.ts +0 -23
- package/example/src/chevre/transactionNumber/testRandomness.ts +0 -42
- package/example/src/chevre/unsetUnnecessaryFields.ts +0 -35
- package/example/src/chevre/updateEventPartiallyById.ts +0 -22
- package/example/src/chevre/updateProjectAggregateReservation.ts +0 -21
- package/example/src/chevre/validateCheckMovieTicketActions.ts +0 -70
- package/example/src/customSearch.ts +0 -48
- package/example/src/duration.ts +0 -22
- package/example/src/fetch.ts +0 -45
- package/example/src/moment.ts +0 -22
- package/example/src/mongoConnectionList.ts +0 -81
- package/example/src/mvtkMessage.ts +0 -11
- package/example/src/objectId.ts +0 -12
- package/example/src/redisClientList.ts +0 -80
- package/example/src/redisMulti.ts +0 -63
- package/example/src/regex.ts +0 -31
- package/example/src/signPayload.ts +0 -50
- package/example/src/verifyToken.ts +0 -44
- package/lib/chevre/repo/mongoose/onIndexCreated.d.ts +0 -2
- package/lib/chevre/repo/mongoose/onIndexCreated.js +0 -10
- package/lib/chevre/settings/aggregation.d.ts +0 -35
- /package/lib/chevre/{settings/aggregation.js → taskSettings.js} +0 -0
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const formatter = new Intl.NumberFormat('ja-JP');
|
|
7
|
-
|
|
8
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
-
|
|
10
|
-
async function main() {
|
|
11
|
-
let startTime: [number, number] = process.hrtime();
|
|
12
|
-
let diff: [number, number] = process.hrtime(startTime);
|
|
13
|
-
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
-
|
|
16
|
-
const acceptedOfferRepo = await chevre.repository.AcceptedOffer.createInstance(mongoose.connection);
|
|
17
|
-
|
|
18
|
-
startTime = process.hrtime();
|
|
19
|
-
const result = await acceptedOfferRepo.searchWithUnwoundAcceptedOffers(
|
|
20
|
-
{
|
|
21
|
-
project: { id: { $eq: project.id } },
|
|
22
|
-
limit: 20,
|
|
23
|
-
page: 12,
|
|
24
|
-
sort: {
|
|
25
|
-
orderDate: chevre.factory.sortType.Descending
|
|
26
|
-
},
|
|
27
|
-
orderStatuses: [chevre.factory.orderStatus.OrderDelivered],
|
|
28
|
-
orderDate: {
|
|
29
|
-
$gte: new Date('2025-06-07T15:00:00.000Z'),
|
|
30
|
-
$lte: new Date('2025-07-08T01:42:34.654Z')
|
|
31
|
-
},
|
|
32
|
-
acceptedOffers: {
|
|
33
|
-
itemOffered: {
|
|
34
|
-
issuedThrough: { typeOf: { $eq: chevre.factory.product.ProductType.EventService } },
|
|
35
|
-
reservationFor: {
|
|
36
|
-
inSessionFrom: new Date('2025-07-07T15:00:00.000Z'),
|
|
37
|
-
inSessionThrough: new Date('2025-07-08T15:00:00.000Z'),
|
|
38
|
-
superEvent: {
|
|
39
|
-
location: { branchCodes: ['p006'] }
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
seller: { ids: ['62568df4138ef5000b18c8c0'] },
|
|
45
|
-
provider: { id: { $eq: '62568df4138ef5000b18c8c0' } }
|
|
46
|
-
// // req.seller.idを考慮(2023-07-19~)
|
|
47
|
-
// ...(typeof req.seller?.id === 'string') ? { provider: { id: { $eq: req.seller.id } } } : undefined
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
confirmationNumber: 1,
|
|
51
|
-
customer: 1,
|
|
52
|
-
dateReturned: 1,
|
|
53
|
-
orderDate: 1,
|
|
54
|
-
orderNumber: 1,
|
|
55
|
-
orderStatus: 1,
|
|
56
|
-
paymentMethods: 1,
|
|
57
|
-
price: 1,
|
|
58
|
-
priceCurrency: 1,
|
|
59
|
-
project: 1,
|
|
60
|
-
seller: 1
|
|
61
|
-
},
|
|
62
|
-
{ useLimitAfterSkip: false }
|
|
63
|
-
// { useLimitAfterSkip: true }
|
|
64
|
-
);
|
|
65
|
-
diff = process.hrtime(startTime);
|
|
66
|
-
console.log(result.map(({ orderNumber, orderDate }) => `${orderDate} ${orderNumber}`));
|
|
67
|
-
console.log(result.length);
|
|
68
|
-
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
main()
|
|
72
|
-
.then(console.log)
|
|
73
|
-
.catch(console.error);
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
import { chevre } from '../../../../lib/index';
|
|
4
|
-
|
|
5
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
try {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const limit = 10;
|
|
14
|
-
const page = 1;
|
|
15
|
-
const docs = await paymentServiceRepo.projectFields(
|
|
16
|
-
{
|
|
17
|
-
limit,
|
|
18
|
-
page,
|
|
19
|
-
project: { id: { $eq: project.id } },
|
|
20
|
-
availableChannel: { id: { $eq: 'xxx' } },
|
|
21
|
-
id: { $eq: 'xxx' }
|
|
22
|
-
},
|
|
23
|
-
['availableChannel', 'productID']
|
|
24
|
-
);
|
|
25
|
-
// tslint:disable-next-line:no-null-keyword
|
|
26
|
-
console.dir(docs, { depth: null });
|
|
27
|
-
console.log(docs.length, 'docs found');
|
|
28
|
-
} catch (error) {
|
|
29
|
-
throw await chevre.errorHandler.handleMongoError(error);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
main()
|
|
34
|
-
.then(() => {
|
|
35
|
-
console.log('success!');
|
|
36
|
-
})
|
|
37
|
-
.catch(console.error);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const { PROJECT_ID } = process.env;
|
|
7
|
-
const formatter = new Intl.NumberFormat('ja-JP');
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
let startTime: [number, number] = process.hrtime();
|
|
12
|
-
let diff: [number, number] = process.hrtime(startTime);
|
|
13
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
14
|
-
|
|
15
|
-
setInterval(
|
|
16
|
-
async () => {
|
|
17
|
-
startTime = process.hrtime();
|
|
18
|
-
const result = await (await chevre.service.offer.createService()).findEventSeatOffersBySection({
|
|
19
|
-
limit: 100,
|
|
20
|
-
page: 10,
|
|
21
|
-
projectId: String(PROJECT_ID),
|
|
22
|
-
sellerId: '59d20831e53ebc2b4e774466',
|
|
23
|
-
eventId: '693622f7876e9977c32ae270',
|
|
24
|
-
/**
|
|
25
|
-
* セクションコード
|
|
26
|
-
*/
|
|
27
|
-
sectionCode: 'Default'
|
|
28
|
-
})({
|
|
29
|
-
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
30
|
-
seat: await chevre.repository.place.Seat.createInstance(mongoose.connection),
|
|
31
|
-
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection })
|
|
32
|
-
});
|
|
33
|
-
diff = process.hrtime(startTime);
|
|
34
|
-
// tslint:disable-next-line:no-null-keyword
|
|
35
|
-
console.dir(result, { depth: null });
|
|
36
|
-
console.log(result.length, 'results found');
|
|
37
|
-
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
38
|
-
},
|
|
39
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
40
|
-
1000
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
main()
|
|
45
|
-
.then()
|
|
46
|
-
.catch(console.error);
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import { CognitoIdentityProvider, ListUserPoolClientsCommandOutput, UserPoolClientDescription } from '@aws-sdk/client-cognito-identity-provider';
|
|
3
|
-
import { fromEnv } from '@aws-sdk/credential-providers';
|
|
4
|
-
import mongoose from 'mongoose';
|
|
5
|
-
|
|
6
|
-
import { chevre } from '../../../../lib/index';
|
|
7
|
-
|
|
8
|
-
const USERPOOL_PROVIDER_NAME = (typeof process.env.DISCONTINUE_PEOPLE_USERPOOL_PROVIDER_NAME === 'string')
|
|
9
|
-
? process.env.DISCONTINUE_PEOPLE_USERPOOL_PROVIDER_NAME
|
|
10
|
-
: 'SSKTS';
|
|
11
|
-
|
|
12
|
-
// tslint:disable-next-line:max-func-body-length
|
|
13
|
-
async function main(): Promise<void> {
|
|
14
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
15
|
-
|
|
16
|
-
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
17
|
-
const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
|
|
18
|
-
if (typeof setting?.userPoolIdNew !== 'string') {
|
|
19
|
-
throw new chevre.factory.errors.NotFound('setting.userPoolIdNew');
|
|
20
|
-
}
|
|
21
|
-
const userPoolId: string = setting.userPoolIdNew;
|
|
22
|
-
|
|
23
|
-
const awsCredentials = fromEnv();
|
|
24
|
-
const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
|
|
25
|
-
apiVersion: 'latest',
|
|
26
|
-
region: 'ap-northeast-1',
|
|
27
|
-
credentials: awsCredentials
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// create user
|
|
31
|
-
const newPersonRepo = await chevre.repository.Person.createInstance({
|
|
32
|
-
userPoolId: userPoolId,
|
|
33
|
-
cognitoIdentityServiceProvider
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const clients: UserPoolClientDescription[] = [];
|
|
37
|
-
let nextToken: string | undefined = '';
|
|
38
|
-
let page: number = 0;
|
|
39
|
-
while (typeof nextToken === 'string') {
|
|
40
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
41
|
-
if (page > 1) {
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
page += 1;
|
|
46
|
-
console.log('listUserPoolClients processing...', nextToken, page);
|
|
47
|
-
const listUserPoolClientsResult =
|
|
48
|
-
<ListUserPoolClientsCommandOutput>await newPersonRepo.cognitoIdentityServiceProvider.listUserPoolClients(
|
|
49
|
-
{
|
|
50
|
-
MaxResults: 50,
|
|
51
|
-
UserPoolId: userPoolId,
|
|
52
|
-
...(typeof nextToken === 'string' && nextToken !== '') ? { NextToken: nextToken } : undefined
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
// tslint:disable-next-line:no-null-keyword
|
|
56
|
-
console.dir(listUserPoolClientsResult.UserPoolClients?.at(0), { depth: null });
|
|
57
|
-
nextToken = listUserPoolClientsResult.NextToken;
|
|
58
|
-
if (Array.isArray(listUserPoolClientsResult.UserPoolClients)) {
|
|
59
|
-
clients.push(...listUserPoolClientsResult.UserPoolClients);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
console.log('listUsersInGroup processed', nextToken, page);
|
|
63
|
-
console.log(clients.length, 'users found');
|
|
64
|
-
|
|
65
|
-
let i = 0;
|
|
66
|
-
let providerSupportedCount = 0;
|
|
67
|
-
for (const client of clients) {
|
|
68
|
-
i += 1;
|
|
69
|
-
|
|
70
|
-
const ClientId = client.ClientId;
|
|
71
|
-
|
|
72
|
-
// disable link provider
|
|
73
|
-
const describeUserPoolClientResult = await newPersonRepo.cognitoIdentityServiceProvider.describeUserPoolClient({
|
|
74
|
-
UserPoolId: userPoolId,
|
|
75
|
-
ClientId
|
|
76
|
-
});
|
|
77
|
-
const codeFlowAllowed = describeUserPoolClientResult.UserPoolClient?.AllowedOAuthFlows?.some(
|
|
78
|
-
(flow) => flow !== 'client_credentials'
|
|
79
|
-
);
|
|
80
|
-
if (codeFlowAllowed) {
|
|
81
|
-
const providerSupported = describeUserPoolClientResult.UserPoolClient?.SupportedIdentityProviders?.some(
|
|
82
|
-
(provider) => provider === USERPOOL_PROVIDER_NAME
|
|
83
|
-
);
|
|
84
|
-
if (providerSupported) {
|
|
85
|
-
providerSupportedCount += 1;
|
|
86
|
-
console.log(
|
|
87
|
-
'describeUserPoolClientResult:',
|
|
88
|
-
describeUserPoolClientResult.UserPoolClient?.AllowedOAuthFlows,
|
|
89
|
-
describeUserPoolClientResult.UserPoolClient?.AllowedOAuthScopes,
|
|
90
|
-
describeUserPoolClientResult.UserPoolClient?.SupportedIdentityProviders,
|
|
91
|
-
describeUserPoolClientResult.UserPoolClient?.ClientName,
|
|
92
|
-
ClientId, i
|
|
93
|
-
);
|
|
94
|
-
} else {
|
|
95
|
-
console.log(
|
|
96
|
-
'describeUserPoolClientResult:',
|
|
97
|
-
describeUserPoolClientResult.UserPoolClient?.AllowedOAuthFlows,
|
|
98
|
-
describeUserPoolClientResult.UserPoolClient?.AllowedOAuthScopes,
|
|
99
|
-
describeUserPoolClientResult.UserPoolClient?.SupportedIdentityProviders,
|
|
100
|
-
describeUserPoolClientResult.UserPoolClient?.ClientName,
|
|
101
|
-
ClientId, i
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
console.log(
|
|
106
|
-
'describeUserPoolClientResult:',
|
|
107
|
-
describeUserPoolClientResult.UserPoolClient?.AllowedOAuthFlows,
|
|
108
|
-
describeUserPoolClientResult.UserPoolClient?.ClientName,
|
|
109
|
-
ClientId, i
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
console.log(clients.length, 'clients processed');
|
|
115
|
-
console.log(providerSupportedCount, 'clients supported');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
main()
|
|
119
|
-
.then()
|
|
120
|
-
.catch(console.error);
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import { CognitoIdentityProvider, ListUsersInGroupCommandOutput, UserType } from '@aws-sdk/client-cognito-identity-provider';
|
|
3
|
-
import { fromEnv } from '@aws-sdk/credential-providers';
|
|
4
|
-
import moment from 'moment';
|
|
5
|
-
import mongoose from 'mongoose';
|
|
6
|
-
|
|
7
|
-
import { chevre } from '../../../../lib/index';
|
|
8
|
-
|
|
9
|
-
const USERPOOL_PROVIDER_NAME = (typeof process.env.DISCONTINUE_PEOPLE_USERPOOL_PROVIDER_NAME === 'string')
|
|
10
|
-
? process.env.DISCONTINUE_PEOPLE_USERPOOL_PROVIDER_NAME
|
|
11
|
-
: 'SSKTS';
|
|
12
|
-
|
|
13
|
-
// tslint:disable-next-line:max-func-body-length
|
|
14
|
-
async function main(): Promise<void> {
|
|
15
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
16
|
-
|
|
17
|
-
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
18
|
-
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
19
|
-
const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
|
|
20
|
-
if (typeof setting?.userPoolIdNew !== 'string') {
|
|
21
|
-
throw new chevre.factory.errors.NotFound('setting.userPoolIdNew');
|
|
22
|
-
}
|
|
23
|
-
const userPoolId: string = setting.userPoolIdNew;
|
|
24
|
-
const USER_GROUP_NAME = `${userPoolId}_${USERPOOL_PROVIDER_NAME}`; // 'ap-northeast-1_XXXXXXXXX_SSKTS',
|
|
25
|
-
|
|
26
|
-
const awsCredentials = fromEnv();
|
|
27
|
-
const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
|
|
28
|
-
apiVersion: 'latest',
|
|
29
|
-
region: 'ap-northeast-1',
|
|
30
|
-
credentials: awsCredentials
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// create user
|
|
34
|
-
const newPersonRepo = await chevre.repository.Person.createInstance({
|
|
35
|
-
userPoolId: userPoolId,
|
|
36
|
-
cognitoIdentityServiceProvider
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const users: UserType[] = [];
|
|
40
|
-
let nextToken: string | undefined = '';
|
|
41
|
-
let page: number = 0;
|
|
42
|
-
while (typeof nextToken === 'string') {
|
|
43
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
44
|
-
// if (page > 1000) {
|
|
45
|
-
// break;
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
|
-
page += 1;
|
|
49
|
-
console.log('listUsersInGroup processing...', nextToken, page);
|
|
50
|
-
const listUsersInGroupResult = <ListUsersInGroupCommandOutput>await newPersonRepo.cognitoIdentityServiceProvider.listUsersInGroup(
|
|
51
|
-
{
|
|
52
|
-
Limit: 50,
|
|
53
|
-
UserPoolId: userPoolId,
|
|
54
|
-
GroupName: USER_GROUP_NAME,
|
|
55
|
-
...(typeof nextToken === 'string' && nextToken !== '') ? { NextToken: nextToken } : undefined
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
// tslint:disable-next-line:no-null-keyword
|
|
59
|
-
console.dir(listUsersInGroupResult.Users?.at(0), { depth: null });
|
|
60
|
-
nextToken = listUsersInGroupResult.NextToken;
|
|
61
|
-
if (Array.isArray(listUsersInGroupResult.Users)) {
|
|
62
|
-
users.push(...listUsersInGroupResult.Users);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
console.log('listUsersInGroup processed', nextToken, page);
|
|
66
|
-
console.log(users.length, 'users found');
|
|
67
|
-
|
|
68
|
-
const someMonthsAgo = moment()
|
|
69
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
70
|
-
.add(-3, 'months');
|
|
71
|
-
let i = 0;
|
|
72
|
-
for (const user of users) {
|
|
73
|
-
i += 1;
|
|
74
|
-
const isSSKTSMember = user.Username?.startsWith(USERPOOL_PROVIDER_NAME, 0);
|
|
75
|
-
if (!isSSKTSMember) {
|
|
76
|
-
console.error(user);
|
|
77
|
-
throw new Error('not ssktsMember');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const sub = user.Attributes?.find(({ Name }) => Name === 'sub')?.Value;
|
|
81
|
-
|
|
82
|
-
// 注文が存在しなければ削除
|
|
83
|
-
console.log('searching orders...', user.Username, sub, i);
|
|
84
|
-
const existingOrders = await orderRepo.projectFields(
|
|
85
|
-
{
|
|
86
|
-
limit: 1,
|
|
87
|
-
page: 1,
|
|
88
|
-
customer: { ids: [String(sub)] }
|
|
89
|
-
},
|
|
90
|
-
{ inclusion: ['orderNumber'] }
|
|
91
|
-
);
|
|
92
|
-
console.log(existingOrders.length, 'existingOrders found', user.Username, sub, i);
|
|
93
|
-
|
|
94
|
-
if (existingOrders.length > 0) {
|
|
95
|
-
continue;
|
|
96
|
-
} else {
|
|
97
|
-
if (user.UserLastModifiedDate instanceof Date) {
|
|
98
|
-
if (moment(user.UserLastModifiedDate)
|
|
99
|
-
.isBefore(someMonthsAgo)) {
|
|
100
|
-
console.log('adminDeleteUser prossing...', user.Username, sub);
|
|
101
|
-
const adminDeleteUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDeleteUser({
|
|
102
|
-
UserPoolId: userPoolId,
|
|
103
|
-
Username: user.Username
|
|
104
|
-
});
|
|
105
|
-
console.log('adminDeleteUser processed.', user.Username, sub, adminDeleteUserResult);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// if (user.Enabled === true) {
|
|
110
|
-
// console.log('disabling...', user.Username, sub);
|
|
111
|
-
// // disable link provider
|
|
112
|
-
// const adminDisableUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDisableUser({
|
|
113
|
-
// UserPoolId: userPoolId,
|
|
114
|
-
// Username: user.Username
|
|
115
|
-
// });
|
|
116
|
-
// console.log('disabled.', user.Username, sub, adminDisableUserResult);
|
|
117
|
-
// } else {
|
|
118
|
-
// if (user.UserLastModifiedDate instanceof Date) {
|
|
119
|
-
// if (moment(user.UserLastModifiedDate)
|
|
120
|
-
// .isBefore(oneMonthAgo)) {
|
|
121
|
-
// console.log('adminDeleteUser prossing...', user.Username, sub);
|
|
122
|
-
// const adminDeleteUserResult = await newPersonRepo.cognitoIdentityServiceProvider.adminDeleteUser({
|
|
123
|
-
// UserPoolId: userPoolId,
|
|
124
|
-
// Username: user.Username
|
|
125
|
-
// });
|
|
126
|
-
// console.log('adminDeleteUser processed.', user.Username, sub, adminDeleteUserResult);
|
|
127
|
-
// }
|
|
128
|
-
// }
|
|
129
|
-
// }
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
console.log(users.length, 'users processed');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
main()
|
|
137
|
-
.then(() => {
|
|
138
|
-
console.log('success!');
|
|
139
|
-
})
|
|
140
|
-
.catch(console.error);
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import { CognitoIdentityProvider, ListUsersInGroupCommandOutput, UserType } from '@aws-sdk/client-cognito-identity-provider';
|
|
3
|
-
import { fromEnv } from '@aws-sdk/credential-providers';
|
|
4
|
-
import moment from 'moment';
|
|
5
|
-
import mongoose from 'mongoose';
|
|
6
|
-
|
|
7
|
-
import { chevre } from '../../../../lib/index';
|
|
8
|
-
|
|
9
|
-
const TIMEOUT_MS = 5000;
|
|
10
|
-
const USERPOOL_PROVIDER_NAME = (typeof process.env.DISCONTINUE_PEOPLE_USERPOOL_PROVIDER_NAME === 'string')
|
|
11
|
-
? process.env.DISCONTINUE_PEOPLE_USERPOOL_PROVIDER_NAME
|
|
12
|
-
: 'SSKTS';
|
|
13
|
-
|
|
14
|
-
// tslint:disable-next-line:max-func-body-length
|
|
15
|
-
async function main(): Promise<void> {
|
|
16
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
17
|
-
|
|
18
|
-
const orderRepo = await chevre.repository.Order.createInstance(mongoose.connection);
|
|
19
|
-
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
20
|
-
const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdNew']);
|
|
21
|
-
if (typeof setting?.userPoolIdNew !== 'string') {
|
|
22
|
-
throw new chevre.factory.errors.NotFound('setting.userPoolIdNew');
|
|
23
|
-
}
|
|
24
|
-
const userPoolId: string = setting.userPoolIdNew;
|
|
25
|
-
const USER_GROUP_NAME = `${userPoolId}_${USERPOOL_PROVIDER_NAME}`; // 'ap-northeast-1_XXXXXXXXX_SSKTS',
|
|
26
|
-
|
|
27
|
-
const awsCredentials = fromEnv();
|
|
28
|
-
const cognitoIdentityServiceProvider = new CognitoIdentityProvider({
|
|
29
|
-
apiVersion: 'latest',
|
|
30
|
-
region: 'ap-northeast-1',
|
|
31
|
-
credentials: awsCredentials
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// create user
|
|
35
|
-
const newPersonRepo = await chevre.repository.Person.createInstance({
|
|
36
|
-
userPoolId: userPoolId,
|
|
37
|
-
cognitoIdentityServiceProvider
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const users: UserType[] = [];
|
|
41
|
-
let nextToken: string | undefined = '';
|
|
42
|
-
let page: number = 0;
|
|
43
|
-
while (typeof nextToken === 'string') {
|
|
44
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
45
|
-
if (page > 1000) {
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
page += 1;
|
|
50
|
-
console.log('listUsersInGroup processing...', nextToken, page);
|
|
51
|
-
const listUsersInGroupResult = <ListUsersInGroupCommandOutput>await newPersonRepo.cognitoIdentityServiceProvider.listUsersInGroup(
|
|
52
|
-
{
|
|
53
|
-
Limit: 50,
|
|
54
|
-
// Limit: 1,
|
|
55
|
-
UserPoolId: userPoolId,
|
|
56
|
-
GroupName: USER_GROUP_NAME,
|
|
57
|
-
...(typeof nextToken === 'string' && nextToken !== '') ? { NextToken: nextToken } : undefined
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
// tslint:disable-next-line:no-null-keyword
|
|
61
|
-
console.dir(listUsersInGroupResult.Users?.at(0), { depth: null });
|
|
62
|
-
nextToken = listUsersInGroupResult.NextToken;
|
|
63
|
-
if (Array.isArray(listUsersInGroupResult.Users)) {
|
|
64
|
-
users.push(...listUsersInGroupResult.Users);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
console.log('listUsersInGroup processed', nextToken, page);
|
|
68
|
-
console.log(users.length, 'users found');
|
|
69
|
-
|
|
70
|
-
const oneMonthAgo = moment()
|
|
71
|
-
.add(-1, 'months');
|
|
72
|
-
let i = 0;
|
|
73
|
-
for (const user of users) {
|
|
74
|
-
i += 1;
|
|
75
|
-
await new Promise<void>((resolve) => {
|
|
76
|
-
setTimeout(
|
|
77
|
-
() => {
|
|
78
|
-
resolve();
|
|
79
|
-
},
|
|
80
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
81
|
-
500
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
const isSSKTSMember = user.Username?.startsWith(USERPOOL_PROVIDER_NAME, 0);
|
|
85
|
-
if (!isSSKTSMember) {
|
|
86
|
-
console.error(user);
|
|
87
|
-
throw new Error('not ssktsMember');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const sub = user.Attributes?.find(({ Name }) => Name === 'sub')?.Value;
|
|
91
|
-
|
|
92
|
-
// 注文が存在しなければ削除
|
|
93
|
-
console.log('searching orders...', user.Username, sub, i);
|
|
94
|
-
const existingOrders = await orderRepo.projectFields(
|
|
95
|
-
{
|
|
96
|
-
limit: 1,
|
|
97
|
-
page: 1,
|
|
98
|
-
customer: { ids: [String(sub)] }
|
|
99
|
-
},
|
|
100
|
-
{ inclusion: ['orderNumber'] }
|
|
101
|
-
);
|
|
102
|
-
console.log(existingOrders.length, 'existingOrders found', user.Username, sub, i);
|
|
103
|
-
|
|
104
|
-
if (existingOrders.length > 0) {
|
|
105
|
-
continue;
|
|
106
|
-
} else {
|
|
107
|
-
// if (user.Enabled === true && sub === '46686164-2c18-491a-8594-52c944d895e9') {
|
|
108
|
-
if (user.Enabled === true) {
|
|
109
|
-
console.log('disabling?...', user.Username, sub, i);
|
|
110
|
-
if (user.UserLastModifiedDate instanceof Date) {
|
|
111
|
-
if (moment(user.UserLastModifiedDate)
|
|
112
|
-
.isBefore(oneMonthAgo)) {
|
|
113
|
-
console.log('adminDeleteUser prossing...', user.Username, sub, i);
|
|
114
|
-
try {
|
|
115
|
-
const url = `${String(process.env.DISCONTINUE_PEOPLE_URL)}?personId=${sub}`;
|
|
116
|
-
const res = await fetch(
|
|
117
|
-
url,
|
|
118
|
-
{
|
|
119
|
-
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
120
|
-
method: 'GET'
|
|
121
|
-
}
|
|
122
|
-
);
|
|
123
|
-
// const result = await res.text();
|
|
124
|
-
console.log('res.status', res.status, user.Username, sub, i);
|
|
125
|
-
} catch (err) {
|
|
126
|
-
console.error(err);
|
|
127
|
-
}
|
|
128
|
-
console.log('adminDeleteUser processed.', user.Username, sub, i);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
if (user.UserLastModifiedDate instanceof Date) {
|
|
133
|
-
if (moment(user.UserLastModifiedDate)
|
|
134
|
-
.isBefore(oneMonthAgo)) {
|
|
135
|
-
console.log('adminDeleteUser prossing...', user.Username, sub, i);
|
|
136
|
-
try {
|
|
137
|
-
const url = `${String(process.env.DISCONTINUE_PEOPLE_URL)}?personId=${sub}`;
|
|
138
|
-
const res = await fetch(
|
|
139
|
-
url,
|
|
140
|
-
{
|
|
141
|
-
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
142
|
-
method: 'GET'
|
|
143
|
-
}
|
|
144
|
-
);
|
|
145
|
-
// const result = await res.text();
|
|
146
|
-
console.log('res.status', res.status, user.Username, sub, i);
|
|
147
|
-
} catch (err) {
|
|
148
|
-
console.error(err);
|
|
149
|
-
}
|
|
150
|
-
console.log('adminDeleteUser processed.', user.Username, sub, i);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
console.log(users.length, 'users processed');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
main()
|
|
161
|
-
.then()
|
|
162
|
-
.catch(console.error);
|