@chevre/domain 21.6.0 → 21.7.0-alpha.1
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/searchOffers.ts +20 -20
- package/example/src/chevre/unsetUnnecessaryFields.ts +5 -11
- package/lib/chevre/repo/creativeWork.d.ts +4 -0
- package/lib/chevre/repo/creativeWork.js +6 -0
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +3 -0
- package/lib/chevre/repo/mongoose/schemas/offer.js +2 -0
- package/lib/chevre/repo/offer.js +11 -7
- package/lib/chevre/service/assetTransaction/reserve.js +31 -0
- package/lib/chevre/settings.d.ts +1 -0
- package/lib/chevre/settings.js +2 -1
- package/package.json +2 -2
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
// import * as redis from 'redis';
|
|
3
2
|
import * as mongoose from 'mongoose';
|
|
4
3
|
|
|
5
4
|
import { chevre } from '../../../lib/index';
|
|
6
5
|
|
|
7
6
|
async function main() {
|
|
8
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
7
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
8
|
|
|
10
9
|
const offerRepo = new chevre.repository.Offer(mongoose.connection);
|
|
11
10
|
|
|
12
11
|
const offers = await offerRepo.search({
|
|
13
|
-
|
|
12
|
+
limit: 1,
|
|
14
13
|
// page: 1,
|
|
15
14
|
project: { id: { $eq: String(process.env.PROJECT_ID) } },
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
availability: { $eq: chevre.factory.itemAvailability.InStock }
|
|
16
|
+
// additionalProperty: {
|
|
17
|
+
// $all: [
|
|
18
|
+
// {
|
|
19
|
+
// $elemMatch: {
|
|
20
|
+
// name: { $eq: 'theaterCode' },
|
|
21
|
+
// value: { $in: ['120'] }
|
|
22
|
+
// }
|
|
23
|
+
// },
|
|
24
|
+
// {
|
|
25
|
+
// $elemMatch: {
|
|
26
|
+
// name: { $eq: 'ticketCode' },
|
|
27
|
+
// value: { $in: ['10', '1001'] }
|
|
28
|
+
// }
|
|
29
|
+
// }
|
|
30
|
+
// ]
|
|
31
|
+
// }
|
|
32
32
|
});
|
|
33
33
|
console.log(offers.map((offer) => {
|
|
34
|
-
return `${offer.
|
|
34
|
+
return `${offer.project.id} ${offer.id} ${offer.identifier} ${offer.name.ja}`;
|
|
35
35
|
}));
|
|
36
36
|
console.log(offers.length);
|
|
37
37
|
}
|
|
@@ -6,26 +6,20 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
async function main() {
|
|
7
7
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const creativeWorkRepo = new chevre.repository.CreativeWork(mongoose.connection);
|
|
10
10
|
|
|
11
11
|
let updateResult: any;
|
|
12
|
-
updateResult = await
|
|
13
|
-
filter: { 'offers.acceptedPaymentMethod': { $exists: true } },
|
|
14
|
-
$unset: { 'offers.acceptedPaymentMethod': 1 }
|
|
15
|
-
});
|
|
16
|
-
console.log('events unset', updateResult);
|
|
17
|
-
|
|
18
|
-
updateResult = await eventRepo.unsetUnnecessaryFields({
|
|
12
|
+
updateResult = await creativeWorkRepo.unsetUnnecessaryFields({
|
|
19
13
|
filter: { 'offers.project': { $exists: true } },
|
|
20
14
|
$unset: { 'offers.project': 1 }
|
|
21
15
|
});
|
|
22
|
-
console.log('
|
|
16
|
+
console.log('unset processed.', updateResult);
|
|
23
17
|
|
|
24
|
-
updateResult = await
|
|
18
|
+
updateResult = await creativeWorkRepo.unsetUnnecessaryFields({
|
|
25
19
|
filter: { 'offers.priceCurrency': { $exists: true } },
|
|
26
20
|
$unset: { 'offers.priceCurrency': 1 }
|
|
27
21
|
});
|
|
28
|
-
console.log('
|
|
22
|
+
console.log('unset processed.', updateResult);
|
|
29
23
|
}
|
|
30
24
|
|
|
31
25
|
main()
|
|
@@ -55,4 +55,8 @@ export declare class MongoRepository {
|
|
|
55
55
|
};
|
|
56
56
|
}): Promise<void>;
|
|
57
57
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<any, import("mongoose").QueryOptions<any>>;
|
|
58
|
+
unsetUnnecessaryFields(params: {
|
|
59
|
+
filter: any;
|
|
60
|
+
$unset: any;
|
|
61
|
+
}): Promise<import("mongodb").UpdateResult>;
|
|
58
62
|
}
|
|
@@ -265,5 +265,11 @@ class MongoRepository {
|
|
|
265
265
|
.sort({ identifier: factory.sortType.Ascending })
|
|
266
266
|
.cursor();
|
|
267
267
|
}
|
|
268
|
+
unsetUnnecessaryFields(params) {
|
|
269
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
270
|
+
return this.creativeWorkModel.updateMany(params.filter, { $unset: params.$unset })
|
|
271
|
+
.exec();
|
|
272
|
+
});
|
|
273
|
+
}
|
|
268
274
|
}
|
|
269
275
|
exports.MongoRepository = MongoRepository;
|
|
@@ -67,6 +67,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
67
67
|
color?: any;
|
|
68
68
|
validFrom?: Date | undefined;
|
|
69
69
|
category?: any;
|
|
70
|
+
advanceBookingRequirement?: any;
|
|
70
71
|
availability?: string | undefined;
|
|
71
72
|
hasMerchantReturnPolicy?: any;
|
|
72
73
|
priceSpecification?: any;
|
|
@@ -97,6 +98,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
97
98
|
color?: any;
|
|
98
99
|
validFrom?: Date | undefined;
|
|
99
100
|
category?: any;
|
|
101
|
+
advanceBookingRequirement?: any;
|
|
100
102
|
availability?: string | undefined;
|
|
101
103
|
hasMerchantReturnPolicy?: any;
|
|
102
104
|
priceSpecification?: any;
|
|
@@ -127,6 +129,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
|
|
|
127
129
|
color?: any;
|
|
128
130
|
validFrom?: Date | undefined;
|
|
129
131
|
category?: any;
|
|
132
|
+
advanceBookingRequirement?: any;
|
|
130
133
|
availability?: string | undefined;
|
|
131
134
|
hasMerchantReturnPolicy?: any;
|
|
132
135
|
priceSpecification?: any;
|
|
@@ -18,6 +18,7 @@ const schema = new mongoose_1.Schema({
|
|
|
18
18
|
category: mongoose_1.SchemaTypes.Mixed,
|
|
19
19
|
color: mongoose_1.SchemaTypes.Mixed,
|
|
20
20
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
21
|
+
advanceBookingRequirement: mongoose_1.SchemaTypes.Mixed,
|
|
21
22
|
alternateName: mongoose_1.SchemaTypes.Mixed,
|
|
22
23
|
// acceptedPaymentMethod: SchemaTypes.Mixed, // 削除(2023-02-27~)
|
|
23
24
|
addOn: [mongoose_1.SchemaTypes.Mixed],
|
|
@@ -207,3 +208,4 @@ schema.index({ validThrough: 1, 'priceSpecification.price': 1 }, {
|
|
|
207
208
|
validThrough: { $exists: true }
|
|
208
209
|
}
|
|
209
210
|
});
|
|
211
|
+
schema.index({ availability: 1, 'priceSpecification.price': 1 }, { name: 'searchByAvailability' });
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -36,7 +36,7 @@ class MongoRepository {
|
|
|
36
36
|
}
|
|
37
37
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
38
38
|
static CREATE_OFFER_MONGO_CONDITIONS(params) {
|
|
39
|
-
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;
|
|
39
|
+
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;
|
|
40
40
|
// MongoDB検索条件
|
|
41
41
|
const andConditions = [];
|
|
42
42
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -266,7 +266,11 @@ class MongoRepository {
|
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
const
|
|
269
|
+
const availabilityEq = (_22 = params.availability) === null || _22 === void 0 ? void 0 : _22.$eq;
|
|
270
|
+
if (typeof availabilityEq === 'string') {
|
|
271
|
+
andConditions.push({ availability: { $eq: availabilityEq } });
|
|
272
|
+
}
|
|
273
|
+
const availableAtOrFromIdEq = (_24 = (_23 = params.availableAtOrFrom) === null || _23 === void 0 ? void 0 : _23.id) === null || _24 === void 0 ? void 0 : _24.$eq;
|
|
270
274
|
if (typeof availableAtOrFromIdEq === 'string') {
|
|
271
275
|
andConditions.push({
|
|
272
276
|
'availableAtOrFrom.id': {
|
|
@@ -275,7 +279,7 @@ class MongoRepository {
|
|
|
275
279
|
}
|
|
276
280
|
});
|
|
277
281
|
}
|
|
278
|
-
const availableAtOrFromIdIn = (
|
|
282
|
+
const availableAtOrFromIdIn = (_26 = (_25 = params.availableAtOrFrom) === null || _25 === void 0 ? void 0 : _25.id) === null || _26 === void 0 ? void 0 : _26.$in;
|
|
279
283
|
if (Array.isArray(availableAtOrFromIdIn)) {
|
|
280
284
|
andConditions.push({
|
|
281
285
|
'availableAtOrFrom.id': {
|
|
@@ -284,7 +288,7 @@ class MongoRepository {
|
|
|
284
288
|
}
|
|
285
289
|
});
|
|
286
290
|
}
|
|
287
|
-
const addOnItemOfferedIdEq = (
|
|
291
|
+
const addOnItemOfferedIdEq = (_29 = (_28 = (_27 = params.addOn) === null || _27 === void 0 ? void 0 : _27.itemOffered) === null || _28 === void 0 ? void 0 : _28.id) === null || _29 === void 0 ? void 0 : _29.$eq;
|
|
288
292
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
289
293
|
andConditions.push({
|
|
290
294
|
'addOn.itemOffered.id': {
|
|
@@ -293,7 +297,7 @@ class MongoRepository {
|
|
|
293
297
|
}
|
|
294
298
|
});
|
|
295
299
|
}
|
|
296
|
-
const hasMerchantReturnPolicyIdEq = (
|
|
300
|
+
const hasMerchantReturnPolicyIdEq = (_31 = (_30 = params.hasMerchantReturnPolicy) === null || _30 === void 0 ? void 0 : _30.id) === null || _31 === void 0 ? void 0 : _31.$eq;
|
|
297
301
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
298
302
|
andConditions.push({
|
|
299
303
|
'hasMerchantReturnPolicy.id': {
|
|
@@ -302,7 +306,7 @@ class MongoRepository {
|
|
|
302
306
|
}
|
|
303
307
|
});
|
|
304
308
|
}
|
|
305
|
-
const additionalPropertyAll = (
|
|
309
|
+
const additionalPropertyAll = (_32 = params.additionalProperty) === null || _32 === void 0 ? void 0 : _32.$all;
|
|
306
310
|
if (Array.isArray(additionalPropertyAll)) {
|
|
307
311
|
andConditions.push({
|
|
308
312
|
additionalProperty: {
|
|
@@ -311,7 +315,7 @@ class MongoRepository {
|
|
|
311
315
|
}
|
|
312
316
|
});
|
|
313
317
|
}
|
|
314
|
-
const additionalPropertyElemMatch = (
|
|
318
|
+
const additionalPropertyElemMatch = (_33 = params.additionalProperty) === null || _33 === void 0 ? void 0 : _33.$elemMatch;
|
|
315
319
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
316
320
|
andConditions.push({
|
|
317
321
|
additionalProperty: {
|
|
@@ -339,6 +339,14 @@ function createReservations4transactionObject(params) {
|
|
|
339
339
|
if (ticketType === undefined) {
|
|
340
340
|
throw new factory.errors.NotFound(ticketOffer.typeOf);
|
|
341
341
|
}
|
|
342
|
+
if (settings_1.USE_ADVANCE_BOOKING_REQUIREMENT) {
|
|
343
|
+
// 事前予約要件検証(2023-08-10~)
|
|
344
|
+
validateAdvanceBookingRequirement({
|
|
345
|
+
unitPriceOffer: ticketType,
|
|
346
|
+
now: params.now,
|
|
347
|
+
reservationFor: params.event
|
|
348
|
+
});
|
|
349
|
+
}
|
|
342
350
|
const programMembershipUsed = yield validateProgramMembershipUsed({
|
|
343
351
|
acceptedOffer,
|
|
344
352
|
project: params.transaction.project
|
|
@@ -484,6 +492,29 @@ function getAcceptedSeatNumbersAndSeatSections(params) {
|
|
|
484
492
|
acceptedSeatSections
|
|
485
493
|
};
|
|
486
494
|
}
|
|
495
|
+
/**
|
|
496
|
+
* 事前予約要件を検証する
|
|
497
|
+
*/
|
|
498
|
+
function validateAdvanceBookingRequirement(params) {
|
|
499
|
+
var _a, _b;
|
|
500
|
+
const advanceBookingRequirementMinValue = (_a = params.unitPriceOffer.advanceBookingRequirement) === null || _a === void 0 ? void 0 : _a.minValue;
|
|
501
|
+
const advanceBookingRequirementUnitCode = (_b = params.unitPriceOffer.advanceBookingRequirement) === null || _b === void 0 ? void 0 : _b.unitCode;
|
|
502
|
+
if (typeof advanceBookingRequirementMinValue === 'number' && typeof advanceBookingRequirementUnitCode === 'string') {
|
|
503
|
+
if (advanceBookingRequirementMinValue < 0) {
|
|
504
|
+
throw new factory.errors.NotImplemented('negative value as advanceBookingRequirement.minValue not implemented');
|
|
505
|
+
}
|
|
506
|
+
if (advanceBookingRequirementUnitCode !== factory.unitCode.Sec) {
|
|
507
|
+
throw new factory.errors.NotImplemented(`only ${factory.unitCode.Sec} implemented`);
|
|
508
|
+
}
|
|
509
|
+
const reservationForMustStartAfter = moment(params.now)
|
|
510
|
+
.add(advanceBookingRequirementMinValue, 'seconds');
|
|
511
|
+
const requirementSatisfied = moment(params.reservationFor.startDate)
|
|
512
|
+
.isSameOrAfter(reservationForMustStartAfter);
|
|
513
|
+
if (!requirementSatisfied) {
|
|
514
|
+
throw new factory.errors.Argument('acceptedOffer.id', 'advanceBookingRequirement not satisfied');
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
487
518
|
function validateProgramMembershipUsed(params) {
|
|
488
519
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
489
520
|
var _a, _b, _c;
|
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_ADVANCE_BOOKING_REQUIREMENT: boolean;
|
|
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_ADVANCE_BOOKING_REQUIREMENT = 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')
|
|
@@ -71,6 +71,7 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
|
|
|
71
71
|
// export const USE_NEW_STOCK_HOLDER_REPO_IDS: string[] = (typeof process.env.USE_NEW_STOCK_HOLDER_REPO_IDS === 'string')
|
|
72
72
|
// ? process.env.USE_NEW_STOCK_HOLDER_REPO_IDS.split(' ')
|
|
73
73
|
// : [];
|
|
74
|
+
exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
|
|
74
75
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
75
76
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
76
77
|
: 0;
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
12
|
+
"@chevre/factory": "^4.325.0-alpha.1",
|
|
13
13
|
"@cinerino/sdk": "3.163.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.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.
|
|
120
|
+
"version": "21.7.0-alpha.1"
|
|
121
121
|
}
|