@chevre/domain 23.1.0-alpha.23 → 23.1.0-alpha.25
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/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
- package/example/src/chevre/reIndex.ts +0 -1
- package/lib/chevre/repo/event.d.ts +0 -35
- package/lib/chevre/repo/event.js +0 -100
- package/lib/chevre/repo/ticket.d.ts +7 -1
- package/lib/chevre/repo/ticket.js +14 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +1 -1
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -1
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +1 -1
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +1 -1
- package/package.json +3 -3
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +0 -7
|
@@ -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);
|
|
@@ -12,7 +12,6 @@ async function main() {
|
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
14
|
await chevre.repository.EventOffer.createInstance(mongoose.connection);
|
|
15
|
-
await chevre.repository.Member.createInstance(mongoose.connection);
|
|
16
15
|
console.log('success!');
|
|
17
16
|
}
|
|
18
17
|
|
|
@@ -75,41 +75,6 @@ export declare class EventRepo {
|
|
|
75
75
|
attributes: factory.event.screeningEvent.IAttributes[];
|
|
76
76
|
expectsNoContent: boolean;
|
|
77
77
|
}): Promise<string[] | void>;
|
|
78
|
-
/**
|
|
79
|
-
* 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
|
|
80
|
-
* 施設コンテンツとルームは1つに限定
|
|
81
|
-
* 存在すれば、特定の属性のみ更新する
|
|
82
|
-
* @deprecated migrate to upsertManyScreeningEventByIdentifier
|
|
83
|
-
*/
|
|
84
|
-
upsertManyByAdditionalPropertyDeprecated(params: {
|
|
85
|
-
events: factory.event.screeningEvent.IAttributes[];
|
|
86
|
-
additionalPropertyFilter: {
|
|
87
|
-
name: string;
|
|
88
|
-
};
|
|
89
|
-
eventSeries: {
|
|
90
|
-
/**
|
|
91
|
-
* 施設コンテンツID
|
|
92
|
-
*/
|
|
93
|
-
id: string;
|
|
94
|
-
};
|
|
95
|
-
screeningRoom: {
|
|
96
|
-
/**
|
|
97
|
-
* ルームコード
|
|
98
|
-
*/
|
|
99
|
-
branchCode: string;
|
|
100
|
-
};
|
|
101
|
-
}, options: {
|
|
102
|
-
/**
|
|
103
|
-
* falseの場合setOnInsertのみ
|
|
104
|
-
* trueの場合setのみ
|
|
105
|
-
*/
|
|
106
|
-
update: boolean;
|
|
107
|
-
}): Promise<{
|
|
108
|
-
bulkWriteResult: BulkWriteResult;
|
|
109
|
-
modifiedEvents: {
|
|
110
|
-
id: string;
|
|
111
|
-
}[];
|
|
112
|
-
} | void>;
|
|
113
78
|
/**
|
|
114
79
|
* イベントコードをキーにして冪等置換
|
|
115
80
|
*/
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -291,106 +291,6 @@ class EventRepo {
|
|
|
291
291
|
return insertingDocs.map(({ _id }) => _id);
|
|
292
292
|
});
|
|
293
293
|
}
|
|
294
|
-
/**
|
|
295
|
-
* 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
|
|
296
|
-
* 施設コンテンツとルームは1つに限定
|
|
297
|
-
* 存在すれば、特定の属性のみ更新する
|
|
298
|
-
* @deprecated migrate to upsertManyScreeningEventByIdentifier
|
|
299
|
-
*/
|
|
300
|
-
// tslint:disable-next-line:max-func-body-length
|
|
301
|
-
upsertManyByAdditionalPropertyDeprecated(params, options) {
|
|
302
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
303
|
-
const { update } = options;
|
|
304
|
-
const bulkWriteOps = [];
|
|
305
|
-
const additionalProperties = [];
|
|
306
|
-
const { events, additionalPropertyFilter, eventSeries, screeningRoom } = params;
|
|
307
|
-
if (Array.isArray(events)) {
|
|
308
|
-
events.forEach((creatingEventParams) => {
|
|
309
|
-
var _a, _b;
|
|
310
|
-
if (creatingEventParams.typeOf !== factory.eventType.ScreeningEvent) {
|
|
311
|
-
throw new factory.errors.NotImplemented(`only ${factory.eventType.ScreeningEvent} implemented`);
|
|
312
|
-
}
|
|
313
|
-
const additionalPropertyValue = (_b = (_a = creatingEventParams.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === additionalPropertyFilter.name)) === null || _b === void 0 ? void 0 : _b.value;
|
|
314
|
-
if (typeof additionalPropertyValue !== 'string' || additionalPropertyValue === '') {
|
|
315
|
-
throw new factory.errors.ArgumentNull('additionalProperty.value');
|
|
316
|
-
}
|
|
317
|
-
additionalProperties.push({ name: additionalPropertyFilter.name, value: additionalPropertyValue });
|
|
318
|
-
if (creatingEventParams.superEvent.id !== eventSeries.id) {
|
|
319
|
-
throw new factory.errors.Argument('superEvent.id', 'superEvent.id not matched');
|
|
320
|
-
}
|
|
321
|
-
if (creatingEventParams.location.branchCode !== screeningRoom.branchCode) {
|
|
322
|
-
throw new factory.errors.Argument('location.branchCode', 'location.branchCode not matched');
|
|
323
|
-
}
|
|
324
|
-
const filter = {
|
|
325
|
-
typeOf: { $eq: creatingEventParams.typeOf },
|
|
326
|
-
'project.id': { $eq: creatingEventParams.project.id },
|
|
327
|
-
// 追加特性をキーに更新
|
|
328
|
-
additionalProperty: {
|
|
329
|
-
$exists: true,
|
|
330
|
-
$all: [{ name: additionalPropertyFilter.name, value: additionalPropertyValue }]
|
|
331
|
-
},
|
|
332
|
-
'superEvent.id': { $exists: true, $eq: creatingEventParams.superEvent.id } // add superEvent.id(2024-09-15~)
|
|
333
|
-
};
|
|
334
|
-
if (update === true) {
|
|
335
|
-
// implemente(2024-12-20~)
|
|
336
|
-
const { eventStatus, superEvent, offers // <-上書き可能な属性を限定的に
|
|
337
|
-
} = creatingEventParams;
|
|
338
|
-
bulkWriteOps.push({
|
|
339
|
-
updateOne: {
|
|
340
|
-
filter,
|
|
341
|
-
update: {
|
|
342
|
-
$set: {
|
|
343
|
-
eventStatus,
|
|
344
|
-
superEvent,
|
|
345
|
-
'offers.seller.makesOffer': offers.seller.makesOffer
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
upsert: false
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
const { coaInfo, // ←適用しない
|
|
354
|
-
// identifier, // support identifier(2025-05-13~)
|
|
355
|
-
maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // ←適用しない
|
|
356
|
-
eventStatus, superEvent } = creatingEventParams, // <-上書き可能な属性を限定的に
|
|
357
|
-
setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent"]);
|
|
358
|
-
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id: EventRepo.CREATE_ID() });
|
|
359
|
-
bulkWriteOps.push({
|
|
360
|
-
updateOne: {
|
|
361
|
-
filter,
|
|
362
|
-
update: {
|
|
363
|
-
$setOnInsert: setOnInsert,
|
|
364
|
-
// 変更可能な属性のみ上書き
|
|
365
|
-
$set: {
|
|
366
|
-
eventStatus,
|
|
367
|
-
superEvent // add superEvent(2024-09-15~)
|
|
368
|
-
}
|
|
369
|
-
},
|
|
370
|
-
upsert: true
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
if (bulkWriteOps.length > 0) {
|
|
377
|
-
const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
378
|
-
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
379
|
-
const modifiedEvents = yield this.eventModel.find({
|
|
380
|
-
typeOf: { $eq: params.events[0].typeOf },
|
|
381
|
-
'project.id': { $eq: params.events[0].project.id },
|
|
382
|
-
additionalProperty: { $exists: true, $in: additionalProperties },
|
|
383
|
-
'superEvent.id': { $exists: true, $eq: eventSeries.id } // add superEvent.id(2024-09-15~)
|
|
384
|
-
}, {
|
|
385
|
-
_id: 0,
|
|
386
|
-
id: { $toString: '$_id' }
|
|
387
|
-
})
|
|
388
|
-
.lean() // lean(2024-09-15~)
|
|
389
|
-
.exec();
|
|
390
|
-
return { bulkWriteResult, modifiedEvents };
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
294
|
/**
|
|
395
295
|
* イベントコードをキーにして冪等置換
|
|
396
296
|
*/
|
|
@@ -38,5 +38,11 @@ export declare class TicketRepo {
|
|
|
38
38
|
* 承認コードからチケットを発行する
|
|
39
39
|
*/
|
|
40
40
|
issueByTicketToken(params: IIssueParams): Promise<Pick<ITicket, 'id'>>;
|
|
41
|
-
|
|
41
|
+
findTickets(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<ITicket[]>;
|
|
42
|
+
/**
|
|
43
|
+
* 発行日時を一定期間過ぎたチケットを削除する
|
|
44
|
+
*/
|
|
45
|
+
deleteTicketsByDateIssued(params: {
|
|
46
|
+
dateIssuedLt: Date;
|
|
47
|
+
}): Promise<void>;
|
|
42
48
|
}
|
|
@@ -69,7 +69,7 @@ class TicketRepo {
|
|
|
69
69
|
return { id: insertedId };
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
findTickets(params, inclusion) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
74
|
var _a;
|
|
75
75
|
const conditions = TicketRepo.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -92,5 +92,18 @@ class TicketRepo {
|
|
|
92
92
|
.exec();
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* 発行日時を一定期間過ぎたチケットを削除する
|
|
97
|
+
*/
|
|
98
|
+
deleteTicketsByDateIssued(params) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
yield this.ticketModel.deleteMany({
|
|
101
|
+
dateIssued: {
|
|
102
|
+
$lt: params.dateIssuedLt
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
.exec();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
95
108
|
}
|
|
96
109
|
exports.TicketRepo = TicketRepo;
|
|
@@ -25,7 +25,7 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
25
25
|
if (typeof placeOrderIdByInstrument !== 'string' || placeOrderIdByInstrument === '') {
|
|
26
26
|
throw new factory.errors.NotFound('instrument as placeOrder');
|
|
27
27
|
}
|
|
28
|
-
const ticket = (yield repos.ticket.
|
|
28
|
+
const ticket = (yield repos.ticket.findTickets({
|
|
29
29
|
limit: 1,
|
|
30
30
|
page: 1,
|
|
31
31
|
project: { id: { $eq: event.project.id } },
|
|
@@ -27,7 +27,7 @@ function requestedProgramMembershipUsed2permit(params) {
|
|
|
27
27
|
else if ((programMembershipUsed === null || programMembershipUsed === void 0 ? void 0 : programMembershipUsed.typeOf) === 'Ticket') {
|
|
28
28
|
const { ticketToken } = programMembershipUsed;
|
|
29
29
|
if (typeof ticketToken === 'string') {
|
|
30
|
-
const ticket = (yield repos.ticket.
|
|
30
|
+
const ticket = (yield repos.ticket.findTickets({
|
|
31
31
|
limit: 1,
|
|
32
32
|
page: 1,
|
|
33
33
|
project: { id: { $eq: params.project.id } },
|
package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js
CHANGED
|
@@ -58,7 +58,7 @@ function acceptAction2ticket(params) {
|
|
|
58
58
|
const ticketToken = (_b = (_a = acceptPayAction.instrument) === null || _a === void 0 ? void 0 : _a.find((ticketAsInstrument) => ticketAsInstrument.typeOf === 'Ticket')) === null || _b === void 0 ? void 0 : _b.ticketToken;
|
|
59
59
|
let acceptAction2ticketResult;
|
|
60
60
|
if (typeof ticketToken === 'string' && ticketToken !== '') {
|
|
61
|
-
const ticket = (yield repos.ticket.
|
|
61
|
+
const ticket = (yield repos.ticket.findTickets({
|
|
62
62
|
limit: 1,
|
|
63
63
|
page: 1,
|
|
64
64
|
project: { id: { $eq: project.id } },
|
|
@@ -25,7 +25,7 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
25
25
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
26
26
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
27
27
|
case factory.service.paymentService.PaymentServiceType.FaceToFace:
|
|
28
|
-
const ticket = (yield repos.ticket.
|
|
28
|
+
const ticket = (yield repos.ticket.findTickets({
|
|
29
29
|
limit: 1,
|
|
30
30
|
page: 1,
|
|
31
31
|
project: { id: { $eq: project.id } },
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "5.4.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "12.11.0
|
|
14
|
+
"@chevre/factory": "5.4.0-alpha.1",
|
|
15
|
+
"@cinerino/sdk": "12.11.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.1.0-alpha.
|
|
118
|
+
"version": "23.1.0-alpha.25"
|
|
119
119
|
}
|