@chevre/domain 20.1.0-alpha.8 → 20.1.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/example/src/chevre/deleteReservationTicketUnderNames.ts +20 -0
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +157 -0
- package/example/src/chevre/migrateCreativeWorkAdditionalProperties.ts +116 -0
- package/example/src/chevre/migrateEventOffersSellerMakesOffer.ts +139 -0
- package/example/src/chevre/migrateEventProjectAttributes.ts +57 -0
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +162 -0
- package/example/src/chevre/migrateSSKTEventCOAEndpoint.ts +64 -0
- package/example/src/chevre/searchEvents.ts +36 -16
- package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -4
- package/example/src/chevre/transaction/orderMembershipService.ts +0 -4
- package/lib/chevre/factory/reservedAgentIdentifireNames.d.ts +1 -0
- package/lib/chevre/factory/reservedAgentIdentifireNames.js +12 -0
- package/lib/chevre/repo/accountAction.d.ts +0 -18
- package/lib/chevre/repo/accountAction.js +402 -355
- package/lib/chevre/repo/accountTitle.d.ts +1 -0
- package/lib/chevre/repo/accountTitle.js +6 -1
- package/lib/chevre/repo/additionalProperty.d.ts +35 -0
- package/lib/chevre/repo/additionalProperty.js +205 -0
- package/lib/chevre/repo/categoryCode.d.ts +1 -0
- package/lib/chevre/repo/categoryCode.js +15 -1
- package/lib/chevre/repo/creativeWork.js +10 -1
- package/lib/chevre/repo/customer.d.ts +1 -0
- package/lib/chevre/repo/customer.js +5 -0
- package/lib/chevre/repo/event.d.ts +12 -4
- package/lib/chevre/repo/event.js +84 -48
- package/lib/chevre/repo/merchantReturnPolicy.d.ts +1 -0
- package/lib/chevre/repo/merchantReturnPolicy.js +5 -0
- package/lib/chevre/repo/mongoose/model/additionalProperty.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/additionalProperty.js +81 -0
- package/lib/chevre/repo/mongoose/model/categoryCode.js +18 -2
- package/lib/chevre/repo/mongoose/model/creativeWork.js +6 -0
- package/lib/chevre/repo/mongoose/model/event.js +6 -0
- package/lib/chevre/repo/mongoose/model/offer.js +7 -1
- package/lib/chevre/repo/mongoose/model/offerCatalog.js +21 -2
- package/lib/chevre/repo/mongoose/model/ownershipInfo.js +3 -15
- package/lib/chevre/repo/mongoose/model/place.js +24 -0
- package/lib/chevre/repo/offer.js +10 -1
- package/lib/chevre/repo/offerCatalog.js +10 -10
- package/lib/chevre/repo/person.js +4 -1
- package/lib/chevre/repo/place.d.ts +1 -0
- package/lib/chevre/repo/place.js +54 -7
- package/lib/chevre/repo/reservation.d.ts +17 -2
- package/lib/chevre/repo/reservation.js +41 -1
- package/lib/chevre/repo/transaction.js +20 -5
- package/lib/chevre/repository.d.ts +6 -3
- package/lib/chevre/repository.js +10 -5
- package/lib/chevre/service/account.d.ts +0 -4
- package/lib/chevre/service/account.js +24 -22
- package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/deposit.js +3 -3
- package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/transfer.js +3 -3
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
- package/lib/chevre/service/assetTransaction/cancelReservation/factory.js +86 -42
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +7 -18
- package/lib/chevre/service/assetTransaction/reserve/factory.js +81 -113
- package/lib/chevre/service/assetTransaction/reserve.js +41 -95
- package/lib/chevre/service/event.js +20 -6
- package/lib/chevre/service/offer/event/authorize.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize.js +65 -27
- package/lib/chevre/service/offer/event/factory.d.ts +1 -1
- package/lib/chevre/service/offer/event/factory.js +17 -12
- package/lib/chevre/service/offer/eventServiceByCOA/factory.js +19 -9
- package/lib/chevre/service/offer/factory.js +7 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +32 -22
- package/lib/chevre/service/reserve/cancelReservation.d.ts +5 -5
- package/lib/chevre/service/reserve/cancelReservation.js +260 -107
- package/lib/chevre/service/reserve/confirmReservation.js +65 -33
- package/lib/chevre/service/reserve/factory.d.ts +14 -2
- package/lib/chevre/service/reserve/factory.js +13 -6
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationConfirmed.js +85 -30
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +15 -28
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +1 -0
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +14 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +9 -4
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +10 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.d.ts +3 -1
- package/lib/chevre/service/transaction/placeOrderInProgress/validation/validateSeller.js +3 -2
- package/lib/chevre/service/transaction/placeOrderInProgress.js +16 -2
- package/lib/chevre/service/transaction/returnOrder.js +10 -1
- package/lib/chevre/service.d.ts +2 -0
- package/lib/chevre/service.js +2 -0
- package/package.json +4 -4
- package/example/src/chevre/accountBlanceTest.ts +0 -24
- package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
- package/example/src/chevre/createSeats.ts +0 -59
- package/example/src/chevre/deleteEvents.ts +0 -50
- package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
- package/example/src/chevre/migrateEventOffersItemOfferedName.ts +0 -82
- package/example/src/chevre/migrateMovieTicketChargePriceSpecs.ts +0 -92
- package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
- package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
- package/example/src/chevre/publishConfirmationNumber.ts +0 -30
- package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
- package/example/src/chevre/publishTransactionNumber.ts +0 -28
- package/example/src/chevre/renameTransaction.ts +0 -22
- package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as 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 reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const result = await reservationRepo.deleteReservedTicketUnderName();
|
|
14
|
+
|
|
15
|
+
console.log('deleted', result);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main()
|
|
19
|
+
.then()
|
|
20
|
+
.catch(console.error);
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const accountTitleRepo = new chevre.repository.AccountTitle(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = accountTitleRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
20
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
21
|
+
// starDate: { $gte: new Date() }
|
|
22
|
+
// _id: { $eq: 'al6aff83w' }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
// _id: 1,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('accountTitles found');
|
|
29
|
+
|
|
30
|
+
const additionalPropertyNamesOnCategories: string[] = [];
|
|
31
|
+
const additionalPropertyNames: string[] = [];
|
|
32
|
+
const additionalPropertyNamesOnTitles: string[] = [];
|
|
33
|
+
const projectIdsOnCategories: string[] = [];
|
|
34
|
+
const projectIds: string[] = [];
|
|
35
|
+
const projectIdsOnTitles: string[] = [];
|
|
36
|
+
const unexpextedprojectIdsOnCategories: string[] = [];
|
|
37
|
+
const unexpextedprojectIds: string[] = [];
|
|
38
|
+
const unexpextedprojectIdsOnTitles: string[] = [];
|
|
39
|
+
|
|
40
|
+
let i = 0;
|
|
41
|
+
let updateCount = 0;
|
|
42
|
+
// tslint:disable-next-line:max-func-body-length
|
|
43
|
+
await cursor.eachAsync(async (doc) => {
|
|
44
|
+
i += 1;
|
|
45
|
+
const accountTitleCategory: chevre.factory.accountTitle.IAccountTitle = doc.toObject();
|
|
46
|
+
|
|
47
|
+
const additionalPropertyNamesOnCategory = accountTitleCategory.additionalProperty?.map((p) => p.name);
|
|
48
|
+
console.log(
|
|
49
|
+
(Array.isArray(additionalPropertyNamesOnCategory)) ? additionalPropertyNamesOnCategory.length : 0,
|
|
50
|
+
'additionalPropertyNamesOnCategory found',
|
|
51
|
+
accountTitleCategory.project.id,
|
|
52
|
+
accountTitleCategory.codeValue
|
|
53
|
+
);
|
|
54
|
+
if (Array.isArray(additionalPropertyNamesOnCategory) && additionalPropertyNamesOnCategory.length > 0) {
|
|
55
|
+
console.log(
|
|
56
|
+
additionalPropertyNamesOnCategory.length,
|
|
57
|
+
'additionalPropertyNamesOnResource found',
|
|
58
|
+
accountTitleCategory.project.id,
|
|
59
|
+
accountTitleCategory.codeValue
|
|
60
|
+
);
|
|
61
|
+
additionalPropertyNamesOnCategories.push(...additionalPropertyNamesOnCategory);
|
|
62
|
+
projectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
63
|
+
additionalPropertyNamesOnCategory.forEach((name) => {
|
|
64
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
65
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
66
|
+
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
67
|
+
}
|
|
68
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
69
|
+
if (name.length < 5) {
|
|
70
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
71
|
+
unexpextedprojectIdsOnCategories.push(accountTitleCategory.project.id);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (Array.isArray(accountTitleCategory.hasCategoryCode)) {
|
|
77
|
+
accountTitleCategory.hasCategoryCode.forEach((accountTitleSet) => {
|
|
78
|
+
const additionalPropertyNamesOnResource = accountTitleSet.additionalProperty?.map((p) => p.name);
|
|
79
|
+
console.log(
|
|
80
|
+
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
81
|
+
'additionalPropertyNamesOnResource found',
|
|
82
|
+
accountTitleCategory.project.id,
|
|
83
|
+
accountTitleCategory.codeValue
|
|
84
|
+
);
|
|
85
|
+
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
86
|
+
console.log(
|
|
87
|
+
additionalPropertyNamesOnResource.length,
|
|
88
|
+
'additionalPropertyNamesOnResource found',
|
|
89
|
+
accountTitleCategory.project.id,
|
|
90
|
+
accountTitleCategory.codeValue
|
|
91
|
+
);
|
|
92
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
93
|
+
projectIds.push(accountTitleCategory.project.id);
|
|
94
|
+
additionalPropertyNamesOnResource.forEach((name) => {
|
|
95
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
96
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
97
|
+
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
98
|
+
}
|
|
99
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
100
|
+
if (name.length < 5) {
|
|
101
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
102
|
+
unexpextedprojectIds.push(accountTitleCategory.project.id);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (Array.isArray(accountTitleSet.hasCategoryCode)) {
|
|
108
|
+
accountTitleSet.hasCategoryCode.forEach((accountTitl) => {
|
|
109
|
+
const additionalPropertyNamesOnSection = accountTitl.additionalProperty?.map((p) => p.name);
|
|
110
|
+
console.log(
|
|
111
|
+
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
112
|
+
'additionalPropertyNamesOnSection found',
|
|
113
|
+
accountTitleCategory.project.id,
|
|
114
|
+
accountTitleCategory.codeValue
|
|
115
|
+
);
|
|
116
|
+
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
117
|
+
console.log(
|
|
118
|
+
additionalPropertyNamesOnSection.length,
|
|
119
|
+
'additionalPropertyNamesOnSection found',
|
|
120
|
+
accountTitleCategory.project.id,
|
|
121
|
+
accountTitleCategory.codeValue
|
|
122
|
+
);
|
|
123
|
+
additionalPropertyNamesOnTitles.push(...additionalPropertyNamesOnSection);
|
|
124
|
+
projectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
125
|
+
additionalPropertyNamesOnSection.forEach((name) => {
|
|
126
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
127
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
128
|
+
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
129
|
+
}
|
|
130
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
131
|
+
if (name.length < 5) {
|
|
132
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
133
|
+
unexpextedprojectIdsOnTitles.push(accountTitleCategory.project.id);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
console.log(i, 'places checked');
|
|
143
|
+
console.log(updateCount, 'places updated');
|
|
144
|
+
console.log([...new Set(additionalPropertyNamesOnCategories)], 'categories');
|
|
145
|
+
console.log([...new Set(projectIdsOnCategories)], 'categories');
|
|
146
|
+
console.log([...new Set(unexpextedprojectIdsOnCategories)], 'categories');
|
|
147
|
+
console.log([...new Set(additionalPropertyNames)], 'sets');
|
|
148
|
+
console.log([...new Set(projectIds)], 'sets');
|
|
149
|
+
console.log([...new Set(unexpextedprojectIds)], 'sets');
|
|
150
|
+
console.log([...new Set(additionalPropertyNamesOnTitles)], 'titles');
|
|
151
|
+
console.log([...new Set(projectIdsOnTitles)], 'titles');
|
|
152
|
+
console.log([...new Set(unexpextedprojectIdsOnTitles)], 'titles');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
main()
|
|
156
|
+
.then()
|
|
157
|
+
.catch(console.error);
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
// const customerRepo = new chevre.repository.Customer(mongoose.connection);
|
|
15
|
+
// const sellerRepo = new chevre.repository.Seller(mongoose.connection);
|
|
16
|
+
// const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
17
|
+
// const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
|
|
18
|
+
// const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
19
|
+
// const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
20
|
+
// const categoryCodeRepo = new chevre.repository.CategoryCode(mongoose.connection);
|
|
21
|
+
// const additionalPropertyRepo = new chevre.repository.AdditionalProperty(mongoose.connection);
|
|
22
|
+
// const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
|
|
23
|
+
const merchantReturnPolicyRepo = new chevre.repository.MerchantReturnPolicy(mongoose.connection);
|
|
24
|
+
|
|
25
|
+
// const cursor = customerRepo.getCursor(
|
|
26
|
+
// const cursor = sellerRepo.getCursor(
|
|
27
|
+
// const cursor = eventRepo.getCursor(
|
|
28
|
+
// const cursor = categoryCodeRepo.getCursor(
|
|
29
|
+
// const cursor = offerRepo.getCursor(
|
|
30
|
+
// const cursor = creativeWorkRepo.getCursor(
|
|
31
|
+
// const cursor = placeRepo.getCursor(
|
|
32
|
+
// const cursor = offerCatalogRepo.getCursor(
|
|
33
|
+
const cursor = merchantReturnPolicyRepo.getCursor(
|
|
34
|
+
{
|
|
35
|
+
// 'project.id': { $eq: project.id },
|
|
36
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
37
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
38
|
+
// starDate: { $gte: new Date() }
|
|
39
|
+
// _id: { $eq: 'al6aff83w' }
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
// _id: 1,
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
console.log('creativeWorks found');
|
|
46
|
+
|
|
47
|
+
const additionalPropertyNames: string[] = [];
|
|
48
|
+
const projectIds: string[] = [];
|
|
49
|
+
const unexpextedprojectIds: string[] = [];
|
|
50
|
+
|
|
51
|
+
let i = 0;
|
|
52
|
+
let updateCount = 0;
|
|
53
|
+
await cursor.eachAsync(async (doc) => {
|
|
54
|
+
i += 1;
|
|
55
|
+
const creativeWork: chevre.factory.creativeWork.movie.ICreativeWork = doc.toObject();
|
|
56
|
+
|
|
57
|
+
const additionalPropertyNamesOnEvent = creativeWork.additionalProperty?.map((p) => p.name);
|
|
58
|
+
if (Array.isArray(additionalPropertyNamesOnEvent) && additionalPropertyNamesOnEvent.length > 0) {
|
|
59
|
+
console.log(
|
|
60
|
+
additionalPropertyNamesOnEvent.length,
|
|
61
|
+
'additionalPropertyNamesOnEvent found',
|
|
62
|
+
creativeWork.project.id,
|
|
63
|
+
creativeWork.id
|
|
64
|
+
);
|
|
65
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnEvent);
|
|
66
|
+
projectIds.push(creativeWork.project.id);
|
|
67
|
+
additionalPropertyNamesOnEvent.forEach((name) => {
|
|
68
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
69
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
70
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
71
|
+
}
|
|
72
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
73
|
+
if (name.length < 5) {
|
|
74
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
75
|
+
unexpextedprojectIds.push(creativeWork.project.id);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// for (const additionalPropertyNameOnEvent of additionalPropertyNamesOnEvent) {
|
|
80
|
+
// const existings = await additionalPropertyRepo.search({
|
|
81
|
+
// project: { id: { $eq: event.project.id } },
|
|
82
|
+
// limit: 1,
|
|
83
|
+
// page: 1,
|
|
84
|
+
// name: { $regex: `^${additionalPropertyNameOnEvent}$` }
|
|
85
|
+
// });
|
|
86
|
+
// if (existings.length > 0) {
|
|
87
|
+
// console.log('already existed', additionalPropertyNameOnEvent, event.id, event.project.id);
|
|
88
|
+
// } else {
|
|
89
|
+
// updateCount += 1;
|
|
90
|
+
// await additionalPropertyRepo.save({
|
|
91
|
+
// attributes: {
|
|
92
|
+
// project: event.project,
|
|
93
|
+
// typeOf: 'CategoryCode',
|
|
94
|
+
// codeValue: additionalPropertyNameOnEvent,
|
|
95
|
+
// inCodeSet: {
|
|
96
|
+
// typeOf: 'CategoryCodeSet',
|
|
97
|
+
// identifier: <any>event.typeOf
|
|
98
|
+
// },
|
|
99
|
+
// name: { ja: additionalPropertyNameOnEvent }
|
|
100
|
+
// }
|
|
101
|
+
// });
|
|
102
|
+
// console.log('created', additionalPropertyNameOnEvent, event.id, event.project.id);
|
|
103
|
+
// }
|
|
104
|
+
// }
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
console.log(i, 'events checked');
|
|
108
|
+
console.log(updateCount, 'events updated');
|
|
109
|
+
console.log([...new Set(additionalPropertyNames)]);
|
|
110
|
+
console.log([...new Set(projectIds)]);
|
|
111
|
+
console.log([...new Set(unexpextedprojectIds)]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
main()
|
|
115
|
+
.then()
|
|
116
|
+
.catch(console.error);
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
const AVAILABLE_ROLE_NAMES = ['customer', 'pos'];
|
|
10
|
+
const POS_CLIENT_ID = process.env.POS_CLIENT_ID;
|
|
11
|
+
if (typeof POS_CLIENT_ID !== 'string') {
|
|
12
|
+
throw new Error('set POS_CLIENT_ID');
|
|
13
|
+
}
|
|
14
|
+
const MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = 93;
|
|
15
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
16
|
+
|
|
17
|
+
// tslint:disable-next-line:max-func-body-length
|
|
18
|
+
async function main() {
|
|
19
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
20
|
+
|
|
21
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
22
|
+
const memberRepo = new chevre.repository.Member(mongoose.connection);
|
|
23
|
+
|
|
24
|
+
const cursor = eventRepo.getCursor(
|
|
25
|
+
{
|
|
26
|
+
// 'project.id': { $eq: project.id },
|
|
27
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
28
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
29
|
+
startDate: {
|
|
30
|
+
$gte: moment()
|
|
31
|
+
.add(-1, 'month')
|
|
32
|
+
.toDate()
|
|
33
|
+
}
|
|
34
|
+
// _id: { $eq: 'al6aff83w' }
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
// _id: 1,
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
console.log('events found');
|
|
41
|
+
|
|
42
|
+
let i = 0;
|
|
43
|
+
let updateCount = 0;
|
|
44
|
+
await cursor.eachAsync(async (doc) => {
|
|
45
|
+
i += 1;
|
|
46
|
+
const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
|
|
47
|
+
|
|
48
|
+
// IAMメンバー検索
|
|
49
|
+
const eventOffers = <chevre.factory.event.screeningEvent.IOffer | undefined>event.offers;
|
|
50
|
+
if (eventOffers === undefined) {
|
|
51
|
+
throw new Error('event.offers undefined');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const makesOfferFromEvent = eventOffers.seller.makesOffer;
|
|
55
|
+
|
|
56
|
+
const alreadyMigrated = Array.isArray(makesOfferFromEvent)
|
|
57
|
+
&& makesOfferFromEvent.length > 0
|
|
58
|
+
&& makesOfferFromEvent.every((offer) => {
|
|
59
|
+
return offer.availabilityEnds instanceof Date
|
|
60
|
+
&& offer.availabilityStarts instanceof Date
|
|
61
|
+
&& offer.validFrom instanceof Date
|
|
62
|
+
&& offer.validThrough instanceof Date
|
|
63
|
+
&& Array.isArray(offer.availableAtOrFrom)
|
|
64
|
+
&& offer.availableAtOrFrom.length === 1;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
if (alreadyMigrated) {
|
|
68
|
+
console.log(
|
|
69
|
+
'already exist...', event.project.id, event.id, event.startDate, makesOfferFromEvent.length, i);
|
|
70
|
+
} else {
|
|
71
|
+
let existingApplicationMembers = await memberRepo.search({
|
|
72
|
+
limit: 100,
|
|
73
|
+
page: 1,
|
|
74
|
+
project: { id: { $eq: event.project.id } },
|
|
75
|
+
member: { typeOf: { $eq: chevre.factory.creativeWorkType.WebApplication } }
|
|
76
|
+
});
|
|
77
|
+
// ロールで絞る(customer or pos)
|
|
78
|
+
existingApplicationMembers = existingApplicationMembers
|
|
79
|
+
.filter((m) => {
|
|
80
|
+
return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
|
|
81
|
+
});
|
|
82
|
+
console.log(
|
|
83
|
+
existingApplicationMembers.length,
|
|
84
|
+
'existingApplicationMembers found.',
|
|
85
|
+
event.project.id,
|
|
86
|
+
existingApplicationMembers.map((m) => m.member.name)
|
|
87
|
+
.join(',')
|
|
88
|
+
);
|
|
89
|
+
const newMakesOffer: chevre.factory.event.screeningEvent.ISellerMakesOffer[] = existingApplicationMembers.map((a) => {
|
|
90
|
+
// posについては有効期間調整
|
|
91
|
+
if (a.member.id === POS_CLIENT_ID) {
|
|
92
|
+
const validFrom4pos: Date = moment(event.startDate)
|
|
93
|
+
.add(-MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS, 'days')
|
|
94
|
+
.toDate();
|
|
95
|
+
const validThrough4pos: Date = moment(event.endDate)
|
|
96
|
+
.add(1, 'month')
|
|
97
|
+
.toDate();
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
101
|
+
availableAtOrFrom: [{ id: a.member.id }],
|
|
102
|
+
availabilityEnds: validThrough4pos, // 1 month later from endDate
|
|
103
|
+
availabilityStarts: validFrom4pos, // startのMAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS前
|
|
104
|
+
validFrom: validFrom4pos, // startのMAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS前
|
|
105
|
+
validThrough: validThrough4pos // 1 month later from endDate
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
return {
|
|
109
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
110
|
+
availableAtOrFrom: [{ id: a.member.id }],
|
|
111
|
+
availabilityEnds: eventOffers.availabilityEnds,
|
|
112
|
+
availabilityStarts: eventOffers.availabilityStarts,
|
|
113
|
+
validFrom: eventOffers.validFrom,
|
|
114
|
+
validThrough: eventOffers.validThrough
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
console.log(
|
|
119
|
+
'updating seller...', event.project.id, event.id, event.startDate, newMakesOffer.length, i);
|
|
120
|
+
await eventRepo.updatePartiallyById({
|
|
121
|
+
id: event.id,
|
|
122
|
+
attributes: <any>{
|
|
123
|
+
typeOf: event.typeOf,
|
|
124
|
+
'offers.seller.makesOffer': newMakesOffer
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
updateCount += 1;
|
|
128
|
+
console.log(
|
|
129
|
+
'updated...', event.project.id, event.id, event.startDate, newMakesOffer.length, i);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
console.log(i, 'events checked');
|
|
134
|
+
console.log(updateCount, 'events updated');
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
main()
|
|
138
|
+
.then()
|
|
139
|
+
.catch(console.error);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
13
|
+
|
|
14
|
+
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = eventRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
20
|
+
typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
|
|
21
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
22
|
+
startDate: {
|
|
23
|
+
$gte: moment()
|
|
24
|
+
.add(-1, 'month')
|
|
25
|
+
.toDate()
|
|
26
|
+
}
|
|
27
|
+
// _id: { $eq: 'al6aff83w' }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
// _id: 1,
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
console.log('events found');
|
|
34
|
+
|
|
35
|
+
let i = 0;
|
|
36
|
+
let updateCount = 0;
|
|
37
|
+
await cursor.eachAsync(async (doc) => {
|
|
38
|
+
i += 1;
|
|
39
|
+
const event: chevre.factory.event.screeningEventSeries.IEvent = doc.toObject();
|
|
40
|
+
|
|
41
|
+
const locationProjectId = (<any>event.location).project?.id;
|
|
42
|
+
if (typeof locationProjectId !== 'string') {
|
|
43
|
+
console.log('already deleted', event.id, event.startDate, event.project.id, i);
|
|
44
|
+
} else {
|
|
45
|
+
updateCount += 1;
|
|
46
|
+
console.log('deleting project...', event.id, event.startDate, event.project.id, i);
|
|
47
|
+
await eventRepo.deleteUnnecessaryProjectAttributesById({ id: event.id });
|
|
48
|
+
console.log('project deleted', event.id, event.startDate, event.project.id, i);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
console.log(i, 'events checked');
|
|
52
|
+
console.log(updateCount, 'events updated');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.then()
|
|
57
|
+
.catch(console.error);
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
const EXCLUDED_PROJECT_ID = process.env.EXCLUDED_PROJECT_ID;
|
|
9
|
+
|
|
10
|
+
// tslint:disable-next-line:max-func-body-length
|
|
11
|
+
async function main() {
|
|
12
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
|
+
|
|
14
|
+
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = placeRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
'project.id': { $ne: EXCLUDED_PROJECT_ID }
|
|
20
|
+
// typeOf: { $eq: chevre.factory.eventType.ScreeningEventSeries },
|
|
21
|
+
// starDate: { $gte: new Date() }
|
|
22
|
+
// _id: { $eq: 'al6aff83w' }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
// _id: 1,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('creativeWorks found');
|
|
29
|
+
|
|
30
|
+
const additionalPropertyNames: string[] = [];
|
|
31
|
+
const additionalPropertyNamesOnSections: string[] = [];
|
|
32
|
+
const additionalPropertyNamesOnSeats: string[] = [];
|
|
33
|
+
const projectIds: string[] = [];
|
|
34
|
+
const unexpextedprojectIds: string[] = [];
|
|
35
|
+
const projectIdsOnSections: string[] = [];
|
|
36
|
+
const unexpextedprojectIdsOnSections: string[] = [];
|
|
37
|
+
const projectIdsOnSeats: string[] = [];
|
|
38
|
+
const unexpextedprojectIdsOnSeats: string[] = [];
|
|
39
|
+
|
|
40
|
+
let i = 0;
|
|
41
|
+
let updateCount = 0;
|
|
42
|
+
// tslint:disable-next-line:max-func-body-length
|
|
43
|
+
await cursor.eachAsync(async (doc) => {
|
|
44
|
+
i += 1;
|
|
45
|
+
const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
|
|
46
|
+
|
|
47
|
+
if (Array.isArray(movieTheater.containsPlace)) {
|
|
48
|
+
movieTheater.containsPlace.forEach((screeningRoom) => {
|
|
49
|
+
const additionalPropertyNamesOnResource = screeningRoom.additionalProperty?.map((p) => p.name);
|
|
50
|
+
console.log(
|
|
51
|
+
(Array.isArray(additionalPropertyNamesOnResource)) ? additionalPropertyNamesOnResource.length : 0,
|
|
52
|
+
'additionalPropertyNamesOnResource found',
|
|
53
|
+
movieTheater.project.id,
|
|
54
|
+
movieTheater.id
|
|
55
|
+
);
|
|
56
|
+
if (Array.isArray(additionalPropertyNamesOnResource) && additionalPropertyNamesOnResource.length > 0) {
|
|
57
|
+
console.log(
|
|
58
|
+
additionalPropertyNamesOnResource.length,
|
|
59
|
+
'additionalPropertyNamesOnResource found',
|
|
60
|
+
movieTheater.project.id,
|
|
61
|
+
movieTheater.id
|
|
62
|
+
);
|
|
63
|
+
additionalPropertyNames.push(...additionalPropertyNamesOnResource);
|
|
64
|
+
projectIds.push(movieTheater.project.id);
|
|
65
|
+
additionalPropertyNamesOnResource.forEach((name) => {
|
|
66
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
67
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
68
|
+
unexpextedprojectIds.push(movieTheater.project.id);
|
|
69
|
+
}
|
|
70
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
71
|
+
if (name.length < 5) {
|
|
72
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
73
|
+
unexpextedprojectIds.push(movieTheater.project.id);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (Array.isArray(screeningRoom.containsPlace)) {
|
|
79
|
+
screeningRoom.containsPlace.forEach((section) => {
|
|
80
|
+
const additionalPropertyNamesOnSection = section.additionalProperty?.map((p) => p.name);
|
|
81
|
+
console.log(
|
|
82
|
+
(Array.isArray(additionalPropertyNamesOnSection)) ? additionalPropertyNamesOnSection.length : 0,
|
|
83
|
+
'additionalPropertyNamesOnSection found',
|
|
84
|
+
movieTheater.project.id,
|
|
85
|
+
movieTheater.id
|
|
86
|
+
);
|
|
87
|
+
if (Array.isArray(additionalPropertyNamesOnSection) && additionalPropertyNamesOnSection.length > 0) {
|
|
88
|
+
console.log(
|
|
89
|
+
additionalPropertyNamesOnSection.length,
|
|
90
|
+
'additionalPropertyNamesOnSection found',
|
|
91
|
+
movieTheater.project.id,
|
|
92
|
+
movieTheater.id
|
|
93
|
+
);
|
|
94
|
+
additionalPropertyNamesOnSections.push(...additionalPropertyNamesOnSection);
|
|
95
|
+
projectIdsOnSections.push(movieTheater.project.id);
|
|
96
|
+
additionalPropertyNamesOnSection.forEach((name) => {
|
|
97
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
98
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
99
|
+
unexpextedprojectIdsOnSections.push(movieTheater.project.id);
|
|
100
|
+
}
|
|
101
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
102
|
+
if (name.length < 5) {
|
|
103
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
104
|
+
unexpextedprojectIdsOnSections.push(movieTheater.project.id);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (Array.isArray(section.containsPlace)) {
|
|
110
|
+
section.containsPlace.forEach((seat) => {
|
|
111
|
+
const additionalPropertyNamesOnSeat = seat.additionalProperty?.map((p) => p.name);
|
|
112
|
+
console.log(
|
|
113
|
+
(Array.isArray(additionalPropertyNamesOnSeat)) ? additionalPropertyNamesOnSeat.length : 0,
|
|
114
|
+
'additionalPropertyNamesOnSeat found',
|
|
115
|
+
movieTheater.project.id,
|
|
116
|
+
movieTheater.id
|
|
117
|
+
);
|
|
118
|
+
if (Array.isArray(additionalPropertyNamesOnSeat) && additionalPropertyNamesOnSeat.length > 0) {
|
|
119
|
+
console.log(
|
|
120
|
+
additionalPropertyNamesOnSeat.length,
|
|
121
|
+
'additionalPropertyNamesOnSeat found',
|
|
122
|
+
movieTheater.project.id,
|
|
123
|
+
movieTheater.id
|
|
124
|
+
);
|
|
125
|
+
additionalPropertyNamesOnSeats.push(...additionalPropertyNamesOnSeat);
|
|
126
|
+
projectIdsOnSeats.push(movieTheater.project.id);
|
|
127
|
+
additionalPropertyNamesOnSeat.forEach((name) => {
|
|
128
|
+
if (!name.match(/^[a-zA-Z]*$/)) {
|
|
129
|
+
// throw new Error(`not matched ${creativeWork.project.id} ${creativeWork.id}`);
|
|
130
|
+
unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
|
|
131
|
+
}
|
|
132
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
133
|
+
if (name.length < 5) {
|
|
134
|
+
// throw new Error(`length matched ${creativeWork.project.id} ${creativeWork.id} ${name}`);
|
|
135
|
+
unexpextedprojectIdsOnSeats.push(movieTheater.project.id);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
console.log(i, 'places checked');
|
|
148
|
+
console.log(updateCount, 'places updated');
|
|
149
|
+
console.log([...new Set(additionalPropertyNames)], 'screeningRooms');
|
|
150
|
+
console.log([...new Set(projectIds)], 'screeningRooms');
|
|
151
|
+
console.log([...new Set(unexpextedprojectIds)], 'screeningRooms');
|
|
152
|
+
console.log([...new Set(additionalPropertyNamesOnSections)], 'sections');
|
|
153
|
+
console.log([...new Set(projectIdsOnSections)], 'sections');
|
|
154
|
+
console.log([...new Set(unexpextedprojectIdsOnSections)], 'sections');
|
|
155
|
+
console.log([...new Set(additionalPropertyNamesOnSeats)], 'seats');
|
|
156
|
+
console.log([...new Set(projectIdsOnSeats)], 'seats');
|
|
157
|
+
console.log([...new Set(unexpextedprojectIdsOnSeats)], 'seats');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
main()
|
|
161
|
+
.then()
|
|
162
|
+
.catch(console.error);
|