@chevre/domain 25.2.0-alpha.42 → 25.2.0-alpha.44

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.
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import type { Connection } from 'mongoose';
3
- import type { RedisClientType } from 'redis';
3
+ import type { createClient } from 'redis';
4
4
  import { factory } from '../factory';
5
5
  interface IExecuteSettings {
6
6
  /**
@@ -60,6 +60,7 @@ type IChangedTask = IReadyTask | IRunningTask | IRunningTaskByName | IExecutedTa
60
60
  type IOperationExecute<T> = (settings: IExecuteSettings) => Promise<T>;
61
61
  type INextFunction = (task: IExecutedTask) => IOperationExecute<void>;
62
62
  type IOnTaskStatusChangedListener = (task: IChangedTask, next?: INextFunction) => void;
63
+ type RedisClientType = ReturnType<typeof createClient>;
63
64
  /**
64
65
  * タスクイベントエミッター
65
66
  */
@@ -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
- search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
15
+ findAggregateOffers(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<Pick<factory.aggregateOffer.IAggregateOffer, 'id' | 'offers' | 'typeOf'>[]>;
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 {};
@@ -374,11 +374,11 @@ class AggregateOfferRepo {
374
374
  _id: 0,
375
375
  id: '$_id',
376
376
  typeOf: '$typeOf',
377
- project: '$project',
378
377
  offers: [{ $first: '$offers' }],
379
- highPrice: { $max: '$offers.priceSpecification.price' },
380
- lowPrice: { $min: '$offers.priceSpecification.price' },
381
- offerCount: { $size: '$offers' }
378
+ // project: '$project', // discontinue(2026-07-24~)
379
+ // highPrice: { $max: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
380
+ // lowPrice: { $min: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
381
+ // offerCount: { $size: '$offers' } // offers.length:1に限定につき廃止(2026-07-24~)
382
382
  };
383
383
  const positiveProjectionFields = Object.keys(params)
384
384
  .filter((key) => params[key] !== 0);
@@ -389,11 +389,10 @@ class AggregateOfferRepo {
389
389
  _id: 0,
390
390
  id: '$_id',
391
391
  typeOf: '$typeOf',
392
- project: '$project',
393
- // offers: [{ $first: '$offers' }],
394
- highPrice: { $max: '$offers.priceSpecification.price' },
395
- lowPrice: { $min: '$offers.priceSpecification.price' },
396
- offerCount: { $size: '$offers' }
392
+ // project: '$project', // discontinue(2026-07-24~)
393
+ // highPrice: { $max: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
394
+ // lowPrice: { $min: '$offers.priceSpecification.price' }, // offers.length:1に限定につき廃止(2026-07-24~)
395
+ // offerCount: { $size: '$offers' } // offers.length:1に限定につき廃止(2026-07-24~)
397
396
  };
398
397
  const offersProjection = {};
399
398
  positiveProjectionFields.forEach((field) => {
@@ -410,7 +409,7 @@ class AggregateOfferRepo {
410
409
  }
411
410
  return projectStage;
412
411
  }
413
- async search(params, projection) {
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
- aggregate.limit(params.limit * page)
440
- .skip(params.limit * (page - 1));
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
- // const unitPriceOffers = <Pick<factory.unitPriceOffer.IUnitPriceOffer, 'id' | 'identifier' | 'project' | 'typeOf'>[]>
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;
@@ -1,5 +1,6 @@
1
- import type { RedisClientType } from 'redis';
1
+ import type { createClient } from 'redis';
2
2
  import { AbstractConcurrentLockRepo, ILockParams, IUnlockParams } from './concurrentLockAbstract';
3
+ type RedisClientType = ReturnType<typeof createClient>;
3
4
  /**
4
5
  * 同時実行ロックリポジトリ
5
6
  */
@@ -12,3 +13,4 @@ export declare class ConcurrentLockRepo implements AbstractConcurrentLockRepo {
12
13
  lock(params: ILockParams): Promise<void>;
13
14
  unlock(params: IUnlockParams): Promise<void>;
14
15
  }
16
+ export {};
@@ -1,9 +1,10 @@
1
1
  import type { COA } from '@motionpicture/coa-service';
2
- import type { RedisClientType } from 'redis';
2
+ import type { createClient } from 'redis';
3
3
  interface IOptions {
4
4
  scope: string;
5
5
  expireInSeconds: number;
6
6
  }
7
+ type RedisClientType = ReturnType<typeof createClient>;
7
8
  /**
8
9
  * 認証情報リポジトリ
9
10
  */
@@ -128,7 +128,7 @@ declare abstract class OfferInCatalogReadOnlyRepo {
128
128
  */
129
129
  id: string;
130
130
  }[]>;
131
- abstract count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
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
- count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
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 count(params) {
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
- $unwind: { path: '$offers' }
378
- },
376
+ // // offers.length:1の前提であるため、unwindは不要(2026-07-23~)
377
+ // {
378
+ // $unwind: { path: '$offers' }
379
+ // },
379
380
  ...matchStages,
380
381
  {
381
382
  $count: 'offerCount'
@@ -1,5 +1,5 @@
1
1
  import { JwtPayload } from 'jsonwebtoken';
2
- import type { RedisClientType } from 'redis';
2
+ import type { createClient } from 'redis';
3
3
  import { factory } from '../factory';
4
4
  import { IPassportValidator } from '../factory/transaction';
5
5
  export type IVerifiedPassport = factory.waiter.passport.IPassport & {
@@ -20,6 +20,7 @@ interface IOptions {
20
20
  secret: string;
21
21
  passportValidator?: IPassportValidator;
22
22
  }
23
+ type RedisClientType = ReturnType<typeof createClient>;
23
24
  /**
24
25
  * 取引許可証リポジトリ
25
26
  */
@@ -37,8 +37,8 @@ export declare class PriceSpecificationRepo {
37
37
  };
38
38
  }): Promise<void>;
39
39
  getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & (({
40
- project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
41
40
  name?: (string | import("@chevre/factory/lib/chevre/multilingualString").IMultilingualString) | undefined;
41
+ project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
42
42
  price: number;
43
43
  priceCurrency: factory.priceCurrency;
44
44
  typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification;
@@ -53,8 +53,8 @@ export declare class PriceSpecificationRepo {
53
53
  } & {
54
54
  __v: number;
55
55
  }) | ({
56
- project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
57
56
  name?: (string | import("@chevre/factory/lib/chevre/multilingualString").IMultilingualString) | undefined;
57
+ project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
58
58
  price: number;
59
59
  priceCurrency: factory.priceCurrency;
60
60
  typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
@@ -70,8 +70,8 @@ export declare class PriceSpecificationRepo {
70
70
  } & {
71
71
  __v: number;
72
72
  })), import("mongoose").QueryOptions<IDocType>, (import("mongoose").Document<unknown, Record<string, never>, IDocType, import("./mongoose/virtuals").IVirtuals, {}> & (({
73
- project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
74
73
  name?: (string | import("@chevre/factory/lib/chevre/multilingualString").IMultilingualString) | undefined;
74
+ project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
75
75
  price: number;
76
76
  priceCurrency: factory.priceCurrency;
77
77
  typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification;
@@ -86,8 +86,8 @@ export declare class PriceSpecificationRepo {
86
86
  } & {
87
87
  __v: number;
88
88
  }) | ({
89
- project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
90
89
  name?: (string | import("@chevre/factory/lib/chevre/multilingualString").IMultilingualString) | undefined;
90
+ project?: Pick<factory.project.IProject, "id" | "typeOf"> | undefined;
91
91
  price: number;
92
92
  priceCurrency: factory.priceCurrency;
93
93
  typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification;
@@ -1,5 +1,6 @@
1
- import { RedisClientType } from 'redis';
1
+ import type { createClient } from 'redis';
2
2
  import { factory } from '../../factory';
3
+ type RedisClientType = ReturnType<typeof createClient>;
3
4
  /**
4
5
  * レート制限キーインターフェース
5
6
  */
@@ -34,3 +35,4 @@ export declare class OfferRateLimitRepo {
34
35
  unlock(params: IRateLimitKey): Promise<void>;
35
36
  getHolder(ratelimitKey: IRateLimitKey): Promise<string | null>;
36
37
  }
38
+ export {};
@@ -1,4 +1,4 @@
1
- import type { RedisClientType } from 'redis';
1
+ import type { createClient } from 'redis';
2
2
  import { factory } from '../factory';
3
3
  interface IProcessKey {
4
4
  typeOf: factory.transactionType;
@@ -13,6 +13,7 @@ interface IProcessKey {
13
13
  interface IOptions {
14
14
  lockExpiresInSeconds: number;
15
15
  }
16
+ type RedisClientType = ReturnType<typeof createClient>;
16
17
  /**
17
18
  * 取引プロセスリポジトリ
18
19
  */
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.42"
91
+ "version": "25.2.0-alpha.44"
92
92
  }