@chevre/domain 23.1.0-alpha.2 → 23.1.0-alpha.21
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/assetTransaction/processReserve.ts +8 -3
- package/example/src/chevre/authorizeEventServiceOffer.ts +7 -5
- package/example/src/chevre/eventOffer/adminEventOffers.ts +67 -0
- package/example/src/chevre/eventOffer/publishEventOfferToken.ts +98 -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 +2 -2
- package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
- package/lib/chevre/repo/authorization.d.ts +3 -2
- package/lib/chevre/repo/authorization.js +13 -5
- package/lib/chevre/repo/event.d.ts +2 -1
- package/lib/chevre/repo/event.js +4 -4
- package/lib/chevre/repo/eventOffer.d.ts +1 -1
- package/lib/chevre/repo/eventOffer.js +14 -8
- package/lib/chevre/repo/member.d.ts +18 -1
- package/lib/chevre/repo/member.js +14 -8
- package/lib/chevre/repo/mongoose/schemas/eventOffer.js +39 -35
- package/lib/chevre/repo/mongoose/schemas/member.js +10 -0
- 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.d.ts +2 -1
- package/lib/chevre/service/assetTransaction/pay.js +1 -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 +42 -25
- 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 +19 -27
- package/lib/chevre/service/payment/any.d.ts +1 -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/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/upsertManyEventsByAdditionalProperty.ts +0 -193
|
@@ -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,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
|
+
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 eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
const validFrom = moment()
|
|
15
|
+
.toDate();
|
|
16
|
+
const validThrough = moment(validFrom)
|
|
17
|
+
.add(1, 'hour')
|
|
18
|
+
.toDate();
|
|
19
|
+
const eventOffer: Omit<chevre.factory.eventOffer.IEventOffer, 'id'> = {
|
|
20
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
21
|
+
identifier: '20251113eventOffer',
|
|
22
|
+
itemOffered: {
|
|
23
|
+
id: '69151228ad580da66c8b5068',
|
|
24
|
+
typeOf: chevre.factory.eventType.ScreeningEvent
|
|
25
|
+
},
|
|
26
|
+
availableAtOrFrom: {
|
|
27
|
+
identifier: 'SmartTheaterTXN'
|
|
28
|
+
},
|
|
29
|
+
validFrom,
|
|
30
|
+
validThrough,
|
|
31
|
+
seller: {
|
|
32
|
+
id: '59d20831e53ebc2b4e774466',
|
|
33
|
+
typeOf: chevre.factory.organizationType.Corporation
|
|
34
|
+
},
|
|
35
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
let result = await eventOfferRepo.upsertEventOffersByIdentifier(
|
|
39
|
+
[
|
|
40
|
+
{
|
|
41
|
+
$set: eventOffer,
|
|
42
|
+
$unset: {}
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
{
|
|
46
|
+
update: false
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
console.log(result);
|
|
50
|
+
|
|
51
|
+
result = await eventOfferRepo.upsertEventOffersByIdentifier(
|
|
52
|
+
[
|
|
53
|
+
{
|
|
54
|
+
$set: eventOffer,
|
|
55
|
+
$unset: {}
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
{
|
|
59
|
+
update: true
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
console.log(result);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main()
|
|
66
|
+
.then()
|
|
67
|
+
.catch(console.error);
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import { sign } from 'jsonwebtoken';
|
|
3
|
+
import * as moment from 'moment';
|
|
4
|
+
import * as mongoose from 'mongoose';
|
|
5
|
+
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const eventOfferRepo = await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
14
|
+
const issuerRepo = await chevre.repository.Issuer.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const eventOffer = (await eventOfferRepo.findEventOffers(
|
|
17
|
+
{
|
|
18
|
+
limit: 1,
|
|
19
|
+
page: 1,
|
|
20
|
+
project: { id: { $eq: project.id } },
|
|
21
|
+
id: { $eq: '691e5bb3929e69df1ec6e9a6' }
|
|
22
|
+
},
|
|
23
|
+
['offeredBy', 'identifier', 'itemOffered']
|
|
24
|
+
)).shift();
|
|
25
|
+
if (eventOffer === undefined) {
|
|
26
|
+
throw new chevre.factory.errors.NotFound(chevre.factory.offerType.Offer);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const issuerIdentifier = eventOffer.offeredBy?.identifier;
|
|
30
|
+
if (typeof issuerIdentifier !== 'string') {
|
|
31
|
+
throw new chevre.factory.errors.NotFound('eventOffer.offeredBy?.identifier');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// const tier = (await memberProgramRepo.projectMemberProgramTiers(
|
|
35
|
+
// {
|
|
36
|
+
// limit: 1,
|
|
37
|
+
// page: 1,
|
|
38
|
+
// project: { id: { $eq: project.id } },
|
|
39
|
+
// identifier: { $eq: tierIdentifier }
|
|
40
|
+
// }
|
|
41
|
+
// )).shift();
|
|
42
|
+
// if (tier === undefined) {
|
|
43
|
+
// throw new chevre.factory.errors.NotFound('MemberProgramTier');
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
const { url, tokenSecret } = await issuerRepo.findByIdentifier({
|
|
47
|
+
identifier: issuerIdentifier,
|
|
48
|
+
project: { id: project.id }
|
|
49
|
+
});
|
|
50
|
+
if (typeof tokenSecret !== 'string') {
|
|
51
|
+
throw new chevre.factory.errors.NotFound('issuer.tokenSecret');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const payload: chevre.factory.assetTransaction.reserve.IEventOfferTokenPayload = {
|
|
55
|
+
identifier: eventOffer.identifier,
|
|
56
|
+
validFrom: moment()
|
|
57
|
+
.format('YYYY-MM-DDTHH:mm:ssZ'),
|
|
58
|
+
validThrough: moment()
|
|
59
|
+
.add(1, 'hour')
|
|
60
|
+
.format('YYYY-MM-DDTHH:mm:ssZ'),
|
|
61
|
+
eligibleQuantity: {
|
|
62
|
+
maxValue: 1
|
|
63
|
+
},
|
|
64
|
+
itemOffered: {
|
|
65
|
+
id: 'xxx'
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const token = await new Promise<string>((resolve, reject) => {
|
|
70
|
+
// 所有権を暗号化する
|
|
71
|
+
sign(
|
|
72
|
+
payload,
|
|
73
|
+
tokenSecret,
|
|
74
|
+
{
|
|
75
|
+
// algorithm: jwtSetting.algorithm,
|
|
76
|
+
issuer: url,
|
|
77
|
+
expiresIn: 1800
|
|
78
|
+
// subject,
|
|
79
|
+
},
|
|
80
|
+
(err, encoded) => {
|
|
81
|
+
if (err instanceof Error) {
|
|
82
|
+
reject(err);
|
|
83
|
+
} else {
|
|
84
|
+
if (typeof encoded !== 'string') {
|
|
85
|
+
reject(new Error('cannot be signed unexpectedly'));
|
|
86
|
+
} else {
|
|
87
|
+
resolve(encoded);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
console.log(token);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
main()
|
|
97
|
+
.then()
|
|
98
|
+
.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,8 @@ 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
|
-
|
|
14
|
+
await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
15
|
+
await chevre.repository.Member.createInstance(mongoose.connection);
|
|
16
16
|
console.log('success!');
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -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) {
|
|
@@ -16,9 +16,10 @@ export declare class AuthorizationRepo {
|
|
|
16
16
|
constructor(connection: Connection);
|
|
17
17
|
static CREATE_MONGO_CONDITIONS(params: factory.authorization.ISearchConditions): FilterQuery<factory.authorization.IAuthorization>[];
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* 承認を発行する
|
|
20
|
+
* コードが自動生成されます
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
issueAuthorization(params: IPublishParams[]): Promise<factory.authorization.IAuthorization[]>;
|
|
22
23
|
/**
|
|
23
24
|
* コードで有効な承認を参照する
|
|
24
25
|
*/
|
|
@@ -111,9 +111,10 @@ class AuthorizationRepo {
|
|
|
111
111
|
return andConditions;
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* 承認を発行する
|
|
115
|
+
* コードが自動生成されます
|
|
115
116
|
*/
|
|
116
|
-
|
|
117
|
+
issueAuthorization(params) {
|
|
117
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
119
|
const saveParams = params.map(({ project, object, validFrom, expiresInSeconds, audience, author, issuedBy }) => {
|
|
119
120
|
const code = uuid.v4();
|
|
@@ -144,7 +145,7 @@ class AuthorizationRepo {
|
|
|
144
145
|
throw new factory.errors.NotFound(this.authorizationModel.modelName);
|
|
145
146
|
}
|
|
146
147
|
const { id, object, typeOf, audience, issuedBy } = doc;
|
|
147
|
-
return Object.assign(
|
|
148
|
+
return Object.assign({ id, object, typeOf, issuedBy }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined);
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
/**
|
|
@@ -217,14 +218,21 @@ class AuthorizationRepo {
|
|
|
217
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
219
|
if (params.length > 0) {
|
|
219
220
|
const docs = params.map(({ project, code, object, validFrom, expiresInSeconds, audience, author, issuedBy }) => {
|
|
221
|
+
// issuedByは必須化(2025-11-21~)
|
|
222
|
+
if (typeof (issuedBy === null || issuedBy === void 0 ? void 0 : issuedBy.id) !== 'string') {
|
|
223
|
+
throw new factory.errors.ArgumentNull('issuedBy?.id');
|
|
224
|
+
}
|
|
220
225
|
const validUntil = moment(validFrom)
|
|
221
226
|
.add(expiresInSeconds, 'seconds')
|
|
222
227
|
.toDate();
|
|
223
|
-
return Object.assign(
|
|
228
|
+
return Object.assign({ project, typeOf: 'Authorization', author,
|
|
224
229
|
code,
|
|
230
|
+
issuedBy,
|
|
225
231
|
object,
|
|
226
232
|
validFrom,
|
|
227
|
-
validUntil }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined
|
|
233
|
+
validUntil }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined
|
|
234
|
+
// ...(typeof issuedBy?.id === 'string') ? { issuedBy } : undefined
|
|
235
|
+
);
|
|
228
236
|
});
|
|
229
237
|
const result = yield this.authorizationModel.insertMany(docs, { ordered: false, rawResult: true });
|
|
230
238
|
if (result.insertedCount !== docs.length) {
|
|
@@ -79,8 +79,9 @@ export declare class EventRepo {
|
|
|
79
79
|
* 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
|
|
80
80
|
* 施設コンテンツとルームは1つに限定
|
|
81
81
|
* 存在すれば、特定の属性のみ更新する
|
|
82
|
+
* @deprecated migrate to upsertManyScreeningEventByIdentifier
|
|
82
83
|
*/
|
|
83
|
-
|
|
84
|
+
upsertManyByAdditionalPropertyDeprecated(params: {
|
|
84
85
|
events: factory.event.screeningEvent.IAttributes[];
|
|
85
86
|
additionalPropertyFilter: {
|
|
86
87
|
name: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -22,13 +22,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.EventRepo = void 0;
|
|
24
24
|
const mongoose_1 = require("mongoose");
|
|
25
|
-
const uniqid = require("uniqid");
|
|
26
25
|
const errorHandler_1 = require("../errorHandler");
|
|
27
26
|
const factory = require("../factory");
|
|
28
27
|
const EventFactory = require("../factory/event");
|
|
29
28
|
const settings_1 = require("../settings");
|
|
30
29
|
const event_1 = require("./mongoose/schemas/event");
|
|
31
|
-
const USE_OBJECT_ID_AS_EVENT_ID = process.env.USE_OBJECT_ID_AS_EVENT_ID === '1';
|
|
32
30
|
const AVAILABLE_PUBLIC_PROJECT_FIELDS = [
|
|
33
31
|
'additionalProperty', 'aggregateReservation', 'attendeeCount', 'checkInCount', 'coaInfo',
|
|
34
32
|
// 'description',
|
|
@@ -49,7 +47,8 @@ class EventRepo {
|
|
|
49
47
|
*/
|
|
50
48
|
static CREATE_ID() {
|
|
51
49
|
// implement using ObjectId(2025-10-17~)
|
|
52
|
-
return (USE_OBJECT_ID_AS_EVENT_ID) ? new
|
|
50
|
+
// return (USE_OBJECT_ID_AS_EVENT_ID) ? new Types.ObjectId().toHexString() : uniqid();
|
|
51
|
+
return new mongoose_1.Types.ObjectId().toHexString(); // 設定を廃止(2025-11-20~)
|
|
53
52
|
}
|
|
54
53
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
55
54
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
@@ -296,9 +295,10 @@ class EventRepo {
|
|
|
296
295
|
* 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
|
|
297
296
|
* 施設コンテンツとルームは1つに限定
|
|
298
297
|
* 存在すれば、特定の属性のみ更新する
|
|
298
|
+
* @deprecated migrate to upsertManyScreeningEventByIdentifier
|
|
299
299
|
*/
|
|
300
300
|
// tslint:disable-next-line:max-func-body-length
|
|
301
|
-
|
|
301
|
+
upsertManyByAdditionalPropertyDeprecated(params, options) {
|
|
302
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
303
303
|
const { update } = options;
|
|
304
304
|
const bulkWriteOps = [];
|
|
@@ -21,7 +21,7 @@ export declare class EventOfferRepo {
|
|
|
21
21
|
* オファーコードとイベントIDをキーにして冪等置換
|
|
22
22
|
*/
|
|
23
23
|
upsertEventOffersByIdentifier(params: {
|
|
24
|
-
$set: Pick<IDocType, 'identifier' | 'itemOffered' | 'offeredBy' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough'> & {
|
|
24
|
+
$set: Pick<IDocType, 'identifier' | 'itemOffered' | 'offeredBy' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough' | 'availableAtOrFrom'> & {
|
|
25
25
|
id?: never;
|
|
26
26
|
};
|
|
27
27
|
$unset: IUnset;
|
|
@@ -32,7 +32,7 @@ class EventOfferRepo {
|
|
|
32
32
|
this.eventOfferModel = connection.model(eventOffer_1.modelName, (0, eventOffer_1.createSchema)());
|
|
33
33
|
}
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
36
36
|
const andConditions = [];
|
|
37
37
|
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
38
38
|
if (typeof idEq === 'string') {
|
|
@@ -58,19 +58,23 @@ class EventOfferRepo {
|
|
|
58
58
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
59
59
|
andConditions.push({ 'itemOffered.id': { $in: itemOfferedIdIn } });
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const availableAtOrFromIdentifierEq = (_l = (_k = params.availableAtOrFrom) === null || _k === void 0 ? void 0 : _k.identifier) === null || _l === void 0 ? void 0 : _l.$eq;
|
|
62
|
+
if (typeof availableAtOrFromIdentifierEq === 'string') {
|
|
63
|
+
andConditions.push({ 'availableAtOrFrom.identifier': { $eq: availableAtOrFromIdentifierEq } });
|
|
64
|
+
}
|
|
65
|
+
const offeredByIdEq = (_o = (_m = params.offeredBy) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
62
66
|
if (typeof offeredByIdEq === 'string') {
|
|
63
67
|
andConditions.push({ 'offeredBy.id': { $exists: true, $eq: offeredByIdEq } });
|
|
64
68
|
}
|
|
65
|
-
const sellerByIdEq = (
|
|
69
|
+
const sellerByIdEq = (_q = (_p = params.seller) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
|
|
66
70
|
if (typeof sellerByIdEq === 'string') {
|
|
67
71
|
andConditions.push({ 'seller.id': { $eq: sellerByIdEq } });
|
|
68
72
|
}
|
|
69
|
-
const validFromLte = (
|
|
73
|
+
const validFromLte = (_r = params.validFrom) === null || _r === void 0 ? void 0 : _r.$lte;
|
|
70
74
|
if (validFromLte instanceof Date) {
|
|
71
75
|
andConditions.push({ validFrom: { $lte: validFromLte } });
|
|
72
76
|
}
|
|
73
|
-
const validThroughGte = (
|
|
77
|
+
const validThroughGte = (_s = params.validThrough) === null || _s === void 0 ? void 0 : _s.$gte;
|
|
74
78
|
if (validThroughGte instanceof Date) {
|
|
75
79
|
andConditions.push({ validThrough: { $gte: validThroughGte } });
|
|
76
80
|
}
|
|
@@ -112,7 +116,7 @@ class EventOfferRepo {
|
|
|
112
116
|
const queryFilters = [];
|
|
113
117
|
if (Array.isArray(params)) {
|
|
114
118
|
params.forEach(({ $set, $unset }) => {
|
|
115
|
-
const { identifier, itemOffered, offeredBy, seller, project, validFrom, validThrough } = $set;
|
|
119
|
+
const { identifier, itemOffered, offeredBy, seller, project, validFrom, validThrough, availableAtOrFrom } = $set;
|
|
116
120
|
if (typeof identifier !== 'string' || identifier === '') {
|
|
117
121
|
throw new factory.errors.ArgumentNull('identifier');
|
|
118
122
|
}
|
|
@@ -132,7 +136,8 @@ class EventOfferRepo {
|
|
|
132
136
|
});
|
|
133
137
|
if (update === true) {
|
|
134
138
|
const setFields = Object.assign({ validFrom,
|
|
135
|
-
validThrough
|
|
139
|
+
validThrough,
|
|
140
|
+
availableAtOrFrom }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
|
|
136
141
|
const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
|
|
137
142
|
const updateOne = {
|
|
138
143
|
filter,
|
|
@@ -143,7 +148,8 @@ class EventOfferRepo {
|
|
|
143
148
|
}
|
|
144
149
|
else {
|
|
145
150
|
const setOnInsert = Object.assign({ itemOffered, identifier, project, seller, typeOf: factory.offerType.Offer, validFrom,
|
|
146
|
-
validThrough
|
|
151
|
+
validThrough,
|
|
152
|
+
availableAtOrFrom }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
|
|
147
153
|
const updateFilter = {
|
|
148
154
|
$setOnInsert: setOnInsert
|
|
149
155
|
};
|
|
@@ -2,7 +2,13 @@ import type { Connection, FilterQuery } from 'mongoose';
|
|
|
2
2
|
import * as factory from '../factory';
|
|
3
3
|
import { IGlobalMember } from './mongoose/schemas/member/global';
|
|
4
4
|
type IKeyOfProjection = keyof factory.iam.IMember;
|
|
5
|
-
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'
|
|
5
|
+
export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'> & {
|
|
6
|
+
/**
|
|
7
|
+
* アプリケーションコード
|
|
8
|
+
* 2025-11-13~
|
|
9
|
+
*/
|
|
10
|
+
identifier?: string;
|
|
11
|
+
};
|
|
6
12
|
/**
|
|
7
13
|
* IAMメンバーリポジトリ
|
|
8
14
|
*/
|
|
@@ -35,6 +41,13 @@ export declare class MemberRepo {
|
|
|
35
41
|
name?: {
|
|
36
42
|
$regex?: string;
|
|
37
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* アプリケーションコード
|
|
46
|
+
* 2025-11-15~
|
|
47
|
+
*/
|
|
48
|
+
identifier?: {
|
|
49
|
+
$eq?: string;
|
|
50
|
+
};
|
|
38
51
|
};
|
|
39
52
|
}): Promise<{
|
|
40
53
|
member: ICustomerMember;
|
|
@@ -87,6 +100,10 @@ export declare class MemberRepo {
|
|
|
87
100
|
hasRole?: factory.iam.IMemberRole[];
|
|
88
101
|
image?: string;
|
|
89
102
|
name?: string;
|
|
103
|
+
/**
|
|
104
|
+
* アプリケーションコード
|
|
105
|
+
*/
|
|
106
|
+
identifier?: string;
|
|
90
107
|
};
|
|
91
108
|
$unset: {
|
|
92
109
|
'member.member'?: 1;
|