@chevre/domain 20.4.0-alpha.9 → 20.5.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/aggregateEventReservation.ts +2 -1
- package/example/src/chevre/createManyEventsIfNotExist.ts +0 -4
- package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
- package/example/src/chevre/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
- package/example/src/chevre/reIndex.ts +25 -0
- package/example/src/chevre/searchEventTicketOffers.ts +7 -4
- package/example/src/chevre/searchOfferCatalogs.ts +14 -16
- package/example/src/chevre/searchOffersByCatalog.ts +2 -1
- package/example/src/chevre/searchProductOffers.ts +38 -0
- package/example/src/chevre/searchTasks.ts +22 -0
- package/example/src/chevre/sendEmailMessage.ts +81 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +6 -11
- package/lib/chevre/emailMessageBuilder.js +72 -30
- package/lib/chevre/errorHandler.js +1 -0
- package/lib/chevre/repo/accountTransaction.d.ts +0 -5
- package/lib/chevre/repo/accountTransaction.js +44 -38
- package/lib/chevre/repo/code.d.ts +0 -7
- package/lib/chevre/repo/code.js +0 -17
- package/lib/chevre/repo/event.d.ts +5 -4
- package/lib/chevre/repo/event.js +8 -17
- package/lib/chevre/repo/mongoose/model/accountTransaction.js +0 -5
- package/lib/chevre/repo/mongoose/model/member.js +5 -2
- package/lib/chevre/repo/mongoose/model/offer.js +19 -9
- package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
- package/lib/chevre/repo/mongoose/model/product.js +15 -2
- package/lib/chevre/repo/offer.d.ts +17 -2
- package/lib/chevre/repo/offer.js +77 -44
- package/lib/chevre/repo/offerCatalog.d.ts +3 -5
- package/lib/chevre/repo/offerCatalog.js +78 -37
- package/lib/chevre/repo/priceSpecification.d.ts +11 -0
- package/lib/chevre/repo/priceSpecification.js +44 -66
- package/lib/chevre/repo/task.d.ts +8 -0
- package/lib/chevre/repo/task.js +21 -9
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +93 -96
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -3
- package/lib/chevre/service/assetTransaction/pay.js +2 -3
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService/factory.js +6 -3
- package/lib/chevre/service/assetTransaction/registerService.js +3 -1
- package/lib/chevre/service/assetTransaction/reserve/factory/price.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/factory/price.js +0 -7
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/factory.js +0 -1
- package/lib/chevre/service/assetTransaction/reserve.js +47 -17
- package/lib/chevre/service/assetTransaction.d.ts +1 -1
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +1 -38
- package/lib/chevre/service/event.js +20 -3
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +7 -8
- package/lib/chevre/service/notification.js +18 -7
- package/lib/chevre/service/offer/event/authorize.js +5 -5
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +222 -346
- package/lib/chevre/service/offer/factory.d.ts +8 -3
- package/lib/chevre/service/offer/factory.js +44 -26
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +11 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +15 -7
- package/lib/chevre/service/offer/product.d.ts +11 -4
- package/lib/chevre/service/offer/product.js +59 -50
- package/lib/chevre/service/payment/any/factory.js +30 -21
- package/lib/chevre/service/payment/any.js +11 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +22 -0
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +183 -0
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +13 -0
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +45 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +15 -0
- package/lib/chevre/service/{assetTransaction/pay → payment}/movieTicket/validation.js +8 -7
- package/lib/chevre/service/payment/movieTicket.d.ts +10 -22
- package/lib/chevre/service/payment/movieTicket.js +19 -219
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
- package/lib/chevre/service/transaction/orderProgramMembership.js +5 -6
- package/lib/chevre/settings.d.ts +4 -1
- package/lib/chevre/settings.js +7 -1
- package/package.json +3 -3
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.d.ts +0 -14
- package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
- package/lib/chevre/service/task/deleteAuthorization.js +0 -29
package/lib/chevre/repo/code.js
CHANGED
|
@@ -204,23 +204,6 @@ class MongoRepository {
|
|
|
204
204
|
.then((docs) => docs.map((doc) => doc.toObject()));
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
|
-
deleteByCode(params) {
|
|
208
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
-
return this.authorizationModel.deleteOne({
|
|
210
|
-
code: { $exists: true, $eq: params.code }
|
|
211
|
-
})
|
|
212
|
-
.exec()
|
|
213
|
-
.then((result) => {
|
|
214
|
-
return {
|
|
215
|
-
n: result === null || result === void 0 ? void 0 : result.n,
|
|
216
|
-
// opTime: result.opTime,
|
|
217
|
-
ok: result === null || result === void 0 ? void 0 : result.ok,
|
|
218
|
-
// operationTime,
|
|
219
|
-
deletedCount: result === null || result === void 0 ? void 0 : result.deletedCount
|
|
220
|
-
};
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
207
|
/**
|
|
225
208
|
* 有効期限を一定期間過ぎた承認を削除する
|
|
226
209
|
*/
|
|
@@ -10,7 +10,7 @@ export interface IUpdateAggregateReservationParams {
|
|
|
10
10
|
$set: {
|
|
11
11
|
updatedAt: Date;
|
|
12
12
|
aggregateReservation: factory.event.screeningEvent.IAggregateReservation;
|
|
13
|
-
aggregateOffer
|
|
13
|
+
aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
|
|
14
14
|
maximumAttendeeCapacity?: number;
|
|
15
15
|
remainingAttendeeCapacity?: number;
|
|
16
16
|
checkInCount?: number;
|
|
@@ -141,9 +141,10 @@ export declare class MongoRepository {
|
|
|
141
141
|
}, update: IUpdateAggregateReservationParams | IUpdateAggregateUseActionsParams): Promise<factory.event.IEvent<T>>;
|
|
142
142
|
bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteOpResultObject>;
|
|
143
143
|
getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
unsetUnnecessaryFields(params: {
|
|
145
|
+
filter: any;
|
|
146
|
+
$unset: any;
|
|
147
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
147
148
|
aggregateEvent(params: {
|
|
148
149
|
project?: {
|
|
149
150
|
id?: {
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -638,14 +638,14 @@ class MongoRepository {
|
|
|
638
638
|
return __awaiter(this, void 0, void 0, function* () {
|
|
639
639
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
640
640
|
const positiveProjectionExists = (projection !== undefined && projection !== null)
|
|
641
|
-
? Object.
|
|
642
|
-
.some((
|
|
641
|
+
? Object.values(projection)
|
|
642
|
+
.some((value) => value !== 0)
|
|
643
643
|
: false;
|
|
644
644
|
const query = this.eventModel.find({ $and: conditions },
|
|
645
645
|
// :1対応(2023-01-25~)
|
|
646
646
|
(positiveProjectionExists)
|
|
647
647
|
? projection
|
|
648
|
-
: Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }
|
|
648
|
+
: Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }));
|
|
649
649
|
if (typeof params.limit === 'number') {
|
|
650
650
|
const page = (typeof params.page === 'number') ? params.page : 1;
|
|
651
651
|
query.limit(params.limit)
|
|
@@ -680,14 +680,14 @@ class MongoRepository {
|
|
|
680
680
|
findById(params, projection) {
|
|
681
681
|
return __awaiter(this, void 0, void 0, function* () {
|
|
682
682
|
const positiveProjectionExists = (projection !== undefined && projection !== null)
|
|
683
|
-
? Object.
|
|
684
|
-
.some((
|
|
683
|
+
? Object.values(projection)
|
|
684
|
+
.some((value) => value !== 0)
|
|
685
685
|
: false;
|
|
686
686
|
const doc = yield this.eventModel.findOne({ _id: params.id },
|
|
687
687
|
// :1対応(2023-01-25~)
|
|
688
688
|
(positiveProjectionExists)
|
|
689
689
|
? projection
|
|
690
|
-
: Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }
|
|
690
|
+
: Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }))
|
|
691
691
|
.exec();
|
|
692
692
|
if (doc === null) {
|
|
693
693
|
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
@@ -751,18 +751,9 @@ class MongoRepository {
|
|
|
751
751
|
.sort({ startDate: factory.sortType.Descending })
|
|
752
752
|
.cursor();
|
|
753
753
|
}
|
|
754
|
-
|
|
754
|
+
unsetUnnecessaryFields(params) {
|
|
755
755
|
return __awaiter(this, void 0, void 0, function* () {
|
|
756
|
-
|
|
757
|
-
_id: { $eq: params.id }
|
|
758
|
-
}, {
|
|
759
|
-
$unset: {
|
|
760
|
-
'location.project': 1,
|
|
761
|
-
'workPerformed.project': 1,
|
|
762
|
-
'superEvent.location.project': 1,
|
|
763
|
-
'superEvent.workPerformed.project': 1
|
|
764
|
-
}
|
|
765
|
-
})
|
|
756
|
+
return this.eventModel.updateMany(params.filter, { $unset: params.$unset })
|
|
766
757
|
.exec();
|
|
767
758
|
});
|
|
768
759
|
}
|
|
@@ -25,15 +25,10 @@ const schema = new mongoose.Schema({
|
|
|
25
25
|
},
|
|
26
26
|
agent: mongoose.SchemaTypes.Mixed,
|
|
27
27
|
recipient: mongoose.SchemaTypes.Mixed,
|
|
28
|
-
error: mongoose.SchemaTypes.Mixed,
|
|
29
|
-
result: mongoose.SchemaTypes.Mixed,
|
|
30
28
|
object: mongoose.SchemaTypes.Mixed,
|
|
31
29
|
expires: Date,
|
|
32
30
|
startDate: Date,
|
|
33
31
|
endDate: Date,
|
|
34
|
-
dateReturned: Date,
|
|
35
|
-
tasksExportedAt: Date,
|
|
36
|
-
tasksExportationStatus: String,
|
|
37
32
|
potentialActions: mongoose.SchemaTypes.Mixed
|
|
38
33
|
}, {
|
|
39
34
|
collection: 'accountTransactions',
|
|
@@ -10,14 +10,17 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose.Schema({
|
|
12
12
|
project: mongoose.SchemaTypes.Mixed,
|
|
13
|
-
typeOf:
|
|
13
|
+
typeOf: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true
|
|
16
|
+
},
|
|
14
17
|
member: mongoose.SchemaTypes.Mixed
|
|
15
18
|
}, {
|
|
16
19
|
collection: 'members',
|
|
17
20
|
id: true,
|
|
18
21
|
read: 'primaryPreferred',
|
|
19
22
|
writeConcern: writeConcern,
|
|
20
|
-
strict:
|
|
23
|
+
strict: true,
|
|
21
24
|
useNestedStrict: true,
|
|
22
25
|
timestamps: {
|
|
23
26
|
createdAt: 'createdAt',
|
|
@@ -11,8 +11,6 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
|
11
11
|
const schema = new mongoose.Schema({
|
|
12
12
|
project: mongoose.SchemaTypes.Mixed,
|
|
13
13
|
_id: String,
|
|
14
|
-
// Stringに変更(2022-08-08~)
|
|
15
|
-
// identifier: mongoose.SchemaTypes.Mixed,
|
|
16
14
|
identifier: String,
|
|
17
15
|
typeOf: String,
|
|
18
16
|
name: mongoose.SchemaTypes.Mixed,
|
|
@@ -21,16 +19,16 @@ const schema = new mongoose.Schema({
|
|
|
21
19
|
color: mongoose.SchemaTypes.Mixed,
|
|
22
20
|
additionalProperty: [mongoose.SchemaTypes.Mixed],
|
|
23
21
|
alternateName: mongoose.SchemaTypes.Mixed,
|
|
24
|
-
acceptedPaymentMethod: mongoose.SchemaTypes.Mixed,
|
|
25
|
-
addOn: mongoose.SchemaTypes.Mixed,
|
|
26
|
-
availableAddOn: mongoose.SchemaTypes.Mixed,
|
|
22
|
+
// acceptedPaymentMethod: mongoose.SchemaTypes.Mixed, // 削除(2023-02-27~)
|
|
23
|
+
addOn: [mongoose.SchemaTypes.Mixed],
|
|
24
|
+
// availableAddOn: mongoose.SchemaTypes.Mixed, // 削除(2023-02-27~)
|
|
27
25
|
availability: String,
|
|
28
|
-
availabilityEnds: Date,
|
|
29
|
-
availabilityStarts: Date,
|
|
30
|
-
availableAtOrFrom: mongoose.SchemaTypes.Mixed,
|
|
26
|
+
// availabilityEnds: Date, // 削除(2023-02-27~)
|
|
27
|
+
// availabilityStarts: Date, // 削除(2023-02-27~)
|
|
28
|
+
availableAtOrFrom: [mongoose.SchemaTypes.Mixed],
|
|
31
29
|
hasMerchantReturnPolicy: mongoose.SchemaTypes.Mixed,
|
|
32
30
|
itemOffered: mongoose.SchemaTypes.Mixed,
|
|
33
|
-
price: Number,
|
|
31
|
+
// price: Number, // 削除(2023-02-27~)
|
|
34
32
|
priceCurrency: String,
|
|
35
33
|
priceSpecification: mongoose.SchemaTypes.Mixed,
|
|
36
34
|
eligibleCustomerType: mongoose.SchemaTypes.Mixed,
|
|
@@ -196,6 +194,18 @@ schema.index({ additionalProperty: 1, 'priceSpecification.price': 1 }, {
|
|
|
196
194
|
additionalProperty: { $exists: true }
|
|
197
195
|
}
|
|
198
196
|
});
|
|
197
|
+
schema.index({ validFrom: 1, 'priceSpecification.price': 1 }, {
|
|
198
|
+
name: 'searchByValidFrom',
|
|
199
|
+
partialFilterExpression: {
|
|
200
|
+
validFrom: { $exists: true }
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
schema.index({ validThrough: 1, 'priceSpecification.price': 1 }, {
|
|
204
|
+
name: 'searchByValidThrough',
|
|
205
|
+
partialFilterExpression: {
|
|
206
|
+
validThrough: { $exists: true }
|
|
207
|
+
}
|
|
208
|
+
});
|
|
199
209
|
mongoose.model(modelName, schema)
|
|
200
210
|
.on('index',
|
|
201
211
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -10,29 +10,24 @@ const writeConcern = { j: true, w: 'majority', wtimeout: 10000 };
|
|
|
10
10
|
*/
|
|
11
11
|
const schema = new mongoose.Schema({
|
|
12
12
|
project: mongoose.SchemaTypes.Mixed,
|
|
13
|
-
typeOf: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
eligibleQuantity: mongoose.SchemaTypes.Mixed,
|
|
18
|
-
eligibleTransactionVolume: [mongoose.SchemaTypes.Mixed],
|
|
19
|
-
maxPrice: Number,
|
|
20
|
-
minPrice: Number,
|
|
21
|
-
price: Number,
|
|
13
|
+
typeOf: { type: String, required: true },
|
|
14
|
+
name: mongoose.SchemaTypes.Mixed,
|
|
15
|
+
price: { type: Number, required: true },
|
|
22
16
|
priceCurrency: String,
|
|
23
17
|
validFrom: Date,
|
|
24
18
|
validThrough: Date,
|
|
25
19
|
valueAddedTaxIncluded: Boolean,
|
|
26
|
-
referenceQuantity: mongoose.SchemaTypes.Mixed,
|
|
27
|
-
appliesToSoundFormat: String,
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
// referenceQuantity: mongoose.SchemaTypes.Mixed,
|
|
21
|
+
// appliesToSoundFormat: String,
|
|
22
|
+
appliesToCategoryCode: mongoose.SchemaTypes.Mixed,
|
|
23
|
+
appliesToMovieTicket: mongoose.SchemaTypes.Mixed,
|
|
24
|
+
appliesToVideoFormat: String
|
|
30
25
|
}, {
|
|
31
26
|
collection: 'priceSpecifications',
|
|
32
27
|
id: true,
|
|
33
28
|
read: 'primaryPreferred',
|
|
34
29
|
writeConcern: writeConcern,
|
|
35
|
-
strict:
|
|
30
|
+
strict: true,
|
|
36
31
|
useNestedStrict: true,
|
|
37
32
|
timestamps: {
|
|
38
33
|
createdAt: 'createdAt',
|
|
@@ -54,53 +49,25 @@ const schema = new mongoose.Schema({
|
|
|
54
49
|
exports.schema = schema;
|
|
55
50
|
schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
|
|
56
51
|
schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
|
|
57
|
-
schema.index({ price: 1 }, {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
price: { $exists: true }
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
schema.index({ 'priceComponent.typeOf': 1 }, {
|
|
64
|
-
name: 'searchByPriceComponentTypeOf',
|
|
65
|
-
partialFilterExpression: {
|
|
66
|
-
'priceComponent.typeOf': { $exists: true }
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
schema.index({ 'project.id': 1, price: 1 }, {
|
|
70
|
-
name: 'searchByProjectId-v20220721'
|
|
71
|
-
});
|
|
72
|
-
schema.index({ typeOf: 1, price: 1 }, {
|
|
73
|
-
name: 'searchByTypeOf-v2',
|
|
74
|
-
partialFilterExpression: {
|
|
75
|
-
price: { $exists: true }
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
schema.index({ appliesToSoundFormat: 1, price: 1 }, {
|
|
79
|
-
name: 'searchByAppliesToSoundFormat',
|
|
80
|
-
partialFilterExpression: {
|
|
81
|
-
appliesToSoundFormat: { $exists: true },
|
|
82
|
-
price: { $exists: true }
|
|
83
|
-
}
|
|
84
|
-
});
|
|
52
|
+
schema.index({ price: 1 }, { name: 'searchByPrice' });
|
|
53
|
+
schema.index({ 'project.id': 1, price: 1 }, { name: 'searchByProjectId' });
|
|
54
|
+
schema.index({ typeOf: 1, price: 1 }, { name: 'searchByTypeOf' });
|
|
85
55
|
schema.index({ appliesToVideoFormat: 1, price: 1 }, {
|
|
86
56
|
name: 'searchByAppliesToVideoFormat',
|
|
87
57
|
partialFilterExpression: {
|
|
88
|
-
appliesToVideoFormat: { $exists: true }
|
|
89
|
-
price: { $exists: true }
|
|
58
|
+
appliesToVideoFormat: { $exists: true }
|
|
90
59
|
}
|
|
91
60
|
});
|
|
92
|
-
schema.index({
|
|
93
|
-
name: '
|
|
61
|
+
schema.index({ 'appliesToMovieTicket.serviceType': 1, price: 1 }, {
|
|
62
|
+
name: 'searchByAppliesToMovieTicketServiceType',
|
|
94
63
|
partialFilterExpression: {
|
|
95
|
-
|
|
96
|
-
price: { $exists: true }
|
|
64
|
+
'appliesToMovieTicket.serviceType': { $exists: true }
|
|
97
65
|
}
|
|
98
66
|
});
|
|
99
|
-
schema.index({ 'appliesToMovieTicket.
|
|
100
|
-
name: '
|
|
67
|
+
schema.index({ 'appliesToMovieTicket.serviceOutput.typeOf': 1, price: 1 }, {
|
|
68
|
+
name: 'searchByAppliesToMovieTicketServiceOutputTypeOf',
|
|
101
69
|
partialFilterExpression: {
|
|
102
|
-
'appliesToMovieTicket.
|
|
103
|
-
price: { $exists: true }
|
|
70
|
+
'appliesToMovieTicket.serviceOutput.typeOf': { $exists: true }
|
|
104
71
|
}
|
|
105
72
|
});
|
|
106
73
|
schema.index({ appliesToCategoryCode: 1, price: 1 }, {
|
|
@@ -13,13 +13,26 @@ const schema = new mongoose.Schema({
|
|
|
13
13
|
typeOf: {
|
|
14
14
|
type: String,
|
|
15
15
|
required: true
|
|
16
|
-
}
|
|
16
|
+
},
|
|
17
|
+
additionalProperty: [mongoose.SchemaTypes.Mixed],
|
|
18
|
+
availableChannel: mongoose.SchemaTypes.Mixed,
|
|
19
|
+
description: mongoose.SchemaTypes.Mixed,
|
|
20
|
+
hasOfferCatalog: mongoose.SchemaTypes.Mixed,
|
|
21
|
+
name: mongoose.SchemaTypes.Mixed,
|
|
22
|
+
offers: [mongoose.SchemaTypes.Mixed],
|
|
23
|
+
productID: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
provider: [mongoose.SchemaTypes.Mixed],
|
|
28
|
+
serviceOutput: mongoose.SchemaTypes.Mixed,
|
|
29
|
+
serviceType: mongoose.SchemaTypes.Mixed
|
|
17
30
|
}, {
|
|
18
31
|
collection: 'products',
|
|
19
32
|
id: true,
|
|
20
33
|
read: 'primaryPreferred',
|
|
21
34
|
writeConcern: writeConcern,
|
|
22
|
-
strict:
|
|
35
|
+
strict: true,
|
|
23
36
|
useNestedStrict: true,
|
|
24
37
|
timestamps: {
|
|
25
38
|
createdAt: 'createdAt',
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
+
interface IProjection {
|
|
4
|
+
[key: string]: 0 | 1;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* オファーリポジトリ
|
|
5
8
|
*/
|
|
@@ -23,15 +26,22 @@ export declare class MongoRepository {
|
|
|
23
26
|
availableAtOrFrom?: {
|
|
24
27
|
id?: string;
|
|
25
28
|
};
|
|
29
|
+
unacceptedPaymentMethod?: string[];
|
|
30
|
+
excludeAppliesToMovieTicket: boolean;
|
|
31
|
+
onlyValid?: boolean;
|
|
26
32
|
limit?: number;
|
|
27
33
|
page?: number;
|
|
28
34
|
sort: boolean;
|
|
29
|
-
|
|
35
|
+
projection?: IProjection;
|
|
36
|
+
}): Promise<{
|
|
37
|
+
offers: factory.unitPriceOffer.IUnitPriceOffer[];
|
|
38
|
+
sortedOfferIds: string[];
|
|
39
|
+
}>;
|
|
30
40
|
findById(params: {
|
|
31
41
|
id: string;
|
|
32
42
|
}): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
33
43
|
count(params: factory.unitPriceOffer.ISearchConditions): Promise<number>;
|
|
34
|
-
search(params: factory.unitPriceOffer.ISearchConditions): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
44
|
+
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.unitPriceOffer.IUnitPriceOffer[]>;
|
|
35
45
|
save(params: factory.unitPriceOffer.IUnitPriceOffer): Promise<factory.unitPriceOffer.IUnitPriceOffer>;
|
|
36
46
|
saveManyByIdentifier(params: {
|
|
37
47
|
attributes: factory.unitPriceOffer.IUnitPriceOffer;
|
|
@@ -46,4 +56,9 @@ export declare class MongoRepository {
|
|
|
46
56
|
};
|
|
47
57
|
}): Promise<void>;
|
|
48
58
|
getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
|
|
59
|
+
unsetUnnecessaryFields(params: {
|
|
60
|
+
filter: any;
|
|
61
|
+
$unset: any;
|
|
62
|
+
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
49
63
|
}
|
|
64
|
+
export {};
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -35,7 +35,7 @@ class MongoRepository {
|
|
|
35
35
|
}
|
|
36
36
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
37
37
|
static CREATE_OFFER_MONGO_CONDITIONS(params) {
|
|
38
|
-
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;
|
|
38
|
+
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;
|
|
39
39
|
// MongoDB検索条件
|
|
40
40
|
const andConditions = [];
|
|
41
41
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
@@ -166,7 +166,15 @@ class MongoRepository {
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
const
|
|
169
|
+
const appliesToMovieTicketServiceTypeExist = (_w = (_v = (_u = params.priceSpecification) === null || _u === void 0 ? void 0 : _u.appliesToMovieTicket) === null || _v === void 0 ? void 0 : _v.serviceType) === null || _w === void 0 ? void 0 : _w.$exists;
|
|
170
|
+
if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
|
|
171
|
+
andConditions.push({
|
|
172
|
+
'priceSpecification.appliesToMovieTicket.serviceType': {
|
|
173
|
+
$exists: appliesToMovieTicketServiceTypeExist
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const appliesToMovieTicketServiceTypeEq = (_z = (_y = (_x = params.priceSpecification) === null || _x === void 0 ? void 0 : _x.appliesToMovieTicket) === null || _y === void 0 ? void 0 : _y.serviceType) === null || _z === void 0 ? void 0 : _z.$eq;
|
|
170
178
|
if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
|
|
171
179
|
andConditions.push({
|
|
172
180
|
'priceSpecification.appliesToMovieTicket.serviceType': {
|
|
@@ -175,7 +183,7 @@ class MongoRepository {
|
|
|
175
183
|
}
|
|
176
184
|
});
|
|
177
185
|
}
|
|
178
|
-
const appliesToMovieTicketServiceOutputTypeOfEq = (
|
|
186
|
+
const appliesToMovieTicketServiceOutputTypeOfEq = (_3 = (_2 = (_1 = (_0 = params.priceSpecification) === null || _0 === void 0 ? void 0 : _0.appliesToMovieTicket) === null || _1 === void 0 ? void 0 : _1.serviceOutput) === null || _2 === void 0 ? void 0 : _2.typeOf) === null || _3 === void 0 ? void 0 : _3.$eq;
|
|
179
187
|
if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
|
|
180
188
|
andConditions.push({
|
|
181
189
|
'priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
@@ -184,8 +192,16 @@ class MongoRepository {
|
|
|
184
192
|
}
|
|
185
193
|
});
|
|
186
194
|
}
|
|
195
|
+
const appliesToMovieTicketServiceOutputTypeOfNin = (_7 = (_6 = (_5 = (_4 = params.priceSpecification) === null || _4 === void 0 ? void 0 : _4.appliesToMovieTicket) === null || _5 === void 0 ? void 0 : _5.serviceOutput) === null || _6 === void 0 ? void 0 : _6.typeOf) === null || _7 === void 0 ? void 0 : _7.$nin;
|
|
196
|
+
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
|
|
197
|
+
andConditions.push({
|
|
198
|
+
'priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
199
|
+
$nin: appliesToMovieTicketServiceOutputTypeOfNin
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
187
203
|
if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
|
|
188
|
-
const priceSpecificationPriceGte = (
|
|
204
|
+
const priceSpecificationPriceGte = (_8 = params.priceSpecification.price) === null || _8 === void 0 ? void 0 : _8.$gte;
|
|
189
205
|
if (typeof priceSpecificationPriceGte === 'number') {
|
|
190
206
|
andConditions.push({
|
|
191
207
|
'priceSpecification.price': {
|
|
@@ -194,7 +210,7 @@ class MongoRepository {
|
|
|
194
210
|
}
|
|
195
211
|
});
|
|
196
212
|
}
|
|
197
|
-
const priceSpecificationPriceLte = (
|
|
213
|
+
const priceSpecificationPriceLte = (_9 = params.priceSpecification.price) === null || _9 === void 0 ? void 0 : _9.$lte;
|
|
198
214
|
if (typeof priceSpecificationPriceLte === 'number') {
|
|
199
215
|
andConditions.push({
|
|
200
216
|
'priceSpecification.price': {
|
|
@@ -203,7 +219,7 @@ class MongoRepository {
|
|
|
203
219
|
}
|
|
204
220
|
});
|
|
205
221
|
}
|
|
206
|
-
const accountsReceivableGte = (
|
|
222
|
+
const accountsReceivableGte = (_11 = (_10 = params.priceSpecification.accounting) === null || _10 === void 0 ? void 0 : _10.accountsReceivable) === null || _11 === void 0 ? void 0 : _11.$gte;
|
|
207
223
|
if (typeof accountsReceivableGte === 'number') {
|
|
208
224
|
andConditions.push({
|
|
209
225
|
'priceSpecification.accounting.accountsReceivable': {
|
|
@@ -212,7 +228,7 @@ class MongoRepository {
|
|
|
212
228
|
}
|
|
213
229
|
});
|
|
214
230
|
}
|
|
215
|
-
const accountsReceivableLte = (
|
|
231
|
+
const accountsReceivableLte = (_13 = (_12 = params.priceSpecification.accounting) === null || _12 === void 0 ? void 0 : _12.accountsReceivable) === null || _13 === void 0 ? void 0 : _13.$lte;
|
|
216
232
|
if (typeof accountsReceivableLte === 'number') {
|
|
217
233
|
andConditions.push({
|
|
218
234
|
'priceSpecification.accounting.accountsReceivable': {
|
|
@@ -221,7 +237,7 @@ class MongoRepository {
|
|
|
221
237
|
}
|
|
222
238
|
});
|
|
223
239
|
}
|
|
224
|
-
const accountingCodeValueEq = (
|
|
240
|
+
const accountingCodeValueEq = (_16 = (_15 = (_14 = params.priceSpecification.accounting) === null || _14 === void 0 ? void 0 : _14.operatingRevenue) === null || _15 === void 0 ? void 0 : _15.codeValue) === null || _16 === void 0 ? void 0 : _16.$eq;
|
|
225
241
|
if (typeof accountingCodeValueEq === 'string') {
|
|
226
242
|
andConditions.push({
|
|
227
243
|
'priceSpecification.accounting.operatingRevenue.codeValue': {
|
|
@@ -230,7 +246,7 @@ class MongoRepository {
|
|
|
230
246
|
}
|
|
231
247
|
});
|
|
232
248
|
}
|
|
233
|
-
const accountingCodeValueIn = (
|
|
249
|
+
const accountingCodeValueIn = (_19 = (_18 = (_17 = params.priceSpecification.accounting) === null || _17 === void 0 ? void 0 : _17.operatingRevenue) === null || _18 === void 0 ? void 0 : _18.codeValue) === null || _19 === void 0 ? void 0 : _19.$in;
|
|
234
250
|
if (Array.isArray(accountingCodeValueIn)) {
|
|
235
251
|
andConditions.push({
|
|
236
252
|
'priceSpecification.accounting.operatingRevenue.codeValue': {
|
|
@@ -239,7 +255,7 @@ class MongoRepository {
|
|
|
239
255
|
}
|
|
240
256
|
});
|
|
241
257
|
}
|
|
242
|
-
const referenceQuantityValueEq = (
|
|
258
|
+
const referenceQuantityValueEq = (_21 = (_20 = params.priceSpecification.referenceQuantity) === null || _20 === void 0 ? void 0 : _20.value) === null || _21 === void 0 ? void 0 : _21.$eq;
|
|
243
259
|
if (typeof referenceQuantityValueEq === 'number') {
|
|
244
260
|
andConditions.push({
|
|
245
261
|
'priceSpecification.referenceQuantity.value': {
|
|
@@ -249,7 +265,7 @@ class MongoRepository {
|
|
|
249
265
|
});
|
|
250
266
|
}
|
|
251
267
|
}
|
|
252
|
-
const availableAtOrFromIdEq = (
|
|
268
|
+
const availableAtOrFromIdEq = (_23 = (_22 = params.availableAtOrFrom) === null || _22 === void 0 ? void 0 : _22.id) === null || _23 === void 0 ? void 0 : _23.$eq;
|
|
253
269
|
if (typeof availableAtOrFromIdEq === 'string') {
|
|
254
270
|
andConditions.push({
|
|
255
271
|
'availableAtOrFrom.id': {
|
|
@@ -258,7 +274,7 @@ class MongoRepository {
|
|
|
258
274
|
}
|
|
259
275
|
});
|
|
260
276
|
}
|
|
261
|
-
const availableAtOrFromIdIn = (
|
|
277
|
+
const availableAtOrFromIdIn = (_25 = (_24 = params.availableAtOrFrom) === null || _24 === void 0 ? void 0 : _24.id) === null || _25 === void 0 ? void 0 : _25.$in;
|
|
262
278
|
if (Array.isArray(availableAtOrFromIdIn)) {
|
|
263
279
|
andConditions.push({
|
|
264
280
|
'availableAtOrFrom.id': {
|
|
@@ -267,7 +283,7 @@ class MongoRepository {
|
|
|
267
283
|
}
|
|
268
284
|
});
|
|
269
285
|
}
|
|
270
|
-
const addOnItemOfferedIdEq = (
|
|
286
|
+
const addOnItemOfferedIdEq = (_28 = (_27 = (_26 = params.addOn) === null || _26 === void 0 ? void 0 : _26.itemOffered) === null || _27 === void 0 ? void 0 : _27.id) === null || _28 === void 0 ? void 0 : _28.$eq;
|
|
271
287
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
272
288
|
andConditions.push({
|
|
273
289
|
'addOn.itemOffered.id': {
|
|
@@ -276,7 +292,7 @@ class MongoRepository {
|
|
|
276
292
|
}
|
|
277
293
|
});
|
|
278
294
|
}
|
|
279
|
-
const hasMerchantReturnPolicyIdEq = (
|
|
295
|
+
const hasMerchantReturnPolicyIdEq = (_30 = (_29 = params.hasMerchantReturnPolicy) === null || _29 === void 0 ? void 0 : _29.id) === null || _30 === void 0 ? void 0 : _30.$eq;
|
|
280
296
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
281
297
|
andConditions.push({
|
|
282
298
|
'hasMerchantReturnPolicy.id': {
|
|
@@ -285,7 +301,7 @@ class MongoRepository {
|
|
|
285
301
|
}
|
|
286
302
|
});
|
|
287
303
|
}
|
|
288
|
-
const additionalPropertyElemMatch = (
|
|
304
|
+
const additionalPropertyElemMatch = (_31 = params.additionalProperty) === null || _31 === void 0 ? void 0 : _31.$elemMatch;
|
|
289
305
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
290
306
|
andConditions.push({
|
|
291
307
|
additionalProperty: {
|
|
@@ -294,6 +310,20 @@ class MongoRepository {
|
|
|
294
310
|
}
|
|
295
311
|
});
|
|
296
312
|
}
|
|
313
|
+
if (params.onlyValid === true) {
|
|
314
|
+
const now = new Date();
|
|
315
|
+
andConditions.push({
|
|
316
|
+
$or: [
|
|
317
|
+
{ validFrom: { $exists: false } },
|
|
318
|
+
{ validFrom: { $exists: true, $lte: now } }
|
|
319
|
+
]
|
|
320
|
+
}, {
|
|
321
|
+
$or: [
|
|
322
|
+
{ validThrough: { $exists: false } },
|
|
323
|
+
{ validThrough: { $exists: true, $gte: now } }
|
|
324
|
+
]
|
|
325
|
+
});
|
|
326
|
+
}
|
|
297
327
|
return andConditions;
|
|
298
328
|
}
|
|
299
329
|
/**
|
|
@@ -324,37 +354,32 @@ class MongoRepository {
|
|
|
324
354
|
const sortedOfferIds = (Array.isArray(itemListElements))
|
|
325
355
|
? itemListElements.map((element) => element.id)
|
|
326
356
|
: [];
|
|
327
|
-
// const offerCatalog = await this.offerCatalogModel.findById(
|
|
328
|
-
// params.offerCatalog.id,
|
|
329
|
-
// {
|
|
330
|
-
// itemListElement: 1
|
|
331
|
-
// }
|
|
332
|
-
// )
|
|
333
|
-
// .exec()
|
|
334
|
-
// .then((doc) => {
|
|
335
|
-
// if (doc === null) {
|
|
336
|
-
// throw new factory.errors.NotFound(this.offerCatalogModel.modelName);
|
|
337
|
-
// }
|
|
338
|
-
// return <Pick<factory.offerCatalog.IOfferCatalog, 'itemListElement'>>doc.toObject();
|
|
339
|
-
// });
|
|
340
|
-
// let sortedOfferIds: string[] = (Array.isArray(offerCatalog.itemListElement))
|
|
341
|
-
// ? offerCatalog.itemListElement.map((element) => element.id)
|
|
342
|
-
// : [];
|
|
343
|
-
// const filteredIds = params.ids;
|
|
344
|
-
// if (Array.isArray(filteredIds)) {
|
|
345
|
-
// sortedOfferIds = sortedOfferIds.filter((id) => filteredIds.includes(id));
|
|
346
|
-
// }
|
|
347
357
|
let offers = [];
|
|
348
358
|
if (sortedOfferIds.length > 0) {
|
|
349
|
-
|
|
359
|
+
const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ id: { $in: sortedOfferIds } }, (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
350
360
|
? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
|
|
351
|
-
: undefined)
|
|
361
|
+
: undefined), { priceSpecification: {
|
|
362
|
+
appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
|
|
363
|
+
? {
|
|
364
|
+
serviceOutput: {
|
|
365
|
+
typeOf: { $nin: params.unacceptedPaymentMethod }
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
: undefined), (params.excludeAppliesToMovieTicket)
|
|
369
|
+
? {
|
|
370
|
+
serviceType: { $exists: false }
|
|
371
|
+
}
|
|
372
|
+
: undefined)
|
|
373
|
+
}, onlyValid: params.onlyValid === true }), (typeof params.limit === 'number' && typeof params.page === 'number')
|
|
374
|
+
? { sort: { _id: factory.sortType.Ascending } }
|
|
375
|
+
: undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
|
|
376
|
+
offers = yield this.search(searchOffersConditions, params.projection);
|
|
352
377
|
if (params.sort) {
|
|
353
378
|
// sorting
|
|
354
379
|
offers = offers.sort((a, b) => sortedOfferIds.indexOf(String(a.id)) - sortedOfferIds.indexOf(String(b.id)));
|
|
355
380
|
}
|
|
356
381
|
}
|
|
357
|
-
return offers;
|
|
382
|
+
return { offers, sortedOfferIds };
|
|
358
383
|
});
|
|
359
384
|
}
|
|
360
385
|
findById(params) {
|
|
@@ -379,14 +404,16 @@ class MongoRepository {
|
|
|
379
404
|
.exec();
|
|
380
405
|
});
|
|
381
406
|
}
|
|
382
|
-
search(params) {
|
|
407
|
+
search(params, projection) {
|
|
383
408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
384
409
|
const conditions = MongoRepository.CREATE_OFFER_MONGO_CONDITIONS(params);
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
})
|
|
410
|
+
const positiveProjectionExists = (projection !== undefined && projection !== null)
|
|
411
|
+
? Object.values(projection)
|
|
412
|
+
.some((value) => value !== 0)
|
|
413
|
+
: false;
|
|
414
|
+
const query = this.offerModel.find((conditions.length > 0) ? { $and: conditions } : {}, (positiveProjectionExists)
|
|
415
|
+
? projection
|
|
416
|
+
: Object.assign(Object.assign({}, projection), { __v: 0, createdAt: 0, updatedAt: 0 }));
|
|
390
417
|
if (typeof params.limit === 'number') {
|
|
391
418
|
const page = (typeof params.page === 'number') ? params.page : 1;
|
|
392
419
|
query.limit(params.limit)
|
|
@@ -475,5 +502,11 @@ class MongoRepository {
|
|
|
475
502
|
.sort({ 'priceSpecification.price': factory.sortType.Descending })
|
|
476
503
|
.cursor();
|
|
477
504
|
}
|
|
505
|
+
unsetUnnecessaryFields(params) {
|
|
506
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
507
|
+
return this.offerModel.updateMany(params.filter, { $unset: params.$unset })
|
|
508
|
+
.exec();
|
|
509
|
+
});
|
|
510
|
+
}
|
|
478
511
|
}
|
|
479
512
|
exports.MongoRepository = MongoRepository;
|
|
@@ -28,11 +28,9 @@ export declare class MongoRepository {
|
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
30
|
}): Promise<void>;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})
|
|
34
|
-
count(params: factory.offerCatalog.ISearchConditions): Promise<number>;
|
|
35
|
-
search(params: factory.offerCatalog.ISearchConditions): Promise<factory.offerCatalog.IOfferCatalog[]>;
|
|
31
|
+
search(params: factory.offerCatalog.ISearchConditions): Promise<(Omit<factory.offerCatalog.IOfferCatalog, 'itemListElement'> & {
|
|
32
|
+
numberOfItems?: number;
|
|
33
|
+
})[]>;
|
|
36
34
|
deleteById(params: {
|
|
37
35
|
id: string;
|
|
38
36
|
}): Promise<void>;
|