@chevre/domain 24.0.0-alpha.63 → 24.0.0-alpha.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/assetTransaction/reserve.d.ts +1 -6
- package/lib/chevre/repo/assetTransaction/reserve.js +49 -44
- package/lib/chevre/repo/reservation.d.ts +2 -6
- package/lib/chevre/repo/reservation.js +8 -11
- package/lib/chevre/service/reserve/findReservations.d.ts +8 -2
- package/lib/chevre/service/reserve/findReservations.js +54 -57
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import * as factory from '../../factory';
|
|
|
3
3
|
type ISubReservationAsFindResult = Pick<factory.reservation.eventReservation.IReservation, 'underName' | 'id'> & {
|
|
4
4
|
price?: factory.reservation.eventReservation.IPrice;
|
|
5
5
|
reservedTicket?: Pick<factory.reservation.eventReservation.IReservedTicket, 'ticketType'>;
|
|
6
|
+
reservationFor?: factory.assetTransaction.reserve.IReservationFor;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* 予約取引リポジトリ
|
|
@@ -10,12 +11,6 @@ type ISubReservationAsFindResult = Pick<factory.reservation.eventReservation.IRe
|
|
|
10
11
|
export declare class ReserveTransactionRepo {
|
|
11
12
|
private readonly transactionModel;
|
|
12
13
|
constructor(connection: Connection);
|
|
13
|
-
/**
|
|
14
|
-
* 予約取引から予約を検索する
|
|
15
|
-
*/
|
|
16
|
-
findSubReservationsByReservationNumber(params: {
|
|
17
|
-
reservationNumber: string;
|
|
18
|
-
}): Promise<ISubReservationAsFindResult[]>;
|
|
19
14
|
/**
|
|
20
15
|
* 予約取引から予約を検索する
|
|
21
16
|
* limitはしない
|
|
@@ -35,50 +35,54 @@ class ReserveTransactionRepo {
|
|
|
35
35
|
constructor(connection) {
|
|
36
36
|
this.transactionModel = connection.model(assetTransaction_1.modelName, (0, assetTransaction_1.createSchema)());
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
async findSubReservationsByReservationNumber(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
38
|
+
// /**
|
|
39
|
+
// * 予約取引から予約を検索する
|
|
40
|
+
// */
|
|
41
|
+
// public async findSubReservationsByReservationNumber(
|
|
42
|
+
// params: {
|
|
43
|
+
// reservationNumber: string;
|
|
44
|
+
// }
|
|
45
|
+
// ): Promise<ISubReservationAsFindResult[]> {
|
|
46
|
+
// const aggregate = this.transactionModel.aggregate<ISubReservationAsFindResult>([
|
|
47
|
+
// {
|
|
48
|
+
// $match: {
|
|
49
|
+
// typeOf: { $eq: factory.assetTransactionType.Reserve },
|
|
50
|
+
// transactionNumber: { $eq: params.reservationNumber }
|
|
51
|
+
// }
|
|
52
|
+
// },
|
|
53
|
+
// {
|
|
54
|
+
// $unwind: {
|
|
55
|
+
// path: '$object.subReservation'
|
|
56
|
+
// // includeArrayIndex: 'elementIndex'
|
|
57
|
+
// }
|
|
58
|
+
// },
|
|
59
|
+
// // {
|
|
60
|
+
// // $match: {
|
|
61
|
+
// // typeOf: { $eq: factory.assetTransactionType.Reserve },
|
|
62
|
+
// // transactionNumber: { $eq: params.reservationNumber }
|
|
63
|
+
// // }
|
|
64
|
+
// // },
|
|
65
|
+
// {
|
|
66
|
+
// $project: {
|
|
67
|
+
// _id: 0,
|
|
68
|
+
// id: '$object.subReservation.id',
|
|
69
|
+
// price: '$object.subReservation.price',
|
|
70
|
+
// underName: '$object.underName',
|
|
71
|
+
// reservedTicket: {
|
|
72
|
+
// ticketType: '$object.subReservation.reservedTicket.ticketType',
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
// ]);
|
|
77
|
+
// // if (typeof filter.limit === 'number' && filter.limit > 0) {
|
|
78
|
+
// // const page: number = (typeof filter.page === 'number' && filter.page > 0) ? filter.page : 1;
|
|
79
|
+
// // aggregate.limit(filter.limit * page)
|
|
80
|
+
// // .skip(filter.limit * (page - 1));
|
|
81
|
+
// // }
|
|
82
|
+
// return aggregate
|
|
83
|
+
// .option({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
84
|
+
// .exec();
|
|
85
|
+
// }
|
|
82
86
|
/**
|
|
83
87
|
* 予約取引から予約を検索する
|
|
84
88
|
* limitはしない
|
|
@@ -112,6 +116,7 @@ class ReserveTransactionRepo {
|
|
|
112
116
|
id: '$object.subReservation.id',
|
|
113
117
|
price: '$object.subReservation.price',
|
|
114
118
|
underName: '$object.underName',
|
|
119
|
+
reservationFor: '$object.reservationFor',
|
|
115
120
|
reservedTicket: {
|
|
116
121
|
ticketType: '$object.subReservation.reservedTicket.ticketType',
|
|
117
122
|
}
|
|
@@ -15,13 +15,9 @@ type ISavingReservedTicket = Omit<factory.assetTransaction.reserve.ISubReservati
|
|
|
15
15
|
/**
|
|
16
16
|
* ドキュメントとして保管する予約
|
|
17
17
|
*/
|
|
18
|
-
export type ICreatingReservation = Omit<factory.reservation.eventReservation.IReservation, 'id' | '
|
|
18
|
+
export type ICreatingReservation = Omit<factory.reservation.eventReservation.IReservation, 'id' | 'reservedTicket'> & {
|
|
19
19
|
_id: string;
|
|
20
|
-
|
|
21
|
-
* priceは廃止予定だが、互換性維持対応としてひとまず型を強制的に合わせる
|
|
22
|
-
*/
|
|
23
|
-
price?: factory.reservation.eventReservation.IPrice;
|
|
24
|
-
reservedTicket: factory.assetTransaction.reserve.ISubReservationReservedTicket | ISavingReservedTicket;
|
|
20
|
+
reservedTicket: ISavingReservedTicket;
|
|
25
21
|
};
|
|
26
22
|
/**
|
|
27
23
|
* 廃止予定の予約属性
|
|
@@ -28,7 +28,6 @@ const reservation_1 = require("./mongoose/schemas/reservation");
|
|
|
28
28
|
const factory = __importStar(require("../factory"));
|
|
29
29
|
const createMongoConditions_1 = require("./factory/reservation/createMongoConditions");
|
|
30
30
|
const settings_1 = require("../settings");
|
|
31
|
-
const USE_DISCONTINUED_RESERVATION_PRICE = process.env.USE_DISCONTINUED_RESERVATION_PRICE === '1';
|
|
32
31
|
/**
|
|
33
32
|
* 予約リポジトリ
|
|
34
33
|
*/
|
|
@@ -137,17 +136,15 @@ class ReservationRepo {
|
|
|
137
136
|
const bulkWriteOps = [];
|
|
138
137
|
if (Array.isArray(params.subReservation)) {
|
|
139
138
|
params.subReservation.forEach((subReservation) => {
|
|
140
|
-
const { price, reservedTicket, ...subReservationWithoutPrice } = subReservation;
|
|
139
|
+
const { price: _discontinuePrice, reservedTicket, ...subReservationWithoutPrice } = subReservation;
|
|
141
140
|
const { ticketType, ...reservedTicketWithoutTicketType } = reservedTicket;
|
|
142
141
|
// 予約ドキュメントのticketTypeを最小化(2026-04-03~)
|
|
143
|
-
const savingReservedTicket =
|
|
144
|
-
|
|
145
|
-
: {
|
|
146
|
-
...
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
};
|
|
142
|
+
const savingReservedTicket = {
|
|
143
|
+
...reservedTicketWithoutTicketType,
|
|
144
|
+
ticketType: {
|
|
145
|
+
...((typeof ticketType.id === 'string') && { id: ticketType.id })
|
|
146
|
+
}
|
|
147
|
+
};
|
|
151
148
|
const setOnInsert = {
|
|
152
149
|
...subReservationWithoutPrice,
|
|
153
150
|
typeOf: factory.reservationType.EventReservation,
|
|
@@ -165,7 +162,7 @@ class ReservationRepo {
|
|
|
165
162
|
reservedTicket: savingReservedTicket,
|
|
166
163
|
...(params.underName !== undefined) ? { underName: params.underName } : undefined,
|
|
167
164
|
...(typeof params.broker?.typeOf === 'string') ? { broker: params.broker } : undefined,
|
|
168
|
-
|
|
165
|
+
// discontinue price(2026-03-31~)
|
|
169
166
|
};
|
|
170
167
|
bulkWriteOps.push({
|
|
171
168
|
updateOne: {
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import * as factory from '../../factory';
|
|
2
2
|
import type { ReserveTransactionRepo } from '../../repo/assetTransaction/reserve';
|
|
3
3
|
import type { IDeprecatedField, IKeyOfProjection, ReservationRepo } from '../../repo/reservation';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 予約検索レスポンスとしての予約
|
|
6
|
+
* 予約ドキュメントに予約取引の情報を補完する
|
|
7
|
+
*/
|
|
8
|
+
type IReservationAsFindResult = Omit<factory.reservation.eventReservation.IReservation, 'price' | 'underName' | 'reservedTicket' | 'reservationFor'> & {
|
|
5
9
|
price?: factory.reservation.eventReservation.IPrice;
|
|
10
|
+
underName?: factory.assetTransaction.reserve.IUnderName;
|
|
11
|
+
reservedTicket?: factory.assetTransaction.reserve.IObjectSubReservation['reservedTicket'];
|
|
12
|
+
reservationFor?: factory.assetTransaction.reserve.IReservationFor;
|
|
6
13
|
};
|
|
7
14
|
/**
|
|
8
15
|
* 予約を検索する
|
|
9
16
|
*/
|
|
10
17
|
export declare function findReservations(params: factory.reservation.eventReservation.ISearchConditions, options: {
|
|
11
18
|
inclusion: Partial<Record<IKeyOfProjection | IDeprecatedField, 1>>;
|
|
12
|
-
useReserveTransaction: boolean;
|
|
13
19
|
}): (repos: {
|
|
14
20
|
assetTransaction: {
|
|
15
21
|
reserve: ReserveTransactionRepo;
|
|
@@ -5,70 +5,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.findReservations = findReservations;
|
|
7
7
|
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const util_1 = require("util");
|
|
9
8
|
const debug = (0, debug_1.default)('chevre-domain:service:reserve:findReservations');
|
|
10
9
|
/**
|
|
11
10
|
* 予約を検索する
|
|
12
11
|
*/
|
|
13
12
|
function findReservations(params, options) {
|
|
14
13
|
return async (repos) => {
|
|
15
|
-
const { inclusion
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
...reservation.reservedTicket, // 予約ドキュメントのreservedTicketはそのまま返す
|
|
63
|
-
ticketType: ticketTypeByTransaction
|
|
64
|
-
}
|
|
14
|
+
const { inclusion } = options;
|
|
15
|
+
const rawReservations = await repos.reservation.findReservations(params, inclusion);
|
|
16
|
+
if (rawReservations.length === 0) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const requirePrice = Object.keys(inclusion).includes('price');
|
|
21
|
+
const requireUnderName = Object.keys(inclusion).includes('underName');
|
|
22
|
+
const requireReservedTicket = Object.keys(inclusion).includes('reservedTicket');
|
|
23
|
+
const requireReservationFor = Object.keys(inclusion).includes('reservationFor');
|
|
24
|
+
const reservationIds = rawReservations.map(({ id }) => id);
|
|
25
|
+
const subReservations = await repos.assetTransaction.reserve.findSubReservationsById({
|
|
26
|
+
ids: reservationIds
|
|
27
|
+
});
|
|
28
|
+
// 予約取引から参照した予約数と同じはず
|
|
29
|
+
debug('useReserveTransaction: true. reservations.length === subReservations.length?', rawReservations.length === subReservations.length);
|
|
30
|
+
return rawReservations.map((reservation) => {
|
|
31
|
+
const subReservationByTransaction = subReservations.find((s) => s.id === reservation.id);
|
|
32
|
+
const priceByTransaction = subReservationByTransaction?.price;
|
|
33
|
+
const underNameByTransaction = subReservationByTransaction?.underName;
|
|
34
|
+
const ticketTypeByTransaction = subReservationByTransaction?.reservedTicket?.ticketType;
|
|
35
|
+
const reservationForByTransaction = subReservationByTransaction?.reservationFor;
|
|
36
|
+
// 予約ドキュメントを最適化し始めたため、もう等しくない(2026-04-06~)
|
|
37
|
+
// // 予約取引から参照した属性と全く等しいはず
|
|
38
|
+
// if (requirePrice) {
|
|
39
|
+
// }
|
|
40
|
+
// if (requireUnderName) {
|
|
41
|
+
// }
|
|
42
|
+
// if (requireReservedTicket) {
|
|
43
|
+
// }
|
|
44
|
+
// if (requireReservationFor) {
|
|
45
|
+
// const reservationForMatched = isDeepStrictEqual(reservation.reservationFor, reservationForByTransaction);
|
|
46
|
+
// debug('requireReservationFor. reservationForMatched?', reservationForMatched);
|
|
47
|
+
// if (!reservationForMatched) {
|
|
48
|
+
// console.error('reservationForMatched: false!!!', reservation.id);
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
const { reservationFor, reservedTicket, ...rawReservation4result } = reservation; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
52
|
+
return {
|
|
53
|
+
...rawReservation4result, // 予約ドキュメントはそのまま返す
|
|
54
|
+
...(requirePrice && priceByTransaction !== undefined) ? { price: priceByTransaction } : undefined, // priceがあれば上書き
|
|
55
|
+
...(requireUnderName && underNameByTransaction !== undefined) ? { underName: underNameByTransaction } : undefined, // underNameがあれば上書き
|
|
56
|
+
...(requireReservedTicket && ticketTypeByTransaction !== undefined) // ticketTypeがあれば上書き
|
|
57
|
+
? {
|
|
58
|
+
reservedTicket: {
|
|
59
|
+
...reservedTicket, // 予約ドキュメントのreservedTicketはそのまま返す
|
|
60
|
+
ticketType: ticketTypeByTransaction
|
|
65
61
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
62
|
+
}
|
|
63
|
+
: undefined,
|
|
64
|
+
...(requireReservationFor && reservationForByTransaction !== undefined)
|
|
65
|
+
? { reservationFor: reservationForByTransaction }
|
|
66
|
+
: undefined, // reservationForがあれば上書き(2026-04-06~)
|
|
67
|
+
};
|
|
68
|
+
});
|
|
71
69
|
}
|
|
72
|
-
return reservations;
|
|
73
70
|
};
|
|
74
71
|
}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
14
|
"@chevre/factory": "6.2.0-alpha.7",
|
|
15
|
-
"@cinerino/sdk": "14.0.0-alpha.
|
|
15
|
+
"@cinerino/sdk": "14.0.0-alpha.5",
|
|
16
16
|
"@motionpicture/coa-service": "9.7.0-alpha.2",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"postversion": "git push origin --tags",
|
|
98
98
|
"prepublishOnly": "npm run clean && npm run build"
|
|
99
99
|
},
|
|
100
|
-
"version": "24.0.0-alpha.
|
|
100
|
+
"version": "24.0.0-alpha.64"
|
|
101
101
|
}
|