@chevre/domain 21.18.0 → 21.19.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.
@@ -53,8 +53,8 @@ async function main() {
53
53
  // }
54
54
  // ]
55
55
  // }
56
- }
57
- // { identifier: 1 }
56
+ },
57
+ { project: 1 }
58
58
  );
59
59
  console.log(offers.map((offer) => {
60
60
  return `${offer.project?.id} ${offer.id} ${offer.parentOffer?.id} ${offer.identifier} ${offer.name?.ja}`;
@@ -59,15 +59,6 @@ export declare class MongoRepository {
59
59
  };
60
60
  };
61
61
  }): Promise<void>;
62
- /**
63
- * サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
64
- */
65
- /**
66
- * カタログに属するサブカタログを全て除外する
67
- */
68
- /**
69
- * サブカタログに属するサブカタログを全て除外する
70
- */
71
62
  deleteById(params: {
72
63
  project: {
73
64
  id: string;
@@ -36,7 +36,8 @@ class MongoRepository {
36
36
  if (typeof idEq === 'string') {
37
37
  matchStages.push({
38
38
  $match: {
39
- 'offers.id': { $eq: idEq }
39
+ // 'offers.id': { $eq: idEq }
40
+ _id: { $eq: idEq } // _idに変更(2023-12-22~)
40
41
  }
41
42
  });
42
43
  }
@@ -44,9 +45,8 @@ class MongoRepository {
44
45
  if (Array.isArray(idIn)) {
45
46
  matchStages.push({
46
47
  $match: {
47
- 'offers.id': {
48
- $in: idIn
49
- }
48
+ // 'offers.id': { $in: idIn }
49
+ _id: { $in: idIn } // _idに変更(2023-12-22~)
50
50
  }
51
51
  });
52
52
  }
@@ -533,28 +533,6 @@ class MongoRepository {
533
533
  })
534
534
  .exec();
535
535
  debug('result', result);
536
- // offersにもpush(ひとまず廃止)
537
- // result = await this.aggregateOfferModel.updateMany(
538
- // {
539
- // 'project.id': { $eq: params.project.id },
540
- // _id: { $in: params.id.$in }
541
- // },
542
- // {
543
- // $push: {
544
- // 'offers.$[offer].includedInDataCatalog': {
545
- // $each: newIncludedInDataCatalogs
546
- // }
547
- // }
548
- // },
549
- // {
550
- // // includedInDataCatalogのユニークネスを保証する
551
- // arrayFilters: [
552
- // { 'offer.includedInDataCatalog.id': { $nin: pushIncludedInDataCatalogIds } }
553
- // ]
554
- // }
555
- // )
556
- // .exec();
557
- // debug('result', result);
558
536
  });
559
537
  }
560
538
  /**
@@ -575,202 +553,6 @@ class MongoRepository {
575
553
  .exec();
576
554
  });
577
555
  }
578
- // public async pushIncludedInOfferCatalogItem(params: {
579
- // project: { id: string };
580
- // id: { $in: string[] };
581
- // $push: {
582
- // includedInOfferCatalogItem: {
583
- // /**
584
- // * サブカタログID
585
- // */
586
- // id: { $eq: string };
587
- // includedInDataCatalog: {
588
- // /**
589
- // * カタログID
590
- // */
591
- // id: { $eq: string };
592
- // };
593
- // };
594
- // };
595
- // }): Promise<void> {
596
- // if (!Array.isArray(params.id.$in) || params.id.$in.length === 0) {
597
- // return;
598
- // }
599
- // const newIncludedInOfferCatalogItem: {
600
- // /**
601
- // * サブカタログID
602
- // */
603
- // id: string;
604
- // typeOf: 'OfferCatalog';
605
- // includedInDataCatalog: {
606
- // /**
607
- // * カタログID
608
- // */
609
- // id: string;
610
- // typeOf: 'OfferCatalog';
611
- // };
612
- // } = {
613
- // id: params.$push.includedInOfferCatalogItem.id.$eq,
614
- // typeOf: 'OfferCatalog',
615
- // includedInDataCatalog: { id: params.$push.includedInOfferCatalogItem.includedInDataCatalog.id.$eq, typeOf: 'OfferCatalog' }
616
- // };
617
- // const result = await this.aggregateOfferModel.updateMany(
618
- // {
619
- // 'project.id': { $eq: params.project.id },
620
- // _id: { $in: params.id.$in }
621
- // },
622
- // {
623
- // // newIncludedInOfferCatalogItemsのユニークネスを保証する
624
- // $addToSet: { 'offers.$[].includedInOfferCatalogItem': newIncludedInOfferCatalogItem }
625
- // }
626
- // )
627
- // .exec();
628
- // debug('result', result);
629
- // }
630
- /**
631
- * サブカタログを含み、かつ、新しいカタログに含まれない集計オファーからサブカタログを除外
632
- */
633
- // public async pullIncludedInOfferCatalogItem(params: {
634
- // project: { id: string };
635
- // id?: { $nin?: string[] };
636
- // $pull: {
637
- // includedInOfferCatalogItem: {
638
- // $elemMatch: {
639
- // /**
640
- // * サブカタログID
641
- // */
642
- // id: { $eq: string };
643
- // includedInDataCatalog: {
644
- // /**
645
- // * カタログID
646
- // */
647
- // id: { $eq: string };
648
- // };
649
- // };
650
- // };
651
- // };
652
- // }) {
653
- // const idNin = params.id?.$nin;
654
- // await this.aggregateOfferModel.updateMany(
655
- // {
656
- // 'project.id': { $eq: params.project.id },
657
- // 'offers.includedInOfferCatalogItem': {
658
- // $elemMatch: {
659
- // id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
660
- // 'includedInDataCatalog.id': {
661
- // $exists: true,
662
- // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
663
- // }
664
- // }
665
- // },
666
- // ...(Array.isArray(idNin)) ? { _id: { $nin: idNin } } : undefined
667
- // },
668
- // {
669
- // $pull: {
670
- // 'offers.$[].includedInOfferCatalogItem': {
671
- // id: { $exists: true, $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq },
672
- // 'includedInDataCatalog.id': {
673
- // $exists: true,
674
- // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
675
- // }
676
- // }
677
- // }
678
- // }
679
- // )
680
- // .exec();
681
- // }
682
- /**
683
- * カタログに属するサブカタログを全て除外する
684
- */
685
- // public async pullIncludedInOfferCatalogItemByCatalogId(params: {
686
- // project: { id: string };
687
- // $pull: {
688
- // includedInOfferCatalogItem: {
689
- // $elemMatch: {
690
- // /**
691
- // * サブカタログID除外リスト
692
- // */
693
- // id?: { $nin: string[] };
694
- // includedInDataCatalog: {
695
- // /**
696
- // * カタログID
697
- // */
698
- // id: { $eq: string };
699
- // };
700
- // };
701
- // };
702
- // };
703
- // }) {
704
- // const offerCatalogItemIdNin = params.$pull.includedInOfferCatalogItem.$elemMatch.id?.$nin;
705
- // await this.aggregateOfferModel.updateMany(
706
- // {
707
- // 'project.id': { $eq: params.project.id },
708
- // 'offers.includedInOfferCatalogItem': {
709
- // $elemMatch: {
710
- // 'includedInDataCatalog.id': {
711
- // $exists: true,
712
- // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
713
- // }
714
- // }
715
- // }
716
- // },
717
- // {
718
- // $pull: {
719
- // 'offers.$[].includedInOfferCatalogItem': {
720
- // 'includedInDataCatalog.id': {
721
- // $exists: true,
722
- // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.includedInDataCatalog.id.$eq
723
- // },
724
- // ...(Array.isArray(offerCatalogItemIdNin))
725
- // ? { id: { $nin: offerCatalogItemIdNin } } // // 指定サブカタログを除外する
726
- // : undefined
727
- // }
728
- // }
729
- // }
730
- // )
731
- // .exec();
732
- // }
733
- /**
734
- * サブカタログに属するサブカタログを全て除外する
735
- */
736
- // public async pullIncludedInOfferCatalogItemByCatalogItemId(params: {
737
- // project: { id: string };
738
- // $pull: {
739
- // includedInOfferCatalogItem: {
740
- // $elemMatch: {
741
- // /**
742
- // * サブカタログID
743
- // */
744
- // id: { $eq: string };
745
- // };
746
- // };
747
- // };
748
- // }) {
749
- // await this.aggregateOfferModel.updateMany(
750
- // {
751
- // 'project.id': { $eq: params.project.id },
752
- // 'offers.includedInOfferCatalogItem': {
753
- // $elemMatch: {
754
- // id: {
755
- // $exists: true,
756
- // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
757
- // }
758
- // }
759
- // }
760
- // },
761
- // {
762
- // $pull: {
763
- // 'offers.$[].includedInOfferCatalogItem': {
764
- // id: {
765
- // $exists: true,
766
- // $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
767
- // }
768
- // }
769
- // }
770
- // }
771
- // )
772
- // .exec();
773
- // }
774
556
  deleteById(params) {
775
557
  return __awaiter(this, void 0, void 0, function* () {
776
558
  yield this.aggregateOfferModel.findOneAndRemove({
@@ -74,13 +74,15 @@ class MongoRepository {
74
74
  const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
75
75
  if (typeof idEq === 'string') {
76
76
  matchStages.push({
77
- $match: { 'offers.id': { $eq: idEq } }
77
+ // $match: { 'offers.id': { $eq: idEq } }
78
+ $match: { _id: { $eq: idEq } } // _idに変更(2023-12-22~)
78
79
  });
79
80
  }
80
81
  const idIn = (_h = params.id) === null || _h === void 0 ? void 0 : _h.$in;
81
82
  if (Array.isArray(idIn)) {
82
83
  matchStages.push({
83
- $match: { 'offers.id': { $in: idIn } }
84
+ // $match: { 'offers.id': { $in: idIn } }
85
+ $match: { _id: { $in: idIn } } // _idに変更(2023-12-22~)
84
86
  });
85
87
  }
86
88
  const identifierEq = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
@@ -468,7 +470,12 @@ class MongoRepository {
468
470
  positiveProjectionFields.forEach((field) => {
469
471
  // idは上書きしない(2023-12-14~)
470
472
  if (field !== 'id') {
471
- projectStage[field] = `$offers.${field}`;
473
+ if (field === 'project') {
474
+ projectStage[field] = `$project`;
475
+ }
476
+ else {
477
+ projectStage[field] = `$offers.${field}`;
478
+ }
472
479
  }
473
480
  });
474
481
  }
@@ -517,7 +524,10 @@ class MongoRepository {
517
524
  }
518
525
  // 解釈を集計オファーIDに変更する必要がある(2023-09-11~)
519
526
  // 単価オファーIDリスト→集計オファーIDに変換→カタログ条件にセット
520
- const aggregateOfferIds = yield this.aggregateOfferModel.distinct('_id', { 'offers.id': { $in: params.ids } })
527
+ const aggregateOfferIds = yield this.aggregateOfferModel.distinct('_id',
528
+ // { 'offers.id': { $in: params.ids } }
529
+ { _id: { $in: params.ids } } // _idに変更(2023-12-22~)
530
+ )
521
531
  .exec();
522
532
  if (aggregateOfferIds.length === 0) {
523
533
  throw new factory.errors.NotFound(factory.offerType.AggregateOffer);
@@ -793,16 +803,21 @@ class MongoRepository {
793
803
  // 上書き禁止属性を除外
794
804
  const { id, identifier, project, typeOf } = paramsWithoutUnset, updateFields = __rest(paramsWithoutUnset, ["id", "identifier", "project", "typeOf"]);
795
805
  savedUnitPriceOffer = Object.assign(Object.assign({}, updateFields), { id: originalUnitPriceOffer.id, identifier: originalUnitPriceOffer.identifier, project: originalUnitPriceOffer.project, typeOf: originalUnitPriceOffer.typeOf });
796
- doc = yield this.aggregateOfferModel.findOneAndUpdate({ 'offers.id': params.id }, {
806
+ doc = yield this.aggregateOfferModel.findOneAndUpdate(
807
+ // { 'offers.id': params.id },
808
+ { _id: params.id }, // _idに変更(2023-12-22~)
809
+ {
797
810
  $set: {
798
- 'offers.$[offer]': savedUnitPriceOffer
811
+ // 'offers.$[offer]': savedUnitPriceOffer
812
+ 'offers.0': savedUnitPriceOffer // _idに変更(2023-12-22~)
799
813
  }
800
814
  }, {
801
815
  upsert: false,
802
- new: true,
803
- arrayFilters: [
804
- { 'offer.id': { $eq: params.id } }
805
- ]
816
+ new: true
817
+ // _idに変更(2023-12-22~)
818
+ // arrayFilters: [
819
+ // { 'offer.id': { $eq: params.id } }
820
+ // ]
806
821
  })
807
822
  .exec();
808
823
  }
package/package.json CHANGED
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "21.18.0"
118
+ "version": "21.19.0-alpha.0"
119
119
  }