@chevre/domain 25.2.0-alpha.42 → 25.2.0-alpha.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/aggregateOffer.d.ts +1 -11
- package/lib/chevre/repo/aggregateOffer.js +8 -117
- package/lib/chevre/repo/offer/offerInCatalogReadOnly.d.ts +1 -1
- package/lib/chevre/repo/offer/unitPriceInCatalog.d.ts +1 -1
- package/lib/chevre/repo/offer/unitPriceInCatalog.js +5 -4
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ export declare class AggregateOfferRepo {
|
|
|
12
12
|
constructor(connection: Connection);
|
|
13
13
|
static CREATE_MATCH_STAGE(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): IMatchStage[];
|
|
14
14
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): Record<string, AnyExpression>;
|
|
15
|
-
|
|
15
|
+
findAggregateOffers(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
|
|
16
16
|
pushIncludedInDataCatalog(params: {
|
|
17
17
|
project: {
|
|
18
18
|
id: string;
|
|
@@ -109,15 +109,5 @@ export declare class AggregateOfferRepo {
|
|
|
109
109
|
};
|
|
110
110
|
};
|
|
111
111
|
}): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
112
|
-
countIncludedInDataCatalog(params: {
|
|
113
|
-
id: {
|
|
114
|
-
$eq: string;
|
|
115
|
-
};
|
|
116
|
-
}): Promise<{
|
|
117
|
-
includedInDataCatalogCount: number;
|
|
118
|
-
}[]>;
|
|
119
|
-
maxIncludedInDataCatalogCount(): Promise<{
|
|
120
|
-
includedInDataCatalogCount: number;
|
|
121
|
-
}[]>;
|
|
122
112
|
}
|
|
123
113
|
export {};
|
|
@@ -390,7 +390,6 @@ class AggregateOfferRepo {
|
|
|
390
390
|
id: '$_id',
|
|
391
391
|
typeOf: '$typeOf',
|
|
392
392
|
project: '$project',
|
|
393
|
-
// offers: [{ $first: '$offers' }],
|
|
394
393
|
highPrice: { $max: '$offers.priceSpecification.price' },
|
|
395
394
|
lowPrice: { $min: '$offers.priceSpecification.price' },
|
|
396
395
|
offerCount: { $size: '$offers' }
|
|
@@ -410,7 +409,7 @@ class AggregateOfferRepo {
|
|
|
410
409
|
}
|
|
411
410
|
return projectStage;
|
|
412
411
|
}
|
|
413
|
-
async
|
|
412
|
+
async findAggregateOffers(params, projection) {
|
|
414
413
|
const matchStages = AggregateOfferRepo.CREATE_MATCH_STAGE(params);
|
|
415
414
|
const projectStage = AggregateOfferRepo.CREATE_AGGREGATE_OFFERS_PROJECTION({ ...projection });
|
|
416
415
|
const sortByPrice = params.sort?.['priceSpecification.price'];
|
|
@@ -436,8 +435,11 @@ class AggregateOfferRepo {
|
|
|
436
435
|
/* istanbul ignore else */
|
|
437
436
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
438
437
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
// support skip -> limit(2026-07-24~)
|
|
439
|
+
// aggregate.limit(params.limit * page)
|
|
440
|
+
// .skip(params.limit * (page - 1));
|
|
441
|
+
aggregate.skip(params.limit * (page - 1))
|
|
442
|
+
.limit(params.limit);
|
|
441
443
|
}
|
|
442
444
|
return aggregate.exec();
|
|
443
445
|
}
|
|
@@ -499,25 +501,6 @@ class AggregateOfferRepo {
|
|
|
499
501
|
}, { projection: { _id: 1 } })
|
|
500
502
|
.exec();
|
|
501
503
|
}
|
|
502
|
-
// 単価オファー最適化作業における一時的な処理
|
|
503
|
-
// public async optimizeOffers() {
|
|
504
|
-
// return this.aggregateOfferModel.updateMany(
|
|
505
|
-
// {
|
|
506
|
-
// $or: [
|
|
507
|
-
// { 'offers.id': { $exists: true } },
|
|
508
|
-
// { 'offers.project': { $exists: true } }
|
|
509
|
-
// ]
|
|
510
|
-
// },
|
|
511
|
-
// {
|
|
512
|
-
// $set: {},
|
|
513
|
-
// $unset: {
|
|
514
|
-
// 'offers.0.id': 1,
|
|
515
|
-
// 'offers.0.project': 1
|
|
516
|
-
// }
|
|
517
|
-
// }
|
|
518
|
-
// )
|
|
519
|
-
// .exec();
|
|
520
|
-
// }
|
|
521
504
|
getCursor(conditions, projection) {
|
|
522
505
|
return this.aggregateOfferModel.find(conditions, projection)
|
|
523
506
|
.sort({ 'offers.identifier': factory_1.factory.sortType.Ascending })
|
|
@@ -530,15 +513,12 @@ class AggregateOfferRepo {
|
|
|
530
513
|
async save(params) {
|
|
531
514
|
let doc;
|
|
532
515
|
let aggregateOfferId;
|
|
533
|
-
// const { $unset, ...paramsWithoutUnset } = params;
|
|
534
516
|
const { ...paramsWithoutUnset } = params;
|
|
535
|
-
// let savedUnitPriceOffer: factory.unitPriceOffer.IUnitPriceOffer;
|
|
536
517
|
if (typeof params.id !== 'string' || params.id.length === 0) {
|
|
537
518
|
const { default: uniqid } = await import('uniqid');
|
|
538
519
|
const newId = uniqid();
|
|
539
520
|
aggregateOfferId = newId;
|
|
540
521
|
// サブオファー最適化(2023-12-22~)
|
|
541
|
-
// savedUnitPriceOffer = { ...paramsWithoutUnset, id };
|
|
542
522
|
const { id, project, ...savedUnitPriceOffer } = paramsWithoutUnset; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
543
523
|
const aggregateOffer = {
|
|
544
524
|
typeOf: factory_1.factory.offerType.AggregateOffer,
|
|
@@ -552,18 +532,7 @@ class AggregateOfferRepo {
|
|
|
552
532
|
}
|
|
553
533
|
else {
|
|
554
534
|
aggregateOfferId = params.id;
|
|
555
|
-
|
|
556
|
-
// await this.search(
|
|
557
|
-
// {
|
|
558
|
-
// limit: 1,
|
|
559
|
-
// page: 1,
|
|
560
|
-
// project: { id: { $eq: params.project.id } },
|
|
561
|
-
// id: { $eq: params.id }
|
|
562
|
-
// },
|
|
563
|
-
// { identifier: 1, project: 1, typeOf: 1 }
|
|
564
|
-
// );
|
|
565
|
-
// const originalUnitPriceOffer = unitPriceOffers.shift();
|
|
566
|
-
const aggregateOffers = await this.search({
|
|
535
|
+
const aggregateOffers = await this.findAggregateOffers({
|
|
567
536
|
limit: 1,
|
|
568
537
|
page: 1,
|
|
569
538
|
project: { id: { $eq: params.project.id } },
|
|
@@ -579,26 +548,17 @@ class AggregateOfferRepo {
|
|
|
579
548
|
// サブオファー最適化(2023-12-22~)
|
|
580
549
|
const subOffer = {
|
|
581
550
|
...updateFields,
|
|
582
|
-
// id: originalUnitPriceOffer.id,
|
|
583
551
|
identifier: originalUnitPriceOffer.identifier,
|
|
584
|
-
// project: originalUnitPriceOffer.project,
|
|
585
552
|
typeOf: originalUnitPriceOffer.typeOf
|
|
586
553
|
};
|
|
587
|
-
doc = await this.aggregateOfferModel.findOneAndUpdate(
|
|
588
|
-
// { 'offers.id': params.id },
|
|
589
|
-
{ _id: params.id }, // _idに変更(2023-12-22~)
|
|
554
|
+
doc = await this.aggregateOfferModel.findOneAndUpdate({ _id: params.id }, // _idに変更(2023-12-22~)
|
|
590
555
|
{
|
|
591
556
|
$set: {
|
|
592
|
-
// 'offers.$[offer]': savedUnitPriceOffer
|
|
593
557
|
'offers.0': subOffer // _idに変更(2023-12-22~)
|
|
594
558
|
}
|
|
595
559
|
}, {
|
|
596
560
|
upsert: false,
|
|
597
561
|
new: true
|
|
598
|
-
// _idに変更(2023-12-22~)
|
|
599
|
-
// arrayFilters: [
|
|
600
|
-
// { 'offer.id': { $eq: params.id } }
|
|
601
|
-
// ]
|
|
602
562
|
})
|
|
603
563
|
.exec();
|
|
604
564
|
}
|
|
@@ -676,7 +636,6 @@ class AggregateOfferRepo {
|
|
|
676
636
|
async saveManyByIdentifier4sskts(params) {
|
|
677
637
|
const { default: uniqid } = await import('uniqid');
|
|
678
638
|
const insertBulkWriteOps = [];
|
|
679
|
-
// const updateBulkWriteOps: AnyBulkWriteOperation[] = [];
|
|
680
639
|
if (Array.isArray(params)) {
|
|
681
640
|
params.forEach((p) => {
|
|
682
641
|
const newOfferId = uniqid();
|
|
@@ -710,7 +669,6 @@ class AggregateOfferRepo {
|
|
|
710
669
|
}
|
|
711
670
|
if (insertBulkWriteOps.length > 0) {
|
|
712
671
|
await this.aggregateOfferModel.bulkWrite(insertBulkWriteOps, { ordered: false });
|
|
713
|
-
// await this.aggregateOfferModel.bulkWrite(updateBulkWriteOps, { ordered: false });
|
|
714
672
|
}
|
|
715
673
|
}
|
|
716
674
|
/**
|
|
@@ -724,13 +682,6 @@ class AggregateOfferRepo {
|
|
|
724
682
|
'project.id': { $eq: params.project.id },
|
|
725
683
|
'offers.addOn.itemOffered.id': { $exists: true, $in: params.addOn.itemOffered.id.$in }
|
|
726
684
|
};
|
|
727
|
-
// const updatingOffers = <Pick<factory.unitPriceOffer.IUnitPriceOffer, 'id' | 'identifier'>[]>await this.search(
|
|
728
|
-
// {
|
|
729
|
-
// project: { id: { $eq: params.project.id } },
|
|
730
|
-
// addOn: { itemOffered: { id: { $in: params.addOn.itemOffered.id.$in } } }
|
|
731
|
-
// },
|
|
732
|
-
// { identifier: 1 }
|
|
733
|
-
// );
|
|
734
685
|
return this.aggregateOfferModel.updateMany(conditions, {
|
|
735
686
|
$pull: {
|
|
736
687
|
'offers.$[offer].addOn': {
|
|
@@ -743,66 +694,6 @@ class AggregateOfferRepo {
|
|
|
743
694
|
]
|
|
744
695
|
})
|
|
745
696
|
.exec();
|
|
746
|
-
// if (updatingOffers.length > 0) {
|
|
747
|
-
// // no op
|
|
748
|
-
// }
|
|
749
|
-
// return result;
|
|
750
|
-
}
|
|
751
|
-
async countIncludedInDataCatalog(params) {
|
|
752
|
-
const aggregate = this.aggregateOfferModel.aggregate([
|
|
753
|
-
{
|
|
754
|
-
$match: {
|
|
755
|
-
_id: { $eq: params.id.$eq }
|
|
756
|
-
}
|
|
757
|
-
},
|
|
758
|
-
{
|
|
759
|
-
$project: {
|
|
760
|
-
_id: 0,
|
|
761
|
-
includedInDataCatalogCount: {
|
|
762
|
-
$cond: {
|
|
763
|
-
if: { $isArray: '$includedInDataCatalog' },
|
|
764
|
-
then: { $size: '$includedInDataCatalog' },
|
|
765
|
-
else: 0
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
]);
|
|
771
|
-
return aggregate.exec();
|
|
772
|
-
}
|
|
773
|
-
async maxIncludedInDataCatalogCount() {
|
|
774
|
-
const aggregate = this.aggregateOfferModel.aggregate([
|
|
775
|
-
// {
|
|
776
|
-
// $match: {
|
|
777
|
-
// _id: { $eq: params.id.$eq }
|
|
778
|
-
// }
|
|
779
|
-
// },
|
|
780
|
-
{
|
|
781
|
-
$project: {
|
|
782
|
-
_id: 0,
|
|
783
|
-
includedInDataCatalogCount: {
|
|
784
|
-
$cond: {
|
|
785
|
-
if: { $isArray: '$includedInDataCatalog' },
|
|
786
|
-
then: { $size: '$includedInDataCatalog' },
|
|
787
|
-
else: 0
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
},
|
|
792
|
-
{
|
|
793
|
-
$group: {
|
|
794
|
-
_id: null,
|
|
795
|
-
maxCount: { $max: '$includedInDataCatalogCount' }
|
|
796
|
-
}
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
$project: {
|
|
800
|
-
_id: 0,
|
|
801
|
-
maxCount: '$maxCount'
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
]);
|
|
805
|
-
return aggregate.exec();
|
|
806
697
|
}
|
|
807
698
|
}
|
|
808
699
|
exports.AggregateOfferRepo = AggregateOfferRepo;
|
|
@@ -128,7 +128,7 @@ declare abstract class OfferInCatalogReadOnlyRepo {
|
|
|
128
128
|
*/
|
|
129
129
|
id: string;
|
|
130
130
|
}[]>;
|
|
131
|
-
abstract
|
|
131
|
+
abstract countUnitPriceOffers(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
132
132
|
abstract findUnitPriceOffers(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<IOfferInCatalog[]>;
|
|
133
133
|
}
|
|
134
134
|
export { KeyOfOffer, IProjection, IOfferInCatalog, IPriceSpecificationConditionsOnSearchWithSortIndex, OfferInCatalogReadOnlyRepo };
|
|
@@ -137,7 +137,7 @@ export declare class OfferRepo implements OfferInCatalogReadOnlyRepo {
|
|
|
137
137
|
};
|
|
138
138
|
unacceptedPaymentMethod: string[];
|
|
139
139
|
}): Promise<boolean>;
|
|
140
|
-
|
|
140
|
+
countUnitPriceOffers(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
141
141
|
findUnitPriceOffers(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<IOfferInCatalog[]>;
|
|
142
142
|
/**
|
|
143
143
|
* サブカタログから集計オファーIDリストを検索する
|
|
@@ -370,12 +370,13 @@ class OfferRepo {
|
|
|
370
370
|
.exec();
|
|
371
371
|
return doc !== null;
|
|
372
372
|
}
|
|
373
|
-
async
|
|
373
|
+
async countUnitPriceOffers(params) {
|
|
374
374
|
const matchStages = aggregateOffer_1.AggregateOfferRepo.CREATE_MATCH_STAGE(params);
|
|
375
375
|
const result = await this.aggregateOfferModel.aggregate([
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
376
|
+
// // offers.length:1の前提であるため、unwindは不要(2026-07-23~)
|
|
377
|
+
// {
|
|
378
|
+
// $unwind: { path: '$offers' }
|
|
379
|
+
// },
|
|
379
380
|
...matchStages,
|
|
380
381
|
{
|
|
381
382
|
$count: 'offerCount'
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "10.0.0",
|
|
14
|
+
"@chevre/factory": "10.1.0-alpha.0",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"postversion": "git push origin --tags",
|
|
89
89
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
90
|
},
|
|
91
|
-
"version": "25.2.0-alpha.
|
|
91
|
+
"version": "25.2.0-alpha.43"
|
|
92
92
|
}
|