@chevre/domain 21.2.0-alpha.117 → 21.2.0-alpha.119
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/aggregateEventReservation.ts +1 -1
- package/example/src/chevre/lockStockHolder.ts +2 -1
- package/example/src/chevre/migrateStockHolderKeys.ts +1 -1
- package/example/src/chevre/processReserve.ts +1 -1
- package/example/src/chevre/searchEventSeats.ts +2 -1
- package/lib/chevre/repo/event.js +27 -30
- package/lib/chevre/repo/mongoose/schemas/holdReservation.d.ts +75 -0
- package/lib/chevre/repo/mongoose/schemas/holdReservation.js +56 -0
- package/lib/chevre/repo/place.js +21 -18
- package/lib/chevre/repo/stockHolder.d.ts +7 -5
- package/lib/chevre/repo/stockHolder.js +140 -89
- package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
- package/lib/chevre/service/task/cancelReservation.js +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +1 -1
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +4 -1
- package/package.json +3 -3
|
@@ -22,7 +22,7 @@ async function main() {
|
|
|
22
22
|
id: String(process.env.EVENT_ID)
|
|
23
23
|
})({
|
|
24
24
|
event: new chevre.repository.Event(mongoose.connection),
|
|
25
|
-
stockHolder: new chevre.repository.StockHolder(client),
|
|
25
|
+
stockHolder: new chevre.repository.StockHolder(client, mongoose.connection),
|
|
26
26
|
offer: new chevre.repository.Offer(mongoose.connection),
|
|
27
27
|
offerCatalog: new chevre.repository.OfferCatalog(mongoose.connection),
|
|
28
28
|
offerRateLimit: new chevre.repository.rateLimit.Offer(client),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
3
4
|
import * as redis from 'redis';
|
|
4
5
|
|
|
5
6
|
import { chevre } from '../../../lib/index';
|
|
@@ -19,7 +20,7 @@ async function main() {
|
|
|
19
20
|
|
|
20
21
|
const startDate = moment('2023-04-18T00:00:00Z');
|
|
21
22
|
|
|
22
|
-
const stockHolderRepo = new chevre.repository.StockHolder(client);
|
|
23
|
+
const stockHolderRepo = new chevre.repository.StockHolder(client, mongoose.connection);
|
|
23
24
|
await stockHolderRepo.lock({
|
|
24
25
|
eventId: 'sampleEventId',
|
|
25
26
|
startDate: startDate.toDate(),
|
|
@@ -21,7 +21,7 @@ async function main() {
|
|
|
21
21
|
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
22
22
|
|
|
23
23
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
24
|
-
const stockHolderRepo = new chevre.repository.StockHolder(client);
|
|
24
|
+
const stockHolderRepo = new chevre.repository.StockHolder(client, mongoose.connection);
|
|
25
25
|
|
|
26
26
|
const cursor = eventRepo.getCursor(
|
|
27
27
|
{
|
|
@@ -30,7 +30,7 @@ async function main() {
|
|
|
30
30
|
const priceSpecRepo = new chevre.repository.PriceSpecification(mongoose.connection);
|
|
31
31
|
const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
|
|
32
32
|
const eventRepo = new chevre.repository.Event(mongoose.connection);
|
|
33
|
-
const itemAvailabilityRepo = new chevre.repository.StockHolder(client);
|
|
33
|
+
const itemAvailabilityRepo = new chevre.repository.StockHolder(client, mongoose.connection);
|
|
34
34
|
const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
|
|
35
35
|
|
|
36
36
|
const identifier = `CIN${(new Date()).valueOf()}`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
2
3
|
import * as redis from 'redis';
|
|
3
4
|
|
|
4
5
|
import { chevre } from '../../../lib/index';
|
|
@@ -16,7 +17,7 @@ async function main() {
|
|
|
16
17
|
});
|
|
17
18
|
await client.connect();
|
|
18
19
|
|
|
19
|
-
const itemAvailabilityRepo = new chevre.repository.StockHolder(client);
|
|
20
|
+
const itemAvailabilityRepo = new chevre.repository.StockHolder(client, mongoose.connection);
|
|
20
21
|
|
|
21
22
|
const result = await itemAvailabilityRepo.searchHolders({
|
|
22
23
|
eventId: 'alckc9mlx',
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -51,7 +51,7 @@ class MongoRepository {
|
|
|
51
51
|
}
|
|
52
52
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
53
53
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
54
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37;
|
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39;
|
|
55
55
|
const andConditions = [{ typeOf: { $eq: conditions.typeOf } }];
|
|
56
56
|
const projectIdEq = (_b = (_a = conditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
57
57
|
if (typeof projectIdEq === 'string') {
|
|
@@ -116,18 +116,15 @@ class MongoRepository {
|
|
|
116
116
|
}
|
|
117
117
|
const locationBranchCodeEq = (_e = (_d = conditions.location) === null || _d === void 0 ? void 0 : _d.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
118
118
|
if (typeof locationBranchCodeEq === 'string') {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
$eq: locationBranchCodeEq
|
|
125
|
-
}
|
|
126
|
-
});
|
|
119
|
+
andConditions.push({ 'location.branchCode': { $exists: true, $eq: locationBranchCodeEq } });
|
|
120
|
+
}
|
|
121
|
+
const locationBranchCodeIn = (_g = (_f = conditions.location) === null || _f === void 0 ? void 0 : _f.branchCode) === null || _g === void 0 ? void 0 : _g.$in;
|
|
122
|
+
if (Array.isArray(locationBranchCodeIn)) {
|
|
123
|
+
andConditions.push({ 'location.branchCode': { $exists: true, $in: locationBranchCodeIn } });
|
|
127
124
|
}
|
|
128
125
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
129
126
|
/* istanbul ignore else */
|
|
130
|
-
const hasOfferCatalogIdEq = (
|
|
127
|
+
const hasOfferCatalogIdEq = (_j = (_h = conditions.hasOfferCatalog) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
131
128
|
if (typeof hasOfferCatalogIdEq === 'string') {
|
|
132
129
|
andConditions.push({
|
|
133
130
|
'hasOfferCatalog.id': {
|
|
@@ -136,7 +133,7 @@ class MongoRepository {
|
|
|
136
133
|
}
|
|
137
134
|
});
|
|
138
135
|
}
|
|
139
|
-
const additionalPropertyElemMatch = (
|
|
136
|
+
const additionalPropertyElemMatch = (_k = conditions.additionalProperty) === null || _k === void 0 ? void 0 : _k.$elemMatch;
|
|
140
137
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
141
138
|
andConditions.push({
|
|
142
139
|
additionalProperty: {
|
|
@@ -152,7 +149,7 @@ class MongoRepository {
|
|
|
152
149
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
153
150
|
/* istanbul ignore else */
|
|
154
151
|
if (params.offers !== undefined) {
|
|
155
|
-
const itemOfferedIdIn4event = (
|
|
152
|
+
const itemOfferedIdIn4event = (_m = (_l = params.offers.itemOffered) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$in;
|
|
156
153
|
if (Array.isArray(itemOfferedIdIn4event)) {
|
|
157
154
|
andConditions.push({
|
|
158
155
|
'offers.itemOffered.id': {
|
|
@@ -202,8 +199,8 @@ class MongoRepository {
|
|
|
202
199
|
}
|
|
203
200
|
}
|
|
204
201
|
}
|
|
205
|
-
const sellerMakesOfferElemMatch4event = (
|
|
206
|
-
if (typeof ((
|
|
202
|
+
const sellerMakesOfferElemMatch4event = (_q = (_p = (_o = params.offers) === null || _o === void 0 ? void 0 : _o.seller) === null || _p === void 0 ? void 0 : _p.makesOffer) === null || _q === void 0 ? void 0 : _q.$elemMatch;
|
|
203
|
+
if (typeof ((_r = sellerMakesOfferElemMatch4event === null || sellerMakesOfferElemMatch4event === void 0 ? void 0 : sellerMakesOfferElemMatch4event['availableAtOrFrom.id']) === null || _r === void 0 ? void 0 : _r.$eq) === 'string') {
|
|
207
204
|
andConditions.push({
|
|
208
205
|
'offers.seller.makesOffer': {
|
|
209
206
|
$exists: true,
|
|
@@ -211,7 +208,7 @@ class MongoRepository {
|
|
|
211
208
|
}
|
|
212
209
|
});
|
|
213
210
|
}
|
|
214
|
-
const reservationForIdentifierEq = (
|
|
211
|
+
const reservationForIdentifierEq = (_w = (_v = (_u = (_t = (_s = params.offers) === null || _s === void 0 ? void 0 : _s.itemOffered) === null || _t === void 0 ? void 0 : _t.serviceOutput) === null || _u === void 0 ? void 0 : _u.reservationFor) === null || _v === void 0 ? void 0 : _v.identifier) === null || _w === void 0 ? void 0 : _w.$eq;
|
|
215
212
|
if (typeof reservationForIdentifierEq === 'string') {
|
|
216
213
|
andConditions.push({
|
|
217
214
|
'offers.itemOffered.serviceOutput.reservationFor.identifier': {
|
|
@@ -220,7 +217,7 @@ class MongoRepository {
|
|
|
220
217
|
}
|
|
221
218
|
});
|
|
222
219
|
}
|
|
223
|
-
const reservationForArrivalBusStopBranchCodeEq = (
|
|
220
|
+
const reservationForArrivalBusStopBranchCodeEq = (_2 = (_1 = (_0 = (_z = (_y = (_x = params.offers) === null || _x === void 0 ? void 0 : _x.itemOffered) === null || _y === void 0 ? void 0 : _y.serviceOutput) === null || _z === void 0 ? void 0 : _z.reservationFor) === null || _0 === void 0 ? void 0 : _0.arrivalBusStop) === null || _1 === void 0 ? void 0 : _1.branchCode) === null || _2 === void 0 ? void 0 : _2.$eq;
|
|
224
221
|
if (typeof reservationForArrivalBusStopBranchCodeEq === 'string') {
|
|
225
222
|
andConditions.push({
|
|
226
223
|
'offers.itemOffered.serviceOutput.reservationFor.arrivalBusStop.branchCode': {
|
|
@@ -229,7 +226,7 @@ class MongoRepository {
|
|
|
229
226
|
}
|
|
230
227
|
});
|
|
231
228
|
}
|
|
232
|
-
const reservationForDepartureBusStopBranchCodeEq = (
|
|
229
|
+
const reservationForDepartureBusStopBranchCodeEq = (_8 = (_7 = (_6 = (_5 = (_4 = (_3 = params.offers) === null || _3 === void 0 ? void 0 : _3.itemOffered) === null || _4 === void 0 ? void 0 : _4.serviceOutput) === null || _5 === void 0 ? void 0 : _5.reservationFor) === null || _6 === void 0 ? void 0 : _6.departureBusStop) === null || _7 === void 0 ? void 0 : _7.branchCode) === null || _8 === void 0 ? void 0 : _8.$eq;
|
|
233
230
|
if (typeof reservationForDepartureBusStopBranchCodeEq === 'string') {
|
|
234
231
|
andConditions.push({
|
|
235
232
|
'offers.itemOffered.serviceOutput.reservationFor.departureBusStop.branchCode': {
|
|
@@ -263,7 +260,7 @@ class MongoRepository {
|
|
|
263
260
|
}
|
|
264
261
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
265
262
|
/* istanbul ignore else */
|
|
266
|
-
const superEventLocationIdEq = (
|
|
263
|
+
const superEventLocationIdEq = (_11 = (_10 = (_9 = params.superEvent) === null || _9 === void 0 ? void 0 : _9.location) === null || _10 === void 0 ? void 0 : _10.id) === null || _11 === void 0 ? void 0 : _11.$eq;
|
|
267
264
|
if (typeof superEventLocationIdEq === 'string') {
|
|
268
265
|
andConditions.push({
|
|
269
266
|
'superEvent.location.id': {
|
|
@@ -306,7 +303,7 @@ class MongoRepository {
|
|
|
306
303
|
});
|
|
307
304
|
}
|
|
308
305
|
}
|
|
309
|
-
const itemOfferedIdIn = (
|
|
306
|
+
const itemOfferedIdIn = (_14 = (_13 = (_12 = params.offers) === null || _12 === void 0 ? void 0 : _12.itemOffered) === null || _13 === void 0 ? void 0 : _13.id) === null || _14 === void 0 ? void 0 : _14.$in;
|
|
310
307
|
if (Array.isArray(itemOfferedIdIn)) {
|
|
311
308
|
andConditions.push({
|
|
312
309
|
'offers.itemOffered.id': {
|
|
@@ -315,7 +312,7 @@ class MongoRepository {
|
|
|
315
312
|
}
|
|
316
313
|
});
|
|
317
314
|
}
|
|
318
|
-
const itemOfferedTicketedSeatTypeOfIn = (
|
|
315
|
+
const itemOfferedTicketedSeatTypeOfIn = (_19 = (_18 = (_17 = (_16 = (_15 = params.offers) === null || _15 === void 0 ? void 0 : _15.itemOffered) === null || _16 === void 0 ? void 0 : _16.serviceOutput) === null || _17 === void 0 ? void 0 : _17.reservedTicket) === null || _18 === void 0 ? void 0 : _18.ticketedSeat) === null || _19 === void 0 ? void 0 : _19.typeOfs;
|
|
319
316
|
if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
|
|
320
317
|
andConditions.push({
|
|
321
318
|
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
@@ -324,7 +321,7 @@ class MongoRepository {
|
|
|
324
321
|
}
|
|
325
322
|
});
|
|
326
323
|
}
|
|
327
|
-
const itemOfferedServiceTypeIdIn = (
|
|
324
|
+
const itemOfferedServiceTypeIdIn = (_22 = (_21 = (_20 = params.offers) === null || _20 === void 0 ? void 0 : _20.itemOffered) === null || _21 === void 0 ? void 0 : _21.serviceType) === null || _22 === void 0 ? void 0 : _22.ids;
|
|
328
325
|
if (Array.isArray(itemOfferedServiceTypeIdIn)) {
|
|
329
326
|
andConditions.push({
|
|
330
327
|
'offers.itemOffered.serviceType.id': {
|
|
@@ -333,8 +330,8 @@ class MongoRepository {
|
|
|
333
330
|
}
|
|
334
331
|
});
|
|
335
332
|
}
|
|
336
|
-
const sellerMakesOfferElemMatch = (
|
|
337
|
-
if (typeof ((
|
|
333
|
+
const sellerMakesOfferElemMatch = (_25 = (_24 = (_23 = params.offers) === null || _23 === void 0 ? void 0 : _23.seller) === null || _24 === void 0 ? void 0 : _24.makesOffer) === null || _25 === void 0 ? void 0 : _25.$elemMatch;
|
|
334
|
+
if (typeof ((_26 = sellerMakesOfferElemMatch === null || sellerMakesOfferElemMatch === void 0 ? void 0 : sellerMakesOfferElemMatch['availableAtOrFrom.id']) === null || _26 === void 0 ? void 0 : _26.$eq) === 'string') {
|
|
338
335
|
andConditions.push({
|
|
339
336
|
'offers.seller.makesOffer': {
|
|
340
337
|
$exists: true,
|
|
@@ -371,7 +368,7 @@ class MongoRepository {
|
|
|
371
368
|
]
|
|
372
369
|
});
|
|
373
370
|
}
|
|
374
|
-
const locationIdEq = (
|
|
371
|
+
const locationIdEq = (_28 = (_27 = params.location) === null || _27 === void 0 ? void 0 : _27.id) === null || _28 === void 0 ? void 0 : _28.$eq;
|
|
375
372
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
376
373
|
/* istanbul ignore else */
|
|
377
374
|
if (typeof locationIdEq === 'string') {
|
|
@@ -393,7 +390,7 @@ class MongoRepository {
|
|
|
393
390
|
});
|
|
394
391
|
}
|
|
395
392
|
}
|
|
396
|
-
const workPerformedIdentifierIn = (
|
|
393
|
+
const workPerformedIdentifierIn = (_29 = params.workPerformed) === null || _29 === void 0 ? void 0 : _29.identifiers;
|
|
397
394
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
398
395
|
/* istanbul ignore else */
|
|
399
396
|
if (Array.isArray(workPerformedIdentifierIn)) {
|
|
@@ -401,13 +398,13 @@ class MongoRepository {
|
|
|
401
398
|
'workPerformed.identifier': { $exists: true, $in: workPerformedIdentifierIn }
|
|
402
399
|
});
|
|
403
400
|
}
|
|
404
|
-
const workPerformedVersionEq = (
|
|
401
|
+
const workPerformedVersionEq = (_31 = (_30 = params.workPerformed) === null || _30 === void 0 ? void 0 : _30.version) === null || _31 === void 0 ? void 0 : _31.$eq;
|
|
405
402
|
if (typeof workPerformedVersionEq === 'string') {
|
|
406
403
|
andConditions.push({
|
|
407
404
|
'workPerformed.version': { $exists: true, $eq: workPerformedVersionEq }
|
|
408
405
|
});
|
|
409
406
|
}
|
|
410
|
-
const videoFormatTypeOfEq = (
|
|
407
|
+
const videoFormatTypeOfEq = (_33 = (_32 = params.videoFormat) === null || _32 === void 0 ? void 0 : _32.typeOf) === null || _33 === void 0 ? void 0 : _33.$eq;
|
|
411
408
|
if (typeof videoFormatTypeOfEq === 'string') {
|
|
412
409
|
andConditions.push({
|
|
413
410
|
'videoFormat.typeOf': {
|
|
@@ -416,7 +413,7 @@ class MongoRepository {
|
|
|
416
413
|
}
|
|
417
414
|
});
|
|
418
415
|
}
|
|
419
|
-
const videoFormatTypeOfIn = (
|
|
416
|
+
const videoFormatTypeOfIn = (_35 = (_34 = params.videoFormat) === null || _34 === void 0 ? void 0 : _34.typeOf) === null || _35 === void 0 ? void 0 : _35.$in;
|
|
420
417
|
if (Array.isArray(videoFormatTypeOfIn)) {
|
|
421
418
|
andConditions.push({
|
|
422
419
|
'videoFormat.typeOf': {
|
|
@@ -425,7 +422,7 @@ class MongoRepository {
|
|
|
425
422
|
}
|
|
426
423
|
});
|
|
427
424
|
}
|
|
428
|
-
const soundFormatTypeOfEq = (
|
|
425
|
+
const soundFormatTypeOfEq = (_37 = (_36 = params.soundFormat) === null || _36 === void 0 ? void 0 : _36.typeOf) === null || _37 === void 0 ? void 0 : _37.$eq;
|
|
429
426
|
if (typeof soundFormatTypeOfEq === 'string') {
|
|
430
427
|
andConditions.push({
|
|
431
428
|
'soundFormat.typeOf': {
|
|
@@ -434,7 +431,7 @@ class MongoRepository {
|
|
|
434
431
|
}
|
|
435
432
|
});
|
|
436
433
|
}
|
|
437
|
-
const soundFormatTypeOfIn = (
|
|
434
|
+
const soundFormatTypeOfIn = (_39 = (_38 = params.soundFormat) === null || _38 === void 0 ? void 0 : _38.typeOf) === null || _39 === void 0 ? void 0 : _39.$in;
|
|
438
435
|
if (Array.isArray(soundFormatTypeOfIn)) {
|
|
439
436
|
andConditions.push({
|
|
440
437
|
'soundFormat.typeOf': {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
import { Schema } from 'mongoose';
|
|
26
|
+
declare const modelName = "HoldReservation";
|
|
27
|
+
/**
|
|
28
|
+
* 保留予約スキーマ
|
|
29
|
+
*/
|
|
30
|
+
declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
31
|
+
collection: string;
|
|
32
|
+
id: true;
|
|
33
|
+
read: string;
|
|
34
|
+
writeConcern: import("mongodb").WriteConcern;
|
|
35
|
+
strict: true;
|
|
36
|
+
strictQuery: false;
|
|
37
|
+
useNestedStrict: boolean;
|
|
38
|
+
timestamps: {
|
|
39
|
+
createdAt: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
};
|
|
42
|
+
toJSON: {
|
|
43
|
+
getters: false;
|
|
44
|
+
virtuals: false;
|
|
45
|
+
minimize: false;
|
|
46
|
+
versionKey: false;
|
|
47
|
+
};
|
|
48
|
+
toObject: {
|
|
49
|
+
getters: false;
|
|
50
|
+
virtuals: true;
|
|
51
|
+
minimize: false;
|
|
52
|
+
versionKey: false;
|
|
53
|
+
};
|
|
54
|
+
}, {
|
|
55
|
+
typeOf: string;
|
|
56
|
+
reservations: any[];
|
|
57
|
+
reservationCount: number;
|
|
58
|
+
project?: any;
|
|
59
|
+
reservationFor?: any;
|
|
60
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
61
|
+
typeOf: string;
|
|
62
|
+
reservations: any[];
|
|
63
|
+
reservationCount: number;
|
|
64
|
+
project?: any;
|
|
65
|
+
reservationFor?: any;
|
|
66
|
+
}>> & Omit<import("mongoose").FlatRecord<{
|
|
67
|
+
typeOf: string;
|
|
68
|
+
reservations: any[];
|
|
69
|
+
reservationCount: number;
|
|
70
|
+
project?: any;
|
|
71
|
+
reservationFor?: any;
|
|
72
|
+
}> & {
|
|
73
|
+
_id: import("mongoose").Types.ObjectId;
|
|
74
|
+
}, never>>;
|
|
75
|
+
export { modelName, schema };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = exports.modelName = void 0;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const writeConcern_1 = require("../writeConcern");
|
|
6
|
+
const modelName = 'HoldReservation';
|
|
7
|
+
exports.modelName = modelName;
|
|
8
|
+
/**
|
|
9
|
+
* 保留予約スキーマ
|
|
10
|
+
*/
|
|
11
|
+
const schema = new mongoose_1.Schema({
|
|
12
|
+
project: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
typeOf: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
17
|
+
reservationFor: mongoose_1.SchemaTypes.Mixed,
|
|
18
|
+
reservationCount: {
|
|
19
|
+
type: Number,
|
|
20
|
+
default: 0,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
reservations: [mongoose_1.SchemaTypes.Mixed]
|
|
24
|
+
}, {
|
|
25
|
+
collection: 'holdReservations',
|
|
26
|
+
id: true,
|
|
27
|
+
read: 'primary',
|
|
28
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
29
|
+
strict: true,
|
|
30
|
+
strictQuery: false,
|
|
31
|
+
useNestedStrict: true,
|
|
32
|
+
timestamps: {
|
|
33
|
+
createdAt: 'createdAt',
|
|
34
|
+
updatedAt: 'updatedAt'
|
|
35
|
+
},
|
|
36
|
+
toJSON: {
|
|
37
|
+
getters: false,
|
|
38
|
+
virtuals: false,
|
|
39
|
+
minimize: false,
|
|
40
|
+
versionKey: false
|
|
41
|
+
},
|
|
42
|
+
toObject: {
|
|
43
|
+
getters: false,
|
|
44
|
+
virtuals: true,
|
|
45
|
+
minimize: false,
|
|
46
|
+
versionKey: false
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
exports.schema = schema;
|
|
50
|
+
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
51
|
+
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
52
|
+
schema.index({ 'reservationFor.startDate': -1 }, { name: 'searchByReservationForStartDate' });
|
|
53
|
+
// イベントIDでunique
|
|
54
|
+
schema.index({ 'reservationFor.id': 1 }, { name: 'uniqueReservationForId', unique: true });
|
|
55
|
+
schema.index({ 'reservationFor.id': 1, 'reservationFor.startDate': -1 }, { name: 'searchByReservationForId' });
|
|
56
|
+
schema.index({ 'project.id': 1, 'reservationFor.startDate': -1 }, { name: 'searchByProjectId' });
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -696,7 +696,7 @@ class MongoRepository {
|
|
|
696
696
|
}
|
|
697
697
|
// tslint:disable-next-line:max-func-body-length
|
|
698
698
|
searchScreeningRooms(searchConditions) {
|
|
699
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
699
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
700
700
|
return __awaiter(this, void 0, void 0, function* () {
|
|
701
701
|
const matchStages = [{ $match: { typeOf: { $eq: factory.placeType.MovieTheater } } }];
|
|
702
702
|
const projectIdEq = (_b = (_a = searchConditions.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -729,20 +729,23 @@ class MongoRepository {
|
|
|
729
729
|
}
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
|
-
|
|
733
|
-
if (
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
$
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
732
|
+
const branchCodeEq = (_e = searchConditions.branchCode) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
733
|
+
if (typeof branchCodeEq === 'string') {
|
|
734
|
+
matchStages.push({
|
|
735
|
+
$match: {
|
|
736
|
+
'containsPlace.branchCode': { $exists: true, $eq: branchCodeEq }
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
const branchCodeIn = (_f = searchConditions.branchCode) === null || _f === void 0 ? void 0 : _f.$in;
|
|
741
|
+
if (Array.isArray(branchCodeIn)) {
|
|
742
|
+
matchStages.push({
|
|
743
|
+
$match: {
|
|
744
|
+
'containsPlace.branchCode': { $exists: true, $in: branchCodeIn }
|
|
745
|
+
}
|
|
746
|
+
});
|
|
744
747
|
}
|
|
745
|
-
const branchCodeRegex = (
|
|
748
|
+
const branchCodeRegex = (_g = searchConditions.branchCode) === null || _g === void 0 ? void 0 : _g.$regex;
|
|
746
749
|
if (typeof branchCodeRegex === 'string') {
|
|
747
750
|
matchStages.push({
|
|
748
751
|
$match: {
|
|
@@ -753,7 +756,7 @@ class MongoRepository {
|
|
|
753
756
|
}
|
|
754
757
|
});
|
|
755
758
|
}
|
|
756
|
-
const nameCodeRegex = (
|
|
759
|
+
const nameCodeRegex = (_h = searchConditions.name) === null || _h === void 0 ? void 0 : _h.$regex;
|
|
757
760
|
if (typeof nameCodeRegex === 'string') {
|
|
758
761
|
matchStages.push({
|
|
759
762
|
$match: {
|
|
@@ -785,7 +788,7 @@ class MongoRepository {
|
|
|
785
788
|
}
|
|
786
789
|
});
|
|
787
790
|
}
|
|
788
|
-
const additionalPropertyElemMatch = (
|
|
791
|
+
const additionalPropertyElemMatch = (_j = searchConditions.additionalProperty) === null || _j === void 0 ? void 0 : _j.$elemMatch;
|
|
789
792
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
790
793
|
matchStages.push({
|
|
791
794
|
$match: {
|
|
@@ -805,7 +808,7 @@ class MongoRepository {
|
|
|
805
808
|
typeOf: '$typeOf',
|
|
806
809
|
branchCode: '$branchCode',
|
|
807
810
|
name: '$name'
|
|
808
|
-
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty' }, (((
|
|
811
|
+
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
|
|
809
812
|
? {
|
|
810
813
|
sectionCount: {
|
|
811
814
|
$cond: {
|
|
@@ -815,7 +818,7 @@ class MongoRepository {
|
|
|
815
818
|
}
|
|
816
819
|
}
|
|
817
820
|
}
|
|
818
|
-
: undefined), (((
|
|
821
|
+
: undefined), (((_l = searchConditions.$projection) === null || _l === void 0 ? void 0 : _l.seatCount) === 1)
|
|
819
822
|
? {
|
|
820
823
|
seatCount: {
|
|
821
824
|
$sum: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Connection } from 'mongoose';
|
|
1
2
|
import { RedisClientType } from 'redis';
|
|
2
3
|
export interface IOffer {
|
|
3
4
|
itemOffered?: {
|
|
@@ -31,9 +32,14 @@ export declare class StockHolderRepository {
|
|
|
31
32
|
static KEY_PREFIX_NEW: string;
|
|
32
33
|
static KEY_PREFIX: string;
|
|
33
34
|
private readonly redisClient;
|
|
34
|
-
|
|
35
|
+
private readonly holdReservationModel;
|
|
36
|
+
constructor(redisClient: RedisClientType, connection: Connection);
|
|
35
37
|
private static offer2field;
|
|
36
38
|
private static createKey;
|
|
39
|
+
/**
|
|
40
|
+
* 新リポジトリを使用するかどうか
|
|
41
|
+
*/
|
|
42
|
+
private static useMongoose;
|
|
37
43
|
/**
|
|
38
44
|
* 座席をロックする(maxキャパシティチェック有)
|
|
39
45
|
*/
|
|
@@ -49,10 +55,6 @@ export declare class StockHolderRepository {
|
|
|
49
55
|
/**
|
|
50
56
|
* 空席でない座席を検索する
|
|
51
57
|
*/
|
|
52
|
-
findUnavailableOffersByEventId(params: {
|
|
53
|
-
eventId: string;
|
|
54
|
-
startDate: Date;
|
|
55
|
-
}): Promise<IOffer[]>;
|
|
56
58
|
/**
|
|
57
59
|
* 空席でない座席をカウントする
|
|
58
60
|
*/
|
|
@@ -13,14 +13,16 @@ exports.StockHolderRepository = void 0;
|
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment");
|
|
15
15
|
const factory = require("../factory");
|
|
16
|
+
const holdReservation_1 = require("./mongoose/schemas/holdReservation");
|
|
16
17
|
const settings_1 = require("../settings");
|
|
17
18
|
const debug = createDebug('chevre-domain:repo');
|
|
18
19
|
/**
|
|
19
20
|
* イベントストックホルダーリポジトリ
|
|
20
21
|
*/
|
|
21
22
|
class StockHolderRepository {
|
|
22
|
-
constructor(redisClient) {
|
|
23
|
+
constructor(redisClient, connection) {
|
|
23
24
|
this.redisClient = redisClient;
|
|
25
|
+
this.holdReservationModel = connection.model(holdReservation_1.modelName, holdReservation_1.schema);
|
|
24
26
|
}
|
|
25
27
|
// public static GET_KEY(params: {
|
|
26
28
|
// eventId: string;
|
|
@@ -50,21 +52,35 @@ class StockHolderRepository {
|
|
|
50
52
|
return `${StockHolderRepository.KEY_PREFIX}:${params.eventId}`;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* 新リポジトリを使用するかどうか
|
|
57
|
+
*/
|
|
58
|
+
static useMongoose(params) {
|
|
59
|
+
if (settings_1.USE_NEW_STOCK_HOLDER_REPO_IDS.includes(params.eventId)) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
53
64
|
/**
|
|
54
65
|
* 座席をロックする(maxキャパシティチェック有)
|
|
55
66
|
*/
|
|
56
67
|
lockIfNotLimitExceeded(lockKey, maximum) {
|
|
57
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
if (StockHolderRepository.useMongoose({ eventId: lockKey.eventId, startDate: lockKey.startDate })) {
|
|
70
|
+
throw new factory.errors.NotImplemented(`new stock holder repository not implemented for the event '${lockKey.eventId}'`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
74
|
+
yield this.redisClient.watch(key);
|
|
75
|
+
const hashCount = yield this.redisClient.hLen(key);
|
|
76
|
+
// Process result
|
|
77
|
+
// Heavy and time consuming operation here
|
|
78
|
+
debug('checking hash count...hashCount:', hashCount);
|
|
79
|
+
if (hashCount + lockKey.offers.length > maximum) {
|
|
80
|
+
throw new factory.errors.Argument('Event', 'maximumAttendeeCapacity exceeded');
|
|
81
|
+
}
|
|
82
|
+
yield this.lock(lockKey);
|
|
66
83
|
}
|
|
67
|
-
yield this.lock(lockKey);
|
|
68
84
|
});
|
|
69
85
|
}
|
|
70
86
|
/**
|
|
@@ -72,47 +88,52 @@ class StockHolderRepository {
|
|
|
72
88
|
*/
|
|
73
89
|
lock(lockKey) {
|
|
74
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
if (
|
|
76
|
-
throw new factory.errors.
|
|
77
|
-
}
|
|
78
|
-
const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
79
|
-
yield this.checkIfConflicted({ key, eventId: lockKey.eventId });
|
|
80
|
-
const value = lockKey.holder;
|
|
81
|
-
const multi = this.redisClient.multi();
|
|
82
|
-
const fields = lockKey.offers.map((offer) => StockHolderRepository.offer2field(offer));
|
|
83
|
-
fields.forEach((field) => {
|
|
84
|
-
multi.hSetNX(key, field, value);
|
|
85
|
-
});
|
|
86
|
-
const results = yield multi.expireAt(key, moment(lockKey.expires)
|
|
87
|
-
.unix())
|
|
88
|
-
.exec();
|
|
89
|
-
const lockedFields = [];
|
|
90
|
-
if (Array.isArray(results)) {
|
|
91
|
-
results.slice(0, fields.length)
|
|
92
|
-
.forEach((r, index) => {
|
|
93
|
-
if (r === 1 || r === true) {
|
|
94
|
-
lockedFields.push(fields[index]);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
91
|
+
if (StockHolderRepository.useMongoose({ eventId: lockKey.eventId, startDate: lockKey.startDate })) {
|
|
92
|
+
throw new factory.errors.NotImplemented(`new stock holder repository not implemented for the event '${lockKey.eventId}'`);
|
|
97
93
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const expiredAll = results.slice(fields.length)
|
|
102
|
-
.every((r) => (r === 1 || r === true));
|
|
103
|
-
debug('expiredAll?', expiredAll);
|
|
104
|
-
if (!lockedAll || !expiredAll) {
|
|
105
|
-
if (lockedFields.length > 0) {
|
|
106
|
-
// 全て仮押さえできなければ仮押さえできたものは解除
|
|
107
|
-
yield this.redisClient.multi()
|
|
108
|
-
.hDel(key, lockedFields)
|
|
109
|
-
.exec();
|
|
94
|
+
else {
|
|
95
|
+
if (!(lockKey.expires instanceof Date)) {
|
|
96
|
+
throw new factory.errors.Argument('expires', 'must be Date');
|
|
110
97
|
}
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
99
|
+
yield this.checkIfConflicted({ key, eventId: lockKey.eventId });
|
|
100
|
+
const value = lockKey.holder;
|
|
101
|
+
const multi = this.redisClient.multi();
|
|
102
|
+
const fields = lockKey.offers.map((offer) => StockHolderRepository.offer2field(offer));
|
|
103
|
+
fields.forEach((field) => {
|
|
104
|
+
multi.hSetNX(key, field, value);
|
|
105
|
+
});
|
|
106
|
+
const results = yield multi.expireAt(key, moment(lockKey.expires)
|
|
107
|
+
.unix())
|
|
108
|
+
.exec();
|
|
109
|
+
const lockedFields = [];
|
|
110
|
+
if (Array.isArray(results)) {
|
|
111
|
+
results.slice(0, fields.length)
|
|
112
|
+
.forEach((r, index) => {
|
|
113
|
+
if (r === 1 || r === true) {
|
|
114
|
+
lockedFields.push(fields[index]);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
113
117
|
}
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
const lockedAll = lockedFields.length === fields.length;
|
|
119
|
+
debug('lockedAll?', lockedAll);
|
|
120
|
+
// expireAtReplyの検証も追加する(2023-04-19~)
|
|
121
|
+
const expiredAll = results.slice(fields.length)
|
|
122
|
+
.every((r) => (r === 1 || r === true));
|
|
123
|
+
debug('expiredAll?', expiredAll);
|
|
124
|
+
if (!lockedAll || !expiredAll) {
|
|
125
|
+
if (lockedFields.length > 0) {
|
|
126
|
+
// 全て仮押さえできなければ仮押さえできたものは解除
|
|
127
|
+
yield this.redisClient.multi()
|
|
128
|
+
.hDel(key, lockedFields)
|
|
129
|
+
.exec();
|
|
130
|
+
}
|
|
131
|
+
if (!lockedAll) {
|
|
132
|
+
throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw new factory.errors.ServiceUnavailable('timeout cannot be set unexpectedly');
|
|
136
|
+
}
|
|
116
137
|
}
|
|
117
138
|
}
|
|
118
139
|
});
|
|
@@ -122,45 +143,65 @@ class StockHolderRepository {
|
|
|
122
143
|
*/
|
|
123
144
|
unlock(params) {
|
|
124
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
.
|
|
130
|
-
.
|
|
146
|
+
if (StockHolderRepository.useMongoose({ eventId: params.eventId, startDate: params.startDate })) {
|
|
147
|
+
throw new factory.errors.NotImplemented(`new stock holder repository not implemented for the event '${params.eventId}'`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
151
|
+
yield this.checkIfConflicted({ key, eventId: params.eventId });
|
|
152
|
+
const field = StockHolderRepository.offer2field(params.offer);
|
|
153
|
+
yield this.redisClient.multi()
|
|
154
|
+
.hDel(key, field)
|
|
155
|
+
.exec();
|
|
156
|
+
}
|
|
131
157
|
});
|
|
132
158
|
}
|
|
133
159
|
/**
|
|
134
160
|
* 空席でない座席を検索する
|
|
135
161
|
*/
|
|
136
|
-
findUnavailableOffersByEventId(params) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
});
|
|
151
|
-
}
|
|
162
|
+
// public async findUnavailableOffersByEventId(params: { eventId: string; startDate: Date }): Promise<IOffer[]> {
|
|
163
|
+
// const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
164
|
+
// const reply = await this.redisClient.hGetAll(key);
|
|
165
|
+
// let offers: IOffer[] = [];
|
|
166
|
+
// if (reply !== null) {
|
|
167
|
+
// offers = Object.keys(reply)
|
|
168
|
+
// .map((field) => {
|
|
169
|
+
// const seatSection = field.split(':')[0];
|
|
170
|
+
// const seatNumber = field.split(':')[1];
|
|
171
|
+
// return { seatSection, seatNumber };
|
|
172
|
+
// });
|
|
173
|
+
// }
|
|
174
|
+
// return offers;
|
|
175
|
+
// }
|
|
152
176
|
/**
|
|
153
177
|
* 空席でない座席をカウントする
|
|
154
178
|
*/
|
|
155
179
|
countUnavailableOffers(params) {
|
|
156
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
181
|
+
if (StockHolderRepository.useMongoose({ eventId: params.event.id, startDate: params.event.startDate })) {
|
|
182
|
+
return this.holdReservationModel.findOne({
|
|
183
|
+
'reservationFor.id': { $eq: params.event.id }
|
|
184
|
+
})
|
|
185
|
+
.select({ reservationCount: 1 })
|
|
186
|
+
.exec()
|
|
187
|
+
.then((doc) => {
|
|
188
|
+
if (doc === null) {
|
|
189
|
+
return 0;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return doc.reservationCount;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const key = StockHolderRepository.createKey({ eventId: params.event.id, startDate: params.event.startDate });
|
|
198
|
+
const reply = yield this.redisClient.hLen(key);
|
|
199
|
+
let fieldCount = 0;
|
|
200
|
+
if (typeof reply === 'number') {
|
|
201
|
+
fieldCount = Number(reply);
|
|
202
|
+
}
|
|
203
|
+
return fieldCount;
|
|
162
204
|
}
|
|
163
|
-
return fieldCount;
|
|
164
205
|
});
|
|
165
206
|
}
|
|
166
207
|
/**
|
|
@@ -168,9 +209,14 @@ class StockHolderRepository {
|
|
|
168
209
|
*/
|
|
169
210
|
getHolder(params) {
|
|
170
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
212
|
+
if (StockHolderRepository.useMongoose({ eventId: params.eventId, startDate: params.startDate })) {
|
|
213
|
+
throw new factory.errors.NotImplemented(`new stock holder repository not implemented for the event '${params.eventId}'`);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
217
|
+
const field = StockHolderRepository.offer2field(params.offer);
|
|
218
|
+
return this.redisClient.hGet(key, field);
|
|
219
|
+
}
|
|
174
220
|
});
|
|
175
221
|
}
|
|
176
222
|
/**
|
|
@@ -207,17 +253,22 @@ class StockHolderRepository {
|
|
|
207
253
|
// }
|
|
208
254
|
searchHolders(params) {
|
|
209
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
256
|
+
if (StockHolderRepository.useMongoose({ eventId: params.eventId, startDate: params.startDate })) {
|
|
257
|
+
throw new factory.errors.NotImplemented(`new stock holder repository not implemented for the event '${params.eventId}'`);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const key = StockHolderRepository.createKey({ eventId: params.eventId, startDate: params.startDate });
|
|
261
|
+
const fields = params.offers.map((o) => {
|
|
262
|
+
return StockHolderRepository.offer2field(o);
|
|
263
|
+
});
|
|
264
|
+
// Array reply: list of values associated with the given fields, in the same order as they are requested.
|
|
265
|
+
const result = yield this.redisClient.hmGet(key, fields);
|
|
266
|
+
if (!Array.isArray(result)) {
|
|
267
|
+
throw new factory.errors.ServiceUnavailable(`searchAvailability got non-array: ${typeof result}`);
|
|
268
|
+
}
|
|
269
|
+
// そのまま返却(2023-04-17~)
|
|
270
|
+
return result;
|
|
218
271
|
}
|
|
219
|
-
// そのまま返却(2023-04-17~)
|
|
220
|
-
return result;
|
|
221
272
|
});
|
|
222
273
|
}
|
|
223
274
|
// public async migrateKey(params: {
|
|
@@ -32,7 +32,7 @@ function call(data) {
|
|
|
32
32
|
}
|
|
33
33
|
yield AggregationService.event.aggregateScreeningEvent(data)({
|
|
34
34
|
event: new event_1.MongoRepository(settings.connection),
|
|
35
|
-
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient),
|
|
35
|
+
stockHolder: new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection),
|
|
36
36
|
offer: new offer_1.MongoRepository(settings.connection),
|
|
37
37
|
offerCatalog: new offerCatalog_1.MongoRepository(settings.connection),
|
|
38
38
|
offerRateLimit: new offer_2.RedisRepository(settings.redisClient),
|
|
@@ -30,7 +30,7 @@ function call(data) {
|
|
|
30
30
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
31
31
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
32
32
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
33
|
-
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
33
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection);
|
|
34
34
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
35
35
|
// アクション数は予約番号単位で1しかありえないはず(2023-06-05~)
|
|
36
36
|
if (data.actionAttributes.length !== 1) {
|
|
@@ -30,7 +30,7 @@ function call(data) {
|
|
|
30
30
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
31
31
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
|
32
32
|
const transactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
33
|
-
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
33
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection);
|
|
34
34
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
35
35
|
yield ReserveService.cancelReservation(data.actionAttributes)({
|
|
36
36
|
action: actionRepo,
|
|
@@ -29,7 +29,7 @@ function call(data) {
|
|
|
29
29
|
}
|
|
30
30
|
const actionRepo = new action_1.MongoRepository(settings.connection);
|
|
31
31
|
const assetTransactionRepo = new assetTransaction_1.MongoRepository(settings.connection);
|
|
32
|
-
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient);
|
|
32
|
+
const stockHolderRepo = new stockHolder_1.StockHolderRepository(settings.redisClient, settings.connection);
|
|
33
33
|
const offerRateLimitRepo = new offer_1.RedisRepository(settings.redisClient);
|
|
34
34
|
const reservationRepo = new reservation_1.MongoRepository(settings.connection);
|
|
35
35
|
const taskRepo = new task_1.MongoRepository(settings.connection);
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
|
39
39
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
40
40
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
41
41
|
export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
42
|
+
export declare const USE_NEW_STOCK_HOLDER_REPO_IDS: string[];
|
|
42
43
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
43
44
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
44
45
|
/**
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_NEW_STOCK_HOLDER_REPO_IDS = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -65,6 +65,9 @@ exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TR
|
|
|
65
65
|
exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM === 'string')
|
|
66
66
|
? moment(process.env.USE_NEW_EVENT_AVAILABILITY_KEY_FROM)
|
|
67
67
|
: moment('2023-08-31T15:00:00Z');
|
|
68
|
+
exports.USE_NEW_STOCK_HOLDER_REPO_IDS = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
|
|
69
|
+
? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
|
|
70
|
+
: [];
|
|
68
71
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
69
72
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
70
73
|
: 0;
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.313.0-alpha.
|
|
13
|
-
"@cinerino/sdk": "3.157.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.313.0-alpha.38",
|
|
13
|
+
"@cinerino/sdk": "3.157.0-alpha.13",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.2.0-alpha.
|
|
120
|
+
"version": "21.2.0-alpha.119"
|
|
121
121
|
}
|