@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,113 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import { CognitoIdentityProvider, ListUsersCommandOutput, UserType } from '@aws-sdk/client-cognito-identity-provider';
|
|
3
|
-
import { fromEnv } from '@aws-sdk/credential-providers';
|
|
4
|
-
// import * as GMO from '@motionpicture/gmo-service';
|
|
5
|
-
import mongoose from 'mongoose';
|
|
6
|
-
|
|
7
|
-
// import { deleteCreditCardsById, getCreditCardPaymentServiceChannel } from '../../../../lib/chevre/service/task/deletePerson';
|
|
8
|
-
import { chevre } from '../../../../lib/index';
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main(): Promise<void> {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
// const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
15
|
-
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
16
|
-
const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdOld']);
|
|
17
|
-
if (typeof setting?.userPoolIdOld !== 'string') {
|
|
18
|
-
throw new chevre.factory.errors.NotFound('setting.userPoolIdOld');
|
|
19
|
-
}
|
|
20
|
-
// const userPoolId: string = setting.userPoolIdNew;
|
|
21
|
-
const userPoolId: string = setting.userPoolIdOld;
|
|
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 oldPersonRepo = await chevre.repository.Person.createInstance({
|
|
32
|
-
userPoolId: userPoolId,
|
|
33
|
-
cognitoIdentityServiceProvider
|
|
34
|
-
});
|
|
35
|
-
// const credentials = await getCreditCardPaymentServiceChannel({
|
|
36
|
-
// project: { id: 'xxxxxxxx' },
|
|
37
|
-
// paymentMethodType: 'CreditCard'
|
|
38
|
-
// })({ paymentService: paymentServiceRepo });
|
|
39
|
-
// const creditCardRepo = await chevre.repository.paymentMethod.CreditCard.createInstance({
|
|
40
|
-
// siteId: credentials.siteId,
|
|
41
|
-
// sitePass: credentials.sitePass,
|
|
42
|
-
// cardService: new GMO.service.Card(
|
|
43
|
-
// {
|
|
44
|
-
// endpoint: credentials.endpoint,
|
|
45
|
-
// useFetch: true
|
|
46
|
-
// },
|
|
47
|
-
// {
|
|
48
|
-
// timeout: 20000 // cronで実行の場合は長めに(2024-10-05~)
|
|
49
|
-
// }
|
|
50
|
-
// )
|
|
51
|
-
// });
|
|
52
|
-
|
|
53
|
-
const users: UserType[] = [];
|
|
54
|
-
let nextToken: string | undefined = '';
|
|
55
|
-
let page: number = 0;
|
|
56
|
-
while (typeof nextToken === 'string') {
|
|
57
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
58
|
-
// if (page > 1000) {
|
|
59
|
-
// break;
|
|
60
|
-
// }
|
|
61
|
-
|
|
62
|
-
page += 1;
|
|
63
|
-
console.log('listUsersInGroup processing...', nextToken, page);
|
|
64
|
-
const listUsersResult = <ListUsersCommandOutput>await oldPersonRepo.cognitoIdentityServiceProvider.listUsers(
|
|
65
|
-
{
|
|
66
|
-
Limit: 50,
|
|
67
|
-
UserPoolId: userPoolId,
|
|
68
|
-
...(typeof nextToken === 'string' && nextToken !== '') ? { PaginationToken: nextToken } : undefined
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
// tslint:disable-next-line:no-null-keyword
|
|
72
|
-
console.dir(listUsersResult.Users?.at(0), { depth: null });
|
|
73
|
-
nextToken = listUsersResult.PaginationToken;
|
|
74
|
-
if (Array.isArray(listUsersResult.Users)) {
|
|
75
|
-
users.push(...listUsersResult.Users);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
console.log('listUsers processed', nextToken, page);
|
|
79
|
-
console.log(users.length, 'users found');
|
|
80
|
-
|
|
81
|
-
let i = 0;
|
|
82
|
-
for (const user of users) {
|
|
83
|
-
i += 1;
|
|
84
|
-
|
|
85
|
-
const sub = user.Attributes?.find(({ Name }) => Name === 'sub')?.Value;
|
|
86
|
-
|
|
87
|
-
// if (i > 10) {
|
|
88
|
-
// continue;
|
|
89
|
-
// }
|
|
90
|
-
|
|
91
|
-
console.log('deleteCreditCardsById prossing...', user.Username, sub, i);
|
|
92
|
-
// await deleteCreditCardsById(
|
|
93
|
-
// {
|
|
94
|
-
// id: String(user.Username),
|
|
95
|
-
// useUsernameAsGMOMemberId: false
|
|
96
|
-
// },
|
|
97
|
-
// { userPoolIdOld: userPoolId }
|
|
98
|
-
// )(<any>{
|
|
99
|
-
// person: undefined,
|
|
100
|
-
// creditCard: creditCardRepo,
|
|
101
|
-
// cognitoIdentityServiceProvider: undefined
|
|
102
|
-
// });
|
|
103
|
-
console.log('deleteCreditCardsById processed.', user.Username, sub, i);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
console.log(users.length, 'users processed');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
main()
|
|
110
|
-
.then(() => {
|
|
111
|
-
console.log('success!');
|
|
112
|
-
})
|
|
113
|
-
.catch(console.error);
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider';
|
|
2
|
-
import { fromEnv } from '@aws-sdk/credential-providers';
|
|
3
|
-
|
|
4
|
-
// tslint:disable:no-console no-magic-numbers
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
const awsCredentials = fromEnv();
|
|
9
|
-
const personRepo = await chevre.repository.Person.createInstance({
|
|
10
|
-
userPoolId: <string>process.env.COGNITO_USER_POOL_ID,
|
|
11
|
-
cognitoIdentityServiceProvider: new CognitoIdentityProvider({
|
|
12
|
-
apiVersion: 'latest',
|
|
13
|
-
region: 'ap-northeast-1',
|
|
14
|
-
credentials: awsCredentials
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const username = 'xxx';
|
|
19
|
-
|
|
20
|
-
let profile = await personRepo.getUserAttributes({
|
|
21
|
-
username: username
|
|
22
|
-
});
|
|
23
|
-
console.log('profile:', profile);
|
|
24
|
-
|
|
25
|
-
await personRepo.updateProfile({
|
|
26
|
-
username: username,
|
|
27
|
-
profile: {
|
|
28
|
-
familyName: 'テスト',
|
|
29
|
-
givenName: profile.givenName,
|
|
30
|
-
telephone: profile.telephone,
|
|
31
|
-
email: profile.email,
|
|
32
|
-
additionalProperty: [
|
|
33
|
-
// {
|
|
34
|
-
// name: 'email_verified',
|
|
35
|
-
// value: 'true'
|
|
36
|
-
// },
|
|
37
|
-
// {
|
|
38
|
-
// name: 'custom:postalCode',
|
|
39
|
-
// value: '999-9999'
|
|
40
|
-
// }
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
profile = await personRepo.getUserAttributes({
|
|
46
|
-
username: username
|
|
47
|
-
});
|
|
48
|
-
console.log('profile:', profile);
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
main()
|
|
53
|
-
.then(() => {
|
|
54
|
-
console.log('success!');
|
|
55
|
-
})
|
|
56
|
-
.catch(console.error);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as redis from 'redis';
|
|
3
|
-
import mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const project = { typeOf: chevre.factory.organizationType.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 entranceGateRepo =
|
|
13
|
-
await chevre.repository.place.EntranceGate.createInstance(mongoose.connection, { id: '5bfb841d5a78d7948369979a' });
|
|
14
|
-
|
|
15
|
-
const gates = await entranceGateRepo.findEntranceGates({
|
|
16
|
-
limit: 10,
|
|
17
|
-
page: 1,
|
|
18
|
-
project: { id: { $eq: project.id } }
|
|
19
|
-
// identifier: { $in: ['GATE01', 'GATE03', 'xx'] }
|
|
20
|
-
});
|
|
21
|
-
console.log(gates);
|
|
22
|
-
console.log(gates.length);
|
|
23
|
-
|
|
24
|
-
let result = await entranceGateRepo.addEntranceGatesByIdentifierIfNotExist(
|
|
25
|
-
[
|
|
26
|
-
{
|
|
27
|
-
$set: {
|
|
28
|
-
identifier: 'sample001',
|
|
29
|
-
name: { ja: 'gateNameJa' }
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
{
|
|
34
|
-
project: { id: project.id }
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
console.log(result);
|
|
38
|
-
|
|
39
|
-
result = await entranceGateRepo.updateEntranceGatesByIdentifier(
|
|
40
|
-
[
|
|
41
|
-
{
|
|
42
|
-
$set: {
|
|
43
|
-
identifier: 'sample001',
|
|
44
|
-
name: { ja: 'gateNameJaUpdated' }
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
{
|
|
49
|
-
project: { id: project.id }
|
|
50
|
-
}
|
|
51
|
-
);
|
|
52
|
-
console.log(result);
|
|
53
|
-
|
|
54
|
-
result = await entranceGateRepo.deleteEntranceGatesByIdentifier(
|
|
55
|
-
[
|
|
56
|
-
{
|
|
57
|
-
identifier: 'sample001'
|
|
58
|
-
}
|
|
59
|
-
],
|
|
60
|
-
{
|
|
61
|
-
project: { id: project.id }
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
console.log(result);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
main()
|
|
68
|
-
.then(console.log)
|
|
69
|
-
.catch(console.error);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as redis from 'redis';
|
|
3
|
-
import mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const project = { typeOf: chevre.factory.organizationType.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 posRepo = await chevre.repository.place.HasPOS.createInstance(mongoose.connection, { id: '5bfb841d5a78d7948369979a' });
|
|
13
|
-
|
|
14
|
-
const poses = await posRepo.search({
|
|
15
|
-
limit: 10,
|
|
16
|
-
page: 1,
|
|
17
|
-
project: { id: { $eq: project.id } },
|
|
18
|
-
branchCode: {
|
|
19
|
-
// $eq: '002',
|
|
20
|
-
$regex: '^0'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
console.log(poses);
|
|
24
|
-
console.log(poses.length);
|
|
25
|
-
|
|
26
|
-
// await posRepo.create({
|
|
27
|
-
// project: { id: project.id },
|
|
28
|
-
// id: '004',
|
|
29
|
-
// name: 'test'
|
|
30
|
-
// });
|
|
31
|
-
// await posRepo.update({
|
|
32
|
-
// project: { id: project.id },
|
|
33
|
-
// id: '004',
|
|
34
|
-
// name: 'test2'
|
|
35
|
-
// });
|
|
36
|
-
// await posRepo.deleteByBranchCode({
|
|
37
|
-
// project: { id: project.id },
|
|
38
|
-
// branchCode: '004'
|
|
39
|
-
// });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
main()
|
|
43
|
-
.then(console.log)
|
|
44
|
-
.catch(console.error);
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
import { chevre } from '../../../../lib/index';
|
|
4
|
-
|
|
5
|
-
const project = { typeOf: chevre.factory.organizationType.Project, id: String(process.env.PROJECT_ID) };
|
|
6
|
-
|
|
7
|
-
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
-
|
|
10
|
-
const seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
const seatingTypes = await seatRepo.aggregateSeatingTypes({
|
|
13
|
-
project: { id: { $eq: project.id } },
|
|
14
|
-
branchCode: { $in: ['A-2', 'A-1'] },
|
|
15
|
-
containedInPlace: {
|
|
16
|
-
branchCode: { $in: ['Default'] },
|
|
17
|
-
containedInPlace: {
|
|
18
|
-
branchCode: { $eq: '100' },
|
|
19
|
-
containedInPlace: { branchCode: { $eq: '118' } }
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
console.log(seatingTypes);
|
|
24
|
-
console.log(seatingTypes.length);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
main()
|
|
28
|
-
.then(console.log)
|
|
29
|
-
.catch(console.error);
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../../lib/index';
|
|
5
|
-
|
|
6
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
-
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
14
|
-
|
|
15
|
-
const cursor = movieTheaterRepo.getCursor(
|
|
16
|
-
{
|
|
17
|
-
// 'project.id': {
|
|
18
|
-
// $ne: 'sskts-development',
|
|
19
|
-
// $eq: 'ttts-development'
|
|
20
|
-
// }
|
|
21
|
-
// _id: { $eq: '67de46777ec0510590b68922' }
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
// _id: 1,
|
|
25
|
-
// about: 1,
|
|
26
|
-
// project: 1,
|
|
27
|
-
// typeOf: 1,
|
|
28
|
-
// issuedBy: 1
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
console.log('docs found');
|
|
32
|
-
|
|
33
|
-
let i = 0;
|
|
34
|
-
let updateCount = 0;
|
|
35
|
-
await cursor.eachAsync(async (doc) => {
|
|
36
|
-
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
37
|
-
|
|
38
|
-
i += 1;
|
|
39
|
-
const { hasEntranceGate } = movieTheater;
|
|
40
|
-
if (!Array.isArray(hasEntranceGate)) {
|
|
41
|
-
throw new Error('hasEntranceGateLength must be an array');
|
|
42
|
-
}
|
|
43
|
-
const hasEntranceGateLength = hasEntranceGate?.length;
|
|
44
|
-
if (typeof hasEntranceGateLength !== 'number') {
|
|
45
|
-
throw new Error('hasEntranceGateLength undefined');
|
|
46
|
-
}
|
|
47
|
-
const uniqueIdentifiersByMovieTheater = hasEntranceGate.map(({ identifier }) => identifier);
|
|
48
|
-
|
|
49
|
-
const entranceGateRepo = await chevre.repository.place.EntranceGate.createInstance(mongoose.connection, { id: movieTheater.id });
|
|
50
|
-
const entranceGates = await entranceGateRepo.findEntranceGates({
|
|
51
|
-
limit: 100,
|
|
52
|
-
page: 1,
|
|
53
|
-
project: { id: { $eq: movieTheater.project.id } }
|
|
54
|
-
});
|
|
55
|
-
const entranceGateCount = entranceGates.length;
|
|
56
|
-
const uniqueIdentifiers = entranceGates.map(({ identifier }) => identifier);
|
|
57
|
-
|
|
58
|
-
const countMatched = hasEntranceGateLength === entranceGateCount;
|
|
59
|
-
const identifiersMatched = uniqueIdentifiersByMovieTheater.length === uniqueIdentifiers.length
|
|
60
|
-
&& uniqueIdentifiersByMovieTheater.every((identifier) => uniqueIdentifiers.includes(identifier));
|
|
61
|
-
console.log(uniqueIdentifiersByMovieTheater, uniqueIdentifiers);
|
|
62
|
-
|
|
63
|
-
console.log(
|
|
64
|
-
'checking...', movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
|
|
65
|
-
if (countMatched && identifiersMatched) {
|
|
66
|
-
console.log(
|
|
67
|
-
'matched.', movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
|
|
68
|
-
} else {
|
|
69
|
-
updateCount += 1;
|
|
70
|
-
console.log(
|
|
71
|
-
'unmatched.',
|
|
72
|
-
movieTheater.project.id, movieTheater.id, hasEntranceGateLength, entranceGateCount, i);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
console.log(i, 'docs checked');
|
|
77
|
-
console.log(updateCount, 'docs updated');
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
main()
|
|
81
|
-
.then()
|
|
82
|
-
.catch(console.error);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console no-magic-numbers
|
|
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 roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
11
|
-
|
|
12
|
-
const rooms = await roomRepo.searchScreeningRooms({
|
|
13
|
-
$projection: { sectionCount: 1 }
|
|
14
|
-
});
|
|
15
|
-
console.log('docs found');
|
|
16
|
-
console.log(rooms);
|
|
17
|
-
|
|
18
|
-
const mutipleSectionRooms = rooms.filter((room) => typeof room.sectionCount === 'number' && room.sectionCount > 1);
|
|
19
|
-
console.log(mutipleSectionRooms);
|
|
20
|
-
|
|
21
|
-
console.log(rooms.length, 'rooms');
|
|
22
|
-
console.log(mutipleSectionRooms.length, 'mutipleSectionRooms');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
main()
|
|
26
|
-
.then()
|
|
27
|
-
.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
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const rooms = await roomRepo.findRooms({
|
|
14
|
-
limit: 20,
|
|
15
|
-
page: 1,
|
|
16
|
-
project: { id: { $eq: project.id } }
|
|
17
|
-
});
|
|
18
|
-
console.log(rooms);
|
|
19
|
-
console.log(rooms.length);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
main()
|
|
23
|
-
.then(console.log)
|
|
24
|
-
.catch(console.error);
|
|
@@ -1,28 +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 sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const sections = await sectionRepo.findSections({
|
|
14
|
-
limit: 10,
|
|
15
|
-
page: 1,
|
|
16
|
-
project: { id: { $eq: project.id } },
|
|
17
|
-
containedInPlace: {
|
|
18
|
-
branchCode: { $eq: '10' },
|
|
19
|
-
containedInPlace: { id: { $eq: '5bfb841d5a78d7948369979a' } }
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
console.log(sections);
|
|
23
|
-
console.log(sections.length);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
main()
|
|
27
|
-
.then(console.log)
|
|
28
|
-
.catch(console.error);
|
|
@@ -1,50 +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 SCREEN_CODE = '100';
|
|
8
|
-
const MOVIE_THEATER_CODE = '118';
|
|
9
|
-
const SELLER_ID = '59d20831e53ebc2b4e774466';
|
|
10
|
-
|
|
11
|
-
const formatter = new Intl.NumberFormat('ja-JP');
|
|
12
|
-
|
|
13
|
-
// tslint:disable-next-line:max-func-body-length
|
|
14
|
-
async function main() {
|
|
15
|
-
let startTime: [number, number] = process.hrtime();
|
|
16
|
-
let diff: [number, number] = process.hrtime(startTime);
|
|
17
|
-
|
|
18
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
19
|
-
|
|
20
|
-
const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
|
|
21
|
-
|
|
22
|
-
setInterval(
|
|
23
|
-
async () => {
|
|
24
|
-
startTime = process.hrtime();
|
|
25
|
-
const seats = await sectionRepo.findSectionsByRoom(
|
|
26
|
-
{
|
|
27
|
-
limit: 10,
|
|
28
|
-
page: 1,
|
|
29
|
-
projectId: PROJECT_ID,
|
|
30
|
-
sellerId: SELLER_ID,
|
|
31
|
-
movieTheaterCode: MOVIE_THEATER_CODE,
|
|
32
|
-
roomCode: SCREEN_CODE
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
diff = process.hrtime(startTime);
|
|
36
|
-
// tslint:disable-next-line:no-null-keyword
|
|
37
|
-
console.dir(seats, { depth: null });
|
|
38
|
-
console.log(seats.length, 'sections found');
|
|
39
|
-
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
40
|
-
},
|
|
41
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
42
|
-
1000
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
main()
|
|
47
|
-
.then(() => {
|
|
48
|
-
console.log('success!');
|
|
49
|
-
})
|
|
50
|
-
.catch(console.error);
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import moment from 'moment-timezone';
|
|
3
|
-
import mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
-
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
9
|
-
|
|
10
|
-
// tslint:disable-next-line:max-func-body-length
|
|
11
|
-
async function main() {
|
|
12
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
-
|
|
14
|
-
const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
15
|
-
const sectionRepo = await chevre.repository.place.Section.createInstance(mongoose.connection);
|
|
16
|
-
|
|
17
|
-
const cursor = roomRepo.getCursor(
|
|
18
|
-
{
|
|
19
|
-
'project.id': {
|
|
20
|
-
$ne: 'sskts-development',
|
|
21
|
-
$eq: 'ttts-development'
|
|
22
|
-
}
|
|
23
|
-
// _id: { $eq: '67de46777ec0510590b68922' }
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
// _id: 1,
|
|
27
|
-
// about: 1,
|
|
28
|
-
// project: 1,
|
|
29
|
-
// typeOf: 1,
|
|
30
|
-
// issuedBy: 1
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
console.log('docs found');
|
|
34
|
-
|
|
35
|
-
const timestamp = moment()
|
|
36
|
-
.tz('Asia/Tokyo')
|
|
37
|
-
.format('YYYYMMDDHHmmss');
|
|
38
|
-
|
|
39
|
-
let i = 0;
|
|
40
|
-
let updateCount = 0;
|
|
41
|
-
await cursor.eachAsync(async (doc) => {
|
|
42
|
-
const room: chevre.factory.place.screeningRoom.IPlace = doc.toObject();
|
|
43
|
-
|
|
44
|
-
const sections = room.containsPlace;
|
|
45
|
-
if (Array.isArray(sections)) {
|
|
46
|
-
for (const section of sections) {
|
|
47
|
-
i += 1;
|
|
48
|
-
const movieTheaterCode = room.containedInPlace?.branchCode;
|
|
49
|
-
if (typeof movieTheaterCode !== 'string') {
|
|
50
|
-
throw new Error('movieTheaterCode undefined');
|
|
51
|
-
}
|
|
52
|
-
const alreadyMigrated = typeof (<any>section).identifier === 'string';
|
|
53
|
-
|
|
54
|
-
if (alreadyMigrated) {
|
|
55
|
-
console.log(
|
|
56
|
-
'already migrated.', room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
57
|
-
} else {
|
|
58
|
-
// if (typeof identity.id !== 'string') {
|
|
59
|
-
// throw new Error(`id undefined ${identity.id}`);
|
|
60
|
-
// }
|
|
61
|
-
const identifier = `${movieTheaterCode}:${room.branchCode}:${section.branchCode}:${timestamp}`;
|
|
62
|
-
|
|
63
|
-
console.log(
|
|
64
|
-
'updating...',
|
|
65
|
-
identifier,
|
|
66
|
-
room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
67
|
-
await sectionRepo.migrateSectionIdentifier({
|
|
68
|
-
project: { id: room.project.id },
|
|
69
|
-
identifier,
|
|
70
|
-
branchCode: section.branchCode,
|
|
71
|
-
containedInPlace: {
|
|
72
|
-
branchCode: room.branchCode,
|
|
73
|
-
containedInPlace: {
|
|
74
|
-
branchCode: movieTheaterCode
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
updateCount += 1;
|
|
79
|
-
console.log(
|
|
80
|
-
'updated.', room.project.id, movieTheaterCode, room.branchCode, section.branchCode, i);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
console.log(i, 'docs checked');
|
|
87
|
-
console.log(updateCount, 'docs updated');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
main()
|
|
91
|
-
.then()
|
|
92
|
-
.catch(console.error);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// tslint:disable-next-line:no-implicit-dependencies
|
|
3
|
-
import { Parser } from '@json2csv/plainjs';
|
|
4
|
-
import mongoose from 'mongoose';
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
const project = { typeOf: chevre.factory.organizationType.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 seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
const seats = await seatRepo.searchSeats(
|
|
15
|
-
{
|
|
16
|
-
project: { id: { $eq: project.id } },
|
|
17
|
-
containedInPlace: {
|
|
18
|
-
// branchCode: { $eq: 'Default02' },
|
|
19
|
-
branchCode: { $eq: 'Default' },
|
|
20
|
-
containedInPlace: {
|
|
21
|
-
branchCode: { $eq: '10' },
|
|
22
|
-
containedInPlace: { branchCode: { $eq: '118' } }
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
console.log(seats);
|
|
28
|
-
console.log(seats.length, 'seats found');
|
|
29
|
-
try {
|
|
30
|
-
const opts = {
|
|
31
|
-
// formatters: {
|
|
32
|
-
// // Define how strings are formatted
|
|
33
|
-
// string: (value) => {
|
|
34
|
-
// // if (value.includes(',') || value.includes('"') || value.includes('\n')) {
|
|
35
|
-
// // return `"${value.replace(/"/g, '""')}"`; // Standard CSV escaping
|
|
36
|
-
// // }
|
|
37
|
-
// // if (value === '') {
|
|
38
|
-
// // return `""`; // Standard CSV escaping
|
|
39
|
-
// // }
|
|
40
|
-
|
|
41
|
-
// return value; // No quotes if safe
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
};
|
|
45
|
-
const parser = new Parser(opts);
|
|
46
|
-
const csv = parser.parse(seats.map((seat) => {
|
|
47
|
-
// branchCode,seatingType,name.ja,name.en
|
|
48
|
-
return {
|
|
49
|
-
branchCode: seat.branchCode,
|
|
50
|
-
...(Array.isArray(seat.seatingType) && seat.seatingType.length > 0) ? { seatingType: seat.seatingType[0] } : undefined,
|
|
51
|
-
'name.ja': (typeof seat.name?.ja === 'string') ? seat.name.ja : '',
|
|
52
|
-
'name.en': (typeof seat.name?.en === 'string') ? seat.name.en : ''
|
|
53
|
-
};
|
|
54
|
-
}));
|
|
55
|
-
console.log(csv);
|
|
56
|
-
} catch (err) {
|
|
57
|
-
console.error(err);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
main()
|
|
62
|
-
.then(console.log)
|
|
63
|
-
.catch(console.error);
|