@chevre/domain 23.1.0-alpha.3 → 23.1.0-alpha.30
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/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +68 -0
- package/example/src/chevre/actions/checkAcceptPayActions.ts +60 -0
- package/example/src/chevre/assetTransaction/checkPayTransactionsTicketToken.ts +67 -0
- package/example/src/chevre/assetTransaction/processReserve.ts +8 -3
- package/example/src/chevre/authorizeEventServiceOffer.ts +7 -5
- package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
- package/example/src/chevre/member/migrateMemberIdentifier.ts +99 -0
- package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
- package/example/src/chevre/reIndex.ts +1 -2
- package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
- package/example/src/chevre/stockHolder/findSeatsBySection.ts +59 -0
- package/example/src/chevre/stockHolder/searchSeats.ts +2 -2
- package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -0
- package/lib/chevre/repo/acceptedPaymentMethod.js +180 -0
- package/lib/chevre/repo/authorization.d.ts +3 -2
- package/lib/chevre/repo/authorization.js +13 -5
- package/lib/chevre/repo/event.d.ts +1 -35
- package/lib/chevre/repo/event.js +2 -102
- package/lib/chevre/repo/eventOffer.d.ts +1 -1
- package/lib/chevre/repo/eventOffer.js +16 -10
- package/lib/chevre/repo/member.d.ts +18 -1
- package/lib/chevre/repo/member.js +14 -8
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +97 -0
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +48 -35
- package/lib/chevre/repo/mongoose/schemas/member.js +10 -0
- package/lib/chevre/repo/place/seat.d.ts +24 -0
- package/lib/chevre/repo/place/seat.js +103 -21
- package/lib/chevre/repo/ticket.d.ts +7 -1
- package/lib/chevre/repo/ticket.js +14 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/pay/factory.js +8 -3
- package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +92 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
- package/lib/chevre/service/assetTransaction/pay.js +6 -1
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +6 -0
- package/lib/chevre/service/assetTransaction/reserve/start.js +5 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +22 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +63 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +32 -32
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +10 -54
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.d.ts +23 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +62 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +36 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +23 -27
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +0 -3
- package/lib/chevre/service/offer/event/authorize/factory.js +4 -3
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +43 -26
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +4 -0
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -4
- package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
- package/lib/chevre/service/offer/event/authorize.js +10 -5
- package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
- package/lib/chevre/service/offer/event.d.ts +2 -1
- package/lib/chevre/service/offer/event.js +3 -1
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +9 -0
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +22 -11
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +19 -2
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +87 -9
- package/lib/chevre/service/payment/any/factory.d.ts +20 -3
- package/lib/chevre/service/payment/any/factory.js +26 -6
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +20 -28
- package/lib/chevre/service/payment/any.d.ts +5 -1
- package/lib/chevre/service/payment/any.js +22 -13
- package/lib/chevre/service/payment/factory.js +0 -5
- package/lib/chevre/service/payment/movieTicket/authorize.js +0 -5
- package/lib/chevre/service/task/authorizePayment.js +2 -0
- package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +9 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.js +2 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +8 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +45 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +3 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +38 -0
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -8
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +5 -35
- package/package.json +3 -3
- package/example/src/chevre/checkReplaceActions.ts +0 -65
- package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +0 -193
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +0 -7
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const acceptedPaymentMethodRepo = await chevre.repository.AcceptedPaymentMethod.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const validFrom = moment()
|
|
15
|
+
.toDate();
|
|
16
|
+
const validThrough = moment(validFrom)
|
|
17
|
+
.add(1, 'hour')
|
|
18
|
+
.toDate();
|
|
19
|
+
const settingOffer: Omit<chevre.factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer, 'id'> = {
|
|
20
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
21
|
+
identifier: '20251202acceptedPaymentMethod',
|
|
22
|
+
itemOffered: {
|
|
23
|
+
id: '7k9ayl8hc',
|
|
24
|
+
typeOf: chevre.factory.eventType.ScreeningEventSeries
|
|
25
|
+
},
|
|
26
|
+
acceptedPaymentMethod: {
|
|
27
|
+
id: '5f9a52994f3709000abe6417',
|
|
28
|
+
typeOf: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
29
|
+
},
|
|
30
|
+
validFrom,
|
|
31
|
+
validThrough,
|
|
32
|
+
seller: {
|
|
33
|
+
id: '59d20831e53ebc2b4e774466',
|
|
34
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
35
|
+
},
|
|
36
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let result = await acceptedPaymentMethodRepo.upsertAcceptedPaymentMethodsByIdentifier(
|
|
40
|
+
[
|
|
41
|
+
{
|
|
42
|
+
$set: settingOffer,
|
|
43
|
+
$unset: {}
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
{
|
|
47
|
+
update: false
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
console.log(result);
|
|
51
|
+
|
|
52
|
+
result = await acceptedPaymentMethodRepo.upsertAcceptedPaymentMethodsByIdentifier(
|
|
53
|
+
[
|
|
54
|
+
{
|
|
55
|
+
$set: settingOffer,
|
|
56
|
+
$unset: {}
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
{
|
|
60
|
+
update: true
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
console.log(result);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
main()
|
|
67
|
+
.then()
|
|
68
|
+
.catch(console.error);
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = actionRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
typeOf: { $eq: chevre.factory.actionType.AcceptAction },
|
|
16
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.assetTransactionType.Pay },
|
|
17
|
+
startDate: {
|
|
18
|
+
$gte: moment()
|
|
19
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
20
|
+
.add(-3, 'days')
|
|
21
|
+
.toDate()
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
console.log('docs found');
|
|
28
|
+
|
|
29
|
+
let i = 0;
|
|
30
|
+
let ticketTokenCount = 0;
|
|
31
|
+
await cursor.eachAsync(async (doc) => {
|
|
32
|
+
i += 1;
|
|
33
|
+
const acceptAction = <chevre.factory.action.accept.pay.IAction>doc.toObject();
|
|
34
|
+
|
|
35
|
+
const ticketTokenByInstrument = acceptAction.instrument?.find((instrument) => instrument.typeOf === 'Ticket')?.ticketToken;
|
|
36
|
+
if (typeof ticketTokenByInstrument === 'string' && ticketTokenByInstrument !== '') {
|
|
37
|
+
console.log(
|
|
38
|
+
ticketTokenByInstrument,
|
|
39
|
+
' ticket token exists.',
|
|
40
|
+
acceptAction.project.id, acceptAction.typeOf, acceptAction.object.typeOf,
|
|
41
|
+
acceptAction.startDate, acceptAction.identifier, i
|
|
42
|
+
);
|
|
43
|
+
ticketTokenCount += 1;
|
|
44
|
+
} else {
|
|
45
|
+
console.log(
|
|
46
|
+
ticketTokenByInstrument,
|
|
47
|
+
' ticket token does not exists.',
|
|
48
|
+
acceptAction.project.id, acceptAction.typeOf, acceptAction.object.typeOf,
|
|
49
|
+
acceptAction.startDate, acceptAction.identifier, i
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log(i, 'docs checked');
|
|
55
|
+
console.log(ticketTokenCount, 'ticketToken exist');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
main()
|
|
59
|
+
.then()
|
|
60
|
+
.catch(console.error);
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
12
|
+
|
|
13
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
16
|
+
startDate: {
|
|
17
|
+
$gte: moment()
|
|
18
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
19
|
+
.add(-3, 'days')
|
|
20
|
+
.toDate()
|
|
21
|
+
},
|
|
22
|
+
'object.typeOf': {
|
|
23
|
+
$exists: true,
|
|
24
|
+
$in: [
|
|
25
|
+
// chevre.factory.service.paymentService.PaymentServiceType.FaceToFace,
|
|
26
|
+
// chevre.factory.service.paymentService.PaymentServiceType.MovieTicket,
|
|
27
|
+
chevre.factory.service.paymentService.PaymentServiceType.CreditCard
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
console.log('docs found');
|
|
35
|
+
|
|
36
|
+
let i = 0;
|
|
37
|
+
let ticketTokenCount = 0;
|
|
38
|
+
await cursor.eachAsync(async (doc) => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const payTransaction = <chevre.factory.assetTransaction.pay.ITransaction>doc.toObject();
|
|
41
|
+
|
|
42
|
+
const ticketTokenByInstrument = payTransaction.instrument?.find((instrument) => instrument.typeOf === 'Ticket')?.ticketToken;
|
|
43
|
+
if (typeof ticketTokenByInstrument === 'string' && ticketTokenByInstrument !== '') {
|
|
44
|
+
console.log(
|
|
45
|
+
ticketTokenByInstrument,
|
|
46
|
+
' ticket token exists.',
|
|
47
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.object.typeOf,
|
|
48
|
+
payTransaction.startDate, payTransaction.transactionNumber, i
|
|
49
|
+
);
|
|
50
|
+
ticketTokenCount += 1;
|
|
51
|
+
} else {
|
|
52
|
+
console.log(
|
|
53
|
+
ticketTokenByInstrument,
|
|
54
|
+
' ticket token does not exists.',
|
|
55
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.object.typeOf,
|
|
56
|
+
payTransaction.startDate, payTransaction.transactionNumber, i
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(i, 'docs checked');
|
|
62
|
+
console.log(ticketTokenCount, 'ticketToken exist');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main()
|
|
66
|
+
.then()
|
|
67
|
+
.catch(console.error);
|
|
@@ -76,8 +76,8 @@ async function main() {
|
|
|
76
76
|
reservationFor: {
|
|
77
77
|
id: EVENT_ID,
|
|
78
78
|
offers: {
|
|
79
|
-
token: OFFER_TOKEN,
|
|
80
|
-
identifier: 'LegacyReservation'
|
|
79
|
+
// token: OFFER_TOKEN,
|
|
80
|
+
// identifier: 'LegacyReservation'
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
@@ -88,7 +88,9 @@ async function main() {
|
|
|
88
88
|
validateEvent: false,
|
|
89
89
|
validateEventOfferPeriod: true,
|
|
90
90
|
validateAppliesToMovieTicket: true,
|
|
91
|
-
instrument: [
|
|
91
|
+
instrument: [
|
|
92
|
+
...(typeof OFFER_TOKEN === 'string') ? [{ ticketToken: OFFER_TOKEN, typeOf: <'Ticket'>'Ticket' }] : []
|
|
93
|
+
],
|
|
92
94
|
availableAtOrFrom: { id: APPLICATION_ID }
|
|
93
95
|
// stockHoldUntilDaysAfterEventEnd: STOCK_HOLD_UNTIL_DAYS_AFTER_EVENT_END
|
|
94
96
|
},
|
|
@@ -96,12 +98,14 @@ async function main() {
|
|
|
96
98
|
)(
|
|
97
99
|
{
|
|
98
100
|
advanceBookingRequirement: await chevre.repository.AdvanceBookingRequirement.createInstance(mongoose.connection),
|
|
101
|
+
authorization: await chevre.repository.Authorization.createInstance(mongoose.connection),
|
|
99
102
|
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
100
103
|
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
|
|
101
104
|
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
102
105
|
eventOffer: await chevre.repository.EventOffer.createInstance(mongoose.connection),
|
|
103
106
|
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
104
107
|
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
108
|
+
member: await chevre.repository.Member.createInstance(mongoose.connection),
|
|
105
109
|
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
106
110
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
107
111
|
offerCatalog: await chevre.repository.OfferCatalog.createInstance(mongoose.connection),
|
|
@@ -114,6 +118,7 @@ async function main() {
|
|
|
114
118
|
seat: await chevre.repository.place.Seat.createInstance(mongoose.connection),
|
|
115
119
|
setting: await chevre.repository.Setting.createInstance(mongoose.connection),
|
|
116
120
|
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
121
|
+
ticket: await chevre.repository.Ticket.createInstance(mongoose.connection),
|
|
117
122
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection)
|
|
118
123
|
},
|
|
119
124
|
new chevre.settings.Settings({
|
|
@@ -29,10 +29,10 @@ async function main() {
|
|
|
29
29
|
reservationFor: {
|
|
30
30
|
id: 'bmcvkft63',
|
|
31
31
|
offers: {
|
|
32
|
-
validForMemberTier: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
// validForMemberTier: {
|
|
33
|
+
// token: 'xx',
|
|
34
|
+
// isTierOf: { identifier: 'DefaultMemberProgram' }
|
|
35
|
+
// }
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
}
|
|
@@ -41,7 +41,8 @@ async function main() {
|
|
|
41
41
|
transaction: { id: 'xxx' },
|
|
42
42
|
validateEventOfferPeriod: true,
|
|
43
43
|
validateEvent: false,
|
|
44
|
-
store: { id: 'xxx' }
|
|
44
|
+
store: { id: 'xxx' },
|
|
45
|
+
instrument: []
|
|
45
46
|
},
|
|
46
47
|
{
|
|
47
48
|
noOfferSpecified: true,
|
|
@@ -57,6 +58,7 @@ async function main() {
|
|
|
57
58
|
eventOffer: await chevre.repository.EventOffer.createInstance(mongoose.connection),
|
|
58
59
|
eventSeries: await chevre.repository.EventSeries.createInstance(mongoose.connection),
|
|
59
60
|
issuer: await chevre.repository.Issuer.createInstance(mongoose.connection),
|
|
61
|
+
member: await chevre.repository.Member.createInstance(mongoose.connection),
|
|
60
62
|
memberProgram: await chevre.repository.MemberProgram.createInstance(mongoose.connection),
|
|
61
63
|
stockHolder: await chevre.repository.StockHolder.createInstance({ connection: mongoose.connection }),
|
|
62
64
|
offer: await chevre.repository.Offer.createInstance(mongoose.connection),
|
|
@@ -0,0 +1,93 @@
|
|
|
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 DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET = 'MovieTicket';
|
|
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 eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = eventSeriesRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
'project.id': { $eq: 'xxx' },
|
|
19
|
+
'offers.unacceptedPaymentMethod': {
|
|
20
|
+
$exists: true,
|
|
21
|
+
$ne: DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
22
|
+
},
|
|
23
|
+
startDate: {
|
|
24
|
+
$lte: moment()
|
|
25
|
+
.add(-1, 'year')
|
|
26
|
+
.toDate()
|
|
27
|
+
}
|
|
28
|
+
// _id: { $eq: 'bliy11ffa' }
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
// _id: 1,
|
|
32
|
+
// offers: 1,
|
|
33
|
+
// startDate: 1,
|
|
34
|
+
// project: 1,
|
|
35
|
+
// typeOf: 1
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
console.log('docs found');
|
|
39
|
+
|
|
40
|
+
let i = 0;
|
|
41
|
+
let updateCount = 0;
|
|
42
|
+
await cursor.eachAsync(async (doc) => {
|
|
43
|
+
i += 1;
|
|
44
|
+
const eventSeries: Pick<
|
|
45
|
+
chevre.factory.eventSeries.IEvent,
|
|
46
|
+
'id' | 'offers' | 'startDate' | 'project' | 'typeOf'
|
|
47
|
+
> = doc.toObject();
|
|
48
|
+
|
|
49
|
+
console.log(
|
|
50
|
+
'alreadyMigrated?', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
51
|
+
const unacceptedPaymentMethod = eventSeries.offers?.unacceptedPaymentMethod;
|
|
52
|
+
const alreadyMigrated = !Array.isArray(unacceptedPaymentMethod)
|
|
53
|
+
|| (Array.isArray(unacceptedPaymentMethod)
|
|
54
|
+
&& unacceptedPaymentMethod.every(
|
|
55
|
+
(paymentMethodType) => paymentMethodType === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
if (alreadyMigrated) {
|
|
59
|
+
console.log(
|
|
60
|
+
'already migrated.', eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
61
|
+
} else {
|
|
62
|
+
if (Array.isArray(unacceptedPaymentMethod)) {
|
|
63
|
+
const newUnacceptedPaymentMethod = unacceptedPaymentMethod.filter(
|
|
64
|
+
(paymentMethod) => paymentMethod === DEFAULT_PAYMENT_METHOD_TYPE_FOR_MOVIE_TICKET
|
|
65
|
+
);
|
|
66
|
+
console.log(
|
|
67
|
+
'updating project...',
|
|
68
|
+
newUnacceptedPaymentMethod,
|
|
69
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
70
|
+
await eventSeriesRepo.saveEventSeries({
|
|
71
|
+
id: eventSeries.id,
|
|
72
|
+
attributes: <any>{
|
|
73
|
+
...{
|
|
74
|
+
typeOf: eventSeries.typeOf,
|
|
75
|
+
'offers.unacceptedPaymentMethod': newUnacceptedPaymentMethod
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
updateCount += 1;
|
|
80
|
+
console.log(
|
|
81
|
+
'updated.',
|
|
82
|
+
eventSeries.project.id, eventSeries.typeOf, eventSeries.id, eventSeries.startDate, i);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
console.log(i, 'docs checked');
|
|
88
|
+
console.log(updateCount, 'docs updated');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
main()
|
|
92
|
+
.then()
|
|
93
|
+
.catch(console.error);
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
const identifierMap = [
|
|
10
|
+
{
|
|
11
|
+
id: '7divuoimobsfgq95tp1csorjqq',
|
|
12
|
+
identifier: 'SmartTheaterTXNMember'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: '51qbjcfr72h62m06vtv5kkhgje',
|
|
16
|
+
identifier: 'SmartTheaterTXN'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'ckevmf3fueqcunnideu6artt',
|
|
20
|
+
identifier: 'SmartTheaterPOS'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: '3eo6okferrsdpfd9j2ce1iv9k7',
|
|
24
|
+
identifier: 'SmartTheaterTVM'
|
|
25
|
+
}
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// tslint:disable-next-line:max-func-body-length
|
|
29
|
+
async function main() {
|
|
30
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
31
|
+
|
|
32
|
+
const memberRepo = await chevre.repository.Member.createInstance(mongoose.connection);
|
|
33
|
+
|
|
34
|
+
const cursor = memberRepo.getCursor(
|
|
35
|
+
{
|
|
36
|
+
// typeOf: { $eq: chevre.factory.placeType.ScreeningRoom }
|
|
37
|
+
'project.id': { $eq: '*' }
|
|
38
|
+
// 'project.id': { $ne: EXCLUDED_PROJECT_ID },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
project: 1,
|
|
42
|
+
member: 1
|
|
43
|
+
// paymentMethods: 1,
|
|
44
|
+
// project: 1,
|
|
45
|
+
// orderDate: 1
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
console.log('docs found');
|
|
49
|
+
|
|
50
|
+
let updated: number = 0;
|
|
51
|
+
let i = 0;
|
|
52
|
+
await cursor.eachAsync(async (doc) => {
|
|
53
|
+
i += 1;
|
|
54
|
+
const iamMember: chevre.factory.iam.IMember = doc.toObject();
|
|
55
|
+
|
|
56
|
+
const applicationIdentifier = iamMember.member.identifier;
|
|
57
|
+
const updatingIdentifier = identifierMap.find(({ id }) => id === iamMember.member.id)?.identifier;
|
|
58
|
+
if (typeof updatingIdentifier !== 'string') {
|
|
59
|
+
throw new Error(`map not found. ${iamMember.member.name}`);
|
|
60
|
+
}
|
|
61
|
+
const identifierExists = typeof applicationIdentifier === 'string';
|
|
62
|
+
|
|
63
|
+
if (identifierExists) {
|
|
64
|
+
if (applicationIdentifier !== updatingIdentifier) {
|
|
65
|
+
throw new Error(`unexpected application identifier. ${iamMember.member.name}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log(
|
|
69
|
+
'identifier exists',
|
|
70
|
+
iamMember.project.id,
|
|
71
|
+
iamMember.member.name,
|
|
72
|
+
applicationIdentifier
|
|
73
|
+
);
|
|
74
|
+
} else {
|
|
75
|
+
console.log(
|
|
76
|
+
'migrating identifier...',
|
|
77
|
+
iamMember.project.id,
|
|
78
|
+
iamMember.member.name,
|
|
79
|
+
updatingIdentifier
|
|
80
|
+
);
|
|
81
|
+
await memberRepo.updateByMemberId({
|
|
82
|
+
project: { id: iamMember.project.id },
|
|
83
|
+
member: {
|
|
84
|
+
id: iamMember.member.id,
|
|
85
|
+
memberOf: iamMember.member.memberOf,
|
|
86
|
+
identifier: updatingIdentifier
|
|
87
|
+
},
|
|
88
|
+
$unset: {}
|
|
89
|
+
});
|
|
90
|
+
updated += 1;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
console.log(i, 'docs checked');
|
|
94
|
+
console.log('updated:', updated);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
main()
|
|
98
|
+
.then()
|
|
99
|
+
.catch(console.error);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as 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 projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = projectRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
_id: {
|
|
15
|
+
$nin: [
|
|
16
|
+
'ttts-development', 'sskts-development',
|
|
17
|
+
'ttts-test', 'sskts-test',
|
|
18
|
+
'ttts-production', 'sskts-production'
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
_id: 1,
|
|
24
|
+
settings: 1,
|
|
25
|
+
typeOf: 1
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
console.log('docs found');
|
|
29
|
+
|
|
30
|
+
let i = 0;
|
|
31
|
+
let updateCount = 0;
|
|
32
|
+
await cursor.eachAsync(async (doc) => {
|
|
33
|
+
i += 1;
|
|
34
|
+
const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf' | 'settings'> = doc.toObject();
|
|
35
|
+
|
|
36
|
+
console.log(
|
|
37
|
+
'alreadyMigrated?', project.id, i);
|
|
38
|
+
const includeCustomerAsFindByConfirmationNumberResult = project.settings?.includeCustomerAsFindByConfirmationNumberResult;
|
|
39
|
+
let alreadyMigrated = true;
|
|
40
|
+
if (typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean'
|
|
41
|
+
&& includeCustomerAsFindByConfirmationNumberResult === true) {
|
|
42
|
+
alreadyMigrated = false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (alreadyMigrated) {
|
|
46
|
+
console.log(
|
|
47
|
+
'already migrated.', project.id, i);
|
|
48
|
+
} else {
|
|
49
|
+
console.log(
|
|
50
|
+
'updating project...',
|
|
51
|
+
project.id, i);
|
|
52
|
+
await projectRepo.unsetUnnecessaryFields({
|
|
53
|
+
filter: {
|
|
54
|
+
_id: { $eq: project.id }
|
|
55
|
+
},
|
|
56
|
+
$unset: {
|
|
57
|
+
'settings.includeCustomerAsFindByConfirmationNumberResult': 1
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
updateCount += 1;
|
|
61
|
+
console.log(
|
|
62
|
+
'updated.',
|
|
63
|
+
project.id, i);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log(i, 'docs checked');
|
|
68
|
+
console.log(updateCount, 'docs updated');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
main()
|
|
72
|
+
.then()
|
|
73
|
+
.catch(console.error);
|
|
@@ -11,8 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
15
|
-
// await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
|
|
14
|
+
await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
16
15
|
console.log('success!');
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -14,7 +14,7 @@ async function main() {
|
|
|
14
14
|
chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
|
|
15
15
|
];
|
|
16
16
|
const permissions = [
|
|
17
|
-
'admin.sellers.
|
|
17
|
+
'admin.sellers.eventOffers.*'
|
|
18
18
|
];
|
|
19
19
|
for (const roleName of roleNames) {
|
|
20
20
|
for (const permission of permissions) {
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
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 seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
|
|
21
|
+
|
|
22
|
+
setInterval(
|
|
23
|
+
async () => {
|
|
24
|
+
startTime = process.hrtime();
|
|
25
|
+
const seats = await seatRepo.findSeatsBySection(
|
|
26
|
+
{
|
|
27
|
+
limit: 100,
|
|
28
|
+
page: 100,
|
|
29
|
+
projectId: PROJECT_ID,
|
|
30
|
+
sellerId: SELLER_ID,
|
|
31
|
+
movieTheaterCode: MOVIE_THEATER_CODE,
|
|
32
|
+
roomCode: SCREEN_CODE,
|
|
33
|
+
sectionCode: 'Default'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
// branchCode: { $in: ['Z-384'] },
|
|
37
|
+
// containedInPlace: {
|
|
38
|
+
// branchCode: {
|
|
39
|
+
// $in: ['Default']
|
|
40
|
+
// }
|
|
41
|
+
// }
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
diff = process.hrtime(startTime);
|
|
45
|
+
// tslint:disable-next-line:no-null-keyword
|
|
46
|
+
console.dir(seats, { depth: null });
|
|
47
|
+
console.log(seats.length, 'seats found');
|
|
48
|
+
console.log('diff:', [diff[0], formatter.format(diff[1])]);
|
|
49
|
+
},
|
|
50
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
51
|
+
1000
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
main()
|
|
56
|
+
.then(() => {
|
|
57
|
+
console.log('success!');
|
|
58
|
+
})
|
|
59
|
+
.catch(console.error);
|
|
@@ -28,8 +28,8 @@ async function main() {
|
|
|
28
28
|
'containedInPlace.containedInPlace': 0,
|
|
29
29
|
'containedInPlace.typeOf': 0,
|
|
30
30
|
'containedInPlace.name': 0,
|
|
31
|
-
typeOf: 0
|
|
32
|
-
additionalProperty: 0
|
|
31
|
+
typeOf: 0
|
|
32
|
+
// additionalProperty: 0
|
|
33
33
|
},
|
|
34
34
|
project: { id: { $eq: PROJECT_ID } },
|
|
35
35
|
screeningRoom: {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
3
|
+
import * as factory from '../factory';
|
|
4
|
+
import { IDocType } from './mongoose/schemas/acceptedPaymentMethod';
|
|
5
|
+
type IUnset = {
|
|
6
|
+
[key in keyof IDocType]?: 1;
|
|
7
|
+
};
|
|
8
|
+
type IDocWithId = IDocType & {
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
type IKeyOfProjection = keyof IDocType;
|
|
12
|
+
/**
|
|
13
|
+
* 対応決済方法リポジトリ
|
|
14
|
+
*/
|
|
15
|
+
export declare class AcceptedPaymentMethodRepo {
|
|
16
|
+
private readonly acceptedPaymentMethodModel;
|
|
17
|
+
constructor(connection: Connection);
|
|
18
|
+
static CREATE_MONGO_CONDITIONS(params: factory.acceptedPaymentMethodOffer.ISearchConditions): FilterQuery<IDocType>[];
|
|
19
|
+
findAcceptedPaymentMethods(params: factory.acceptedPaymentMethodOffer.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
|
|
20
|
+
/**
|
|
21
|
+
* オファーコードと提供リソースIDをキーにして冪等置換
|
|
22
|
+
*/
|
|
23
|
+
upsertAcceptedPaymentMethodsByIdentifier(params: {
|
|
24
|
+
$set: Pick<IDocType, 'identifier' | 'itemOffered' | 'acceptedPaymentMethod' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough'> & {
|
|
25
|
+
id?: never;
|
|
26
|
+
};
|
|
27
|
+
$unset: IUnset;
|
|
28
|
+
}[], options: {
|
|
29
|
+
/**
|
|
30
|
+
* falseの場合setOnInsertのみ
|
|
31
|
+
* trueの場合setのみ
|
|
32
|
+
*/
|
|
33
|
+
update: boolean;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
bulkWriteResult: BulkWriteResult;
|
|
36
|
+
modifiedProductOffers: {
|
|
37
|
+
id: string;
|
|
38
|
+
}[];
|
|
39
|
+
} | void>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|