@chevre/domain 21.6.0 → 21.7.0-alpha.0
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/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 +1 -0
- 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
|
@@ -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],
|
|
@@ -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.0",
|
|
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.0"
|
|
121
121
|
}
|