@chevre/domain 21.9.0-alpha.0 → 21.9.0-alpha.10

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.
Files changed (30) hide show
  1. package/example/src/chevre/searchAvaialbleAppliesToMovieTicketByOfferCatalogId.ts +19 -1
  2. package/example/src/chevre/searchEventTicketOffers.ts +1 -0
  3. package/example/src/chevre/{searchOfferCatalogs.ts → searchOfferCatalogItems.ts} +15 -5
  4. package/example/src/chevre/searchOffersByCatalog.ts +9 -2
  5. package/lib/chevre/repo/aggregateOffer.d.ts +10 -3
  6. package/lib/chevre/repo/aggregateOffer.js +9 -0
  7. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.d.ts +92 -0
  8. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +55 -0
  9. package/lib/chevre/repo/offer.d.ts +8 -12
  10. package/lib/chevre/repo/offer.js +96 -56
  11. package/lib/chevre/repo/offerCatalog.d.ts +0 -4
  12. package/lib/chevre/repo/offerCatalog.js +0 -8
  13. package/lib/chevre/repo/offerCatalogItem.d.ts +47 -0
  14. package/lib/chevre/repo/offerCatalogItem.js +231 -0
  15. package/lib/chevre/repository.d.ts +3 -0
  16. package/lib/chevre/repository.js +5 -1
  17. package/lib/chevre/service/aggregation/event/findEventOffers.js +3 -1
  18. package/lib/chevre/service/assetTransaction/reserve.js +1 -0
  19. package/lib/chevre/service/offer/event/authorize.js +1 -0
  20. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +30 -7
  21. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +64 -3
  22. package/lib/chevre/service/offer/event.d.ts +2 -2
  23. package/lib/chevre/service/offer/event.js +2 -1
  24. package/lib/chevre/service/offer/product/searchProductOffers.js +5 -2
  25. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +2 -0
  26. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +23 -7
  27. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.d.ts +3 -0
  28. package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +39 -24
  29. package/lib/chevre/service/task/onResourceUpdated.js +4 -1
  30. package/package.json +3 -3
@@ -6,9 +6,12 @@ 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 eventRepo = new chevre.repository.Event(mongoose.connection);
9
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
12
+ const productRepo = new chevre.repository.Product(mongoose.connection);
10
13
 
11
- const result = await offerRepo.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
14
+ let result = await offerRepo.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
12
15
  limit: 10,
13
16
  page: 1,
14
17
  subOfferCatalog: {
@@ -19,6 +22,21 @@ async function main() {
19
22
  });
20
23
  console.log(result);
21
24
  console.log(result.length);
25
+
26
+ result = await chevre.service.offer.event.searchOfferAppliesToMovieTicket({
27
+ event: { id: 'cllkq475p' },
28
+ onlyValid: true,
29
+ limit: 100,
30
+ page: 1
31
+ // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
32
+ })({
33
+ event: eventRepo,
34
+ offer: offerRepo,
35
+ offerCatalog: offerCatalogRepo,
36
+ product: productRepo
37
+ });
38
+ console.log(result);
39
+ console.log(result.length);
22
40
  }
23
41
 
24
42
  main()
@@ -28,6 +28,7 @@ async function main() {
28
28
  const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
29
29
  event: { id: 'ale6qiedq' },
30
30
  onlyValid: true,
31
+ priceSpecification: {},
31
32
  validateOfferRateLimit: true,
32
33
  addSortIndex: true,
33
34
  useIncludeInDataCatalog: true,
@@ -9,23 +9,33 @@ mongoose.Model.on('index', (...args) => {
9
9
  });
10
10
 
11
11
  async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: true });
12
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
- const catalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
14
+ const catalogItemRepo = new chevre.repository.OfferCatalogItem(mongoose.connection);
15
15
 
16
16
  console.log('searching...');
17
- const catalogs = await catalogRepo.search(
17
+ const catalogs = await catalogItemRepo.search(
18
18
  {
19
19
  project: { id: { $eq: PROJECT_ID } },
20
- identifier: { $eq: '0001' },
21
20
  sort: { identifier: chevre.factory.sortType.Descending },
22
21
  limit: 2,
23
22
  page: 1,
24
23
  itemListElement: { typeOf: { $eq: 'Offer' } }
24
+ // id: { $in: ['xxx'] }
25
25
  }
26
26
  );
27
- console.log('catalogs found', catalogs.map((catalog) => `${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
27
+ console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
28
+ console.log('catalogs found', catalogs.map((catalog) => `${catalog.id} ${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
28
29
  console.log(catalogs.length);
30
+
31
+ const numCatalogs = await catalogItemRepo.count(
32
+ {
33
+ project: { id: { $eq: PROJECT_ID } },
34
+ itemListElement: { typeOf: { $eq: 'Offer' } }
35
+ // id: { $in: ['xxx'] }
36
+ }
37
+ );
38
+ console.log('numCatalogs:', numCatalogs);
29
39
  }
30
40
 
31
41
  main()
@@ -14,10 +14,17 @@ async function main() {
14
14
  page: 1,
15
15
  // ids: ['xx', 'xxx', '1001', '901'],
16
16
  subOfferCatalog: {
17
- id: 'xxx'
17
+ id: '0001',
18
+ isOfferCatalogItem: false
18
19
  },
19
20
  excludeAppliesToMovieTicket: false,
20
- useIncludeInDataCatalog: true
21
+ useIncludeInDataCatalog: false,
22
+ priceSpecification: {
23
+ // appliesToMovieTicket: {
24
+ // serviceOutput: { typeOf: { $eq: 'SurfRock' } },
25
+ // serviceType: { $exists: true }
26
+ // }
27
+ }
21
28
  });
22
29
  // console.log(offers);
23
30
  console.log(offers.map((offer) => {
@@ -11,18 +11,19 @@ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPric
11
11
  id: string;
12
12
  };
13
13
  };
14
+ type ISearchConditions = factory.unitPriceOffer.ISearchConditions;
14
15
  /**
15
16
  * 集計オファーリポジトリ
16
17
  */
17
18
  export declare class MongoRepository {
18
19
  private readonly aggregateOfferModel;
19
20
  constructor(connection: Connection);
20
- static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: factory.unitPriceOffer.ISearchConditions): IMatchStage[];
21
+ static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: ISearchConditions): IMatchStage[];
21
22
  static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
22
23
  [field: string]: AnyExpression;
23
24
  };
24
- count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
25
- search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
25
+ count(params: Omit<ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
26
+ search(params: ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
26
27
  pushIncludedInDataCatalog(params: {
27
28
  project: {
28
29
  id: string;
@@ -58,5 +59,11 @@ export declare class MongoRepository {
58
59
  };
59
60
  };
60
61
  }): Promise<void>;
62
+ deleteById(params: {
63
+ project: {
64
+ id: string;
65
+ };
66
+ id: string;
67
+ }): Promise<void>;
61
68
  }
62
69
  export {};
@@ -558,5 +558,14 @@ class MongoRepository {
558
558
  .exec();
559
559
  });
560
560
  }
561
+ deleteById(params) {
562
+ return __awaiter(this, void 0, void 0, function* () {
563
+ yield this.aggregateOfferModel.findOneAndRemove({
564
+ _id: { $eq: params.id },
565
+ 'project.id': { $eq: params.project.id }
566
+ }, { projection: { _id: 1 } })
567
+ .exec();
568
+ });
569
+ }
561
570
  }
562
571
  exports.MongoRepository = MongoRepository;
@@ -0,0 +1,92 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import { Schema } from 'mongoose';
26
+ declare const modelName = "OfferCatalogItem";
27
+ /**
28
+ * オファーカタログアイテムスキーマ
29
+ */
30
+ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
31
+ collection: string;
32
+ id: true;
33
+ read: string;
34
+ writeConcern: import("mongodb").WriteConcern;
35
+ strict: true;
36
+ strictQuery: false;
37
+ timestamps: {
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ };
41
+ toJSON: {
42
+ getters: false;
43
+ virtuals: false;
44
+ minimize: false;
45
+ versionKey: false;
46
+ };
47
+ toObject: {
48
+ getters: false;
49
+ virtuals: true;
50
+ minimize: false;
51
+ versionKey: false;
52
+ };
53
+ }, {
54
+ typeOf: string;
55
+ additionalProperty: any[];
56
+ identifier: string;
57
+ itemListElement: any[];
58
+ name?: any;
59
+ project?: any;
60
+ alternateName?: any;
61
+ description?: any;
62
+ itemOffered?: any;
63
+ dateSynced?: Date | undefined;
64
+ relatedOffer?: any;
65
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
66
+ typeOf: string;
67
+ additionalProperty: any[];
68
+ identifier: string;
69
+ itemListElement: any[];
70
+ name?: any;
71
+ project?: any;
72
+ alternateName?: any;
73
+ description?: any;
74
+ itemOffered?: any;
75
+ dateSynced?: Date | undefined;
76
+ relatedOffer?: any;
77
+ }>> & Omit<import("mongoose").FlatRecord<{
78
+ typeOf: string;
79
+ additionalProperty: any[];
80
+ identifier: string;
81
+ itemListElement: any[];
82
+ name?: any;
83
+ project?: any;
84
+ alternateName?: any;
85
+ description?: any;
86
+ itemOffered?: any;
87
+ dateSynced?: Date | undefined;
88
+ relatedOffer?: any;
89
+ }> & {
90
+ _id: import("mongoose").Types.ObjectId;
91
+ }, never>>;
92
+ export { modelName, schema };
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.schema = exports.modelName = void 0;
4
+ const mongoose_1 = require("mongoose");
5
+ const writeConcern_1 = require("../writeConcern");
6
+ const modelName = 'OfferCatalogItem';
7
+ exports.modelName = modelName;
8
+ /**
9
+ * オファーカタログアイテムスキーマ
10
+ */
11
+ const schema = new mongoose_1.Schema({
12
+ project: mongoose_1.SchemaTypes.Mixed,
13
+ identifier: {
14
+ type: String,
15
+ required: true
16
+ },
17
+ name: mongoose_1.SchemaTypes.Mixed,
18
+ description: mongoose_1.SchemaTypes.Mixed,
19
+ alternateName: mongoose_1.SchemaTypes.Mixed,
20
+ typeOf: {
21
+ type: String,
22
+ required: true
23
+ },
24
+ itemListElement: [mongoose_1.SchemaTypes.Mixed],
25
+ itemOffered: mongoose_1.SchemaTypes.Mixed,
26
+ additionalProperty: [mongoose_1.SchemaTypes.Mixed],
27
+ dateSynced: Date,
28
+ relatedOffer: mongoose_1.SchemaTypes.Mixed
29
+ }, {
30
+ collection: 'offerCatalogItems',
31
+ id: true,
32
+ read: 'primaryPreferred',
33
+ writeConcern: writeConcern_1.writeConcern,
34
+ strict: true,
35
+ strictQuery: false,
36
+ timestamps: {
37
+ createdAt: 'createdAt',
38
+ updatedAt: 'updatedAt'
39
+ },
40
+ toJSON: {
41
+ getters: false,
42
+ virtuals: false,
43
+ minimize: false,
44
+ versionKey: false
45
+ },
46
+ toObject: {
47
+ getters: false,
48
+ virtuals: true,
49
+ minimize: false,
50
+ versionKey: false
51
+ }
52
+ });
53
+ exports.schema = schema;
54
+ schema.index({ createdAt: 1 }, { name: 'searchByCreatedAt' });
55
+ schema.index({ updatedAt: 1 }, { name: 'searchByUpdatedAt' });
@@ -17,6 +17,7 @@ export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPric
17
17
  export declare class MongoRepository {
18
18
  private readonly aggregateOfferModel;
19
19
  private readonly offerCatalogModel;
20
+ private readonly offerCatalogItemModel;
20
21
  constructor(connection: Connection);
21
22
  static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): IMatchStage[];
22
23
  static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
@@ -32,6 +33,7 @@ export declare class MongoRepository {
32
33
  * サブカタログID
33
34
  */
34
35
  id: string;
36
+ isOfferCatalogItem: boolean;
35
37
  };
36
38
  projection?: IProjection;
37
39
  }): Promise<{
@@ -51,6 +53,7 @@ export declare class MongoRepository {
51
53
  * サブカタログID
52
54
  */
53
55
  id: string;
56
+ isOfferCatalogItem: boolean;
54
57
  };
55
58
  availableAtOrFrom?: {
56
59
  id?: string;
@@ -74,12 +77,17 @@ export declare class MongoRepository {
74
77
  * サブカタログID
75
78
  */
76
79
  id: string;
80
+ isOfferCatalogItem: boolean;
77
81
  };
78
82
  availableAtOrFrom?: {
79
83
  id?: string;
80
84
  };
81
85
  unacceptedPaymentMethod?: string[];
82
86
  excludeAppliesToMovieTicket: boolean;
87
+ /**
88
+ * 適用決済カード条件
89
+ */
90
+ priceSpecification: Pick<factory.unitPriceOffer.IPriceSpecificationSearchConditions, 'appliesToMovieTicket'>;
83
91
  onlyValid?: boolean;
84
92
  useIncludeInDataCatalog: boolean;
85
93
  limit?: number;
@@ -111,12 +119,6 @@ export declare class MongoRepository {
111
119
  limit?: number;
112
120
  page?: number;
113
121
  }): Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
114
- findAggregateOfferById(params: {
115
- project: {
116
- id: string;
117
- };
118
- id: string;
119
- }): Promise<factory.aggregateOffer.IAggregateOffer>;
120
122
  count(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
121
123
  search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<IUnitPriceOfferFromAggregateOffer[]>;
122
124
  save(params: factory.unitPriceOffer.IUnitPriceOffer & {
@@ -144,12 +146,6 @@ export declare class MongoRepository {
144
146
  };
145
147
  };
146
148
  }): Promise<import("mongodb").UpdateResult | undefined>;
147
- deleteById(params: {
148
- project: {
149
- id: string;
150
- };
151
- id: string;
152
- }): Promise<void>;
153
149
  /**
154
150
  * サブカタログから集計オファーIDリストを検索する
155
151
  */
@@ -21,10 +21,12 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.MongoRepository = void 0;
24
+ const mongoose_1 = require("mongoose");
24
25
  const uniqid = require("uniqid");
25
26
  const factory = require("../factory");
26
27
  const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
27
28
  const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
29
+ const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
28
30
  const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
29
31
  /**
30
32
  * 単価オファーリポジトリ
@@ -33,6 +35,7 @@ class MongoRepository {
33
35
  constructor(connection) {
34
36
  this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, aggregateOffer_1.schema);
35
37
  this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
38
+ this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, offerCatalogItem_1.schema);
36
39
  }
37
40
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
38
41
  static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
@@ -442,7 +445,8 @@ class MongoRepository {
442
445
  searchAllByOfferCatalogId(params) {
443
446
  return __awaiter(this, void 0, void 0, function* () {
444
447
  const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
445
- id: params.subOfferCatalog.id
448
+ id: params.subOfferCatalog.id,
449
+ isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
446
450
  });
447
451
  let offers = [];
448
452
  if (sortedOfferIds.length > 0) {
@@ -470,7 +474,7 @@ class MongoRepository {
470
474
  .exec();
471
475
  aggregateOfferIds = searchDistinctAggregateOfferIdsResult;
472
476
  }
473
- const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog(Object.assign({ id: params.subOfferCatalog.id }, (Array.isArray(aggregateOfferIds)) ? { itemListElementIds: aggregateOfferIds } : undefined));
477
+ const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog(Object.assign({ id: params.subOfferCatalog.id, isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem }, (Array.isArray(aggregateOfferIds)) ? { itemListElementIds: aggregateOfferIds } : undefined));
474
478
  let offers = [];
475
479
  if (sortedOfferIds.length > 0) {
476
480
  const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
@@ -503,30 +507,38 @@ class MongoRepository {
503
507
  * カタログ内ソートインデックスはsortedOfferIdsで判断する
504
508
  */
505
509
  searchByOfferCatalogIdWithSortIndex(params) {
506
- var _a;
510
+ var _a, _b, _c, _d, _e, _f, _g, _h;
507
511
  return __awaiter(this, void 0, void 0, function* () {
508
512
  const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
509
- id: params.subOfferCatalog.id
513
+ id: params.subOfferCatalog.id,
514
+ isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
510
515
  });
511
516
  let offers = [];
512
517
  if (sortedOfferIds.length > 0) {
513
- const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.useIncludeInDataCatalog)
518
+ const appliesToMovieTicketServiceOutputTypeOfEq = (_d = (_c = (_b = (_a = params.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket) === null || _b === void 0 ? void 0 : _b.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf) === null || _d === void 0 ? void 0 : _d.$eq;
519
+ const appliesToMovieTicketServiceTypeExists = (_g = (_f = (_e = params.priceSpecification) === null || _e === void 0 ? void 0 : _e.appliesToMovieTicket) === null || _f === void 0 ? void 0 : _f.serviceType) === null || _g === void 0 ? void 0 : _g.$exists;
520
+ // 適用決済カード条件なしのみを検索するかどうか
521
+ const onlyNoAppliesToMovieTicket = params.excludeAppliesToMovieTicket || (appliesToMovieTicketServiceTypeExists === false);
522
+ const onlyAppliesToMovieTicket = !params.excludeAppliesToMovieTicket && (appliesToMovieTicketServiceTypeExists === true);
523
+ const priceSpecificationConditions = {
524
+ appliesToMovieTicket: Object.assign(Object.assign({ serviceOutput: {
525
+ typeOf: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
526
+ // 利用不可決済方法区分条件を追加(2023-02-21~)
527
+ ? { $nin: params.unacceptedPaymentMethod }
528
+ : undefined), (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string')
529
+ ? { $eq: appliesToMovieTicketServiceOutputTypeOfEq }
530
+ : undefined)
531
+ } }, (onlyNoAppliesToMovieTicket)
532
+ ? { serviceType: { $exists: false } }
533
+ : undefined), (onlyAppliesToMovieTicket)
534
+ ? { serviceType: { $exists: true } }
535
+ : undefined)
536
+ };
537
+ const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ priceSpecification: priceSpecificationConditions, onlyValid: params.onlyValid === true }, (params.useIncludeInDataCatalog)
514
538
  ? { includedInDataCatalog: { id: { $in: [params.subOfferCatalog.id] } } }
515
- : { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
516
- ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
517
- : undefined), { priceSpecification: {
518
- appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
519
- ? {
520
- serviceOutput: {
521
- typeOf: { $nin: params.unacceptedPaymentMethod }
522
- }
523
- }
524
- : undefined), (params.excludeAppliesToMovieTicket)
525
- ? {
526
- serviceType: { $exists: false }
527
- }
528
- : undefined)
529
- }, onlyValid: params.onlyValid === true }), (typeof params.limit === 'number' && typeof params.page === 'number')
539
+ : { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_h = params.availableAtOrFrom) === null || _h === void 0 ? void 0 : _h.id) === 'string')
540
+ ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
541
+ : undefined), (typeof params.limit === 'number' && typeof params.page === 'number')
530
542
  // 明示的なソート指定を調整(決して重複しない属性が相応)(2023-09-07~)
531
543
  ? { sort: { identifier: factory.sortType.Ascending } }
532
544
  : undefined), (typeof params.limit === 'number') ? { limit: params.limit } : undefined), (typeof params.page === 'number') ? { page: params.page } : undefined);
@@ -577,23 +589,27 @@ class MongoRepository {
577
589
  return aggregate.exec();
578
590
  });
579
591
  }
580
- findAggregateOfferById(params) {
581
- return __awaiter(this, void 0, void 0, function* () {
582
- const doc = yield this.aggregateOfferModel.findOne({
583
- _id: { $eq: params.id },
584
- 'project.id': { $eq: params.project.id }
585
- }, {
586
- __v: 0,
587
- createdAt: 0,
588
- updatedAt: 0
589
- })
590
- .exec();
591
- if (doc === null) {
592
- throw new factory.errors.NotFound(this.aggregateOfferModel.modelName);
593
- }
594
- return doc.toObject();
595
- });
596
- }
592
+ // public async findAggregateOfferById(params: {
593
+ // project: { id: string };
594
+ // id: string;
595
+ // }): Promise<factory.aggregateOffer.IAggregateOffer> {
596
+ // const doc = await this.aggregateOfferModel.findOne(
597
+ // {
598
+ // _id: { $eq: params.id },
599
+ // 'project.id': { $eq: params.project.id }
600
+ // },
601
+ // {
602
+ // __v: 0,
603
+ // createdAt: 0,
604
+ // updatedAt: 0
605
+ // }
606
+ // )
607
+ // .exec();
608
+ // if (doc === null) {
609
+ // throw new factory.errors.NotFound(this.aggregateOfferModel.modelName);
610
+ // }
611
+ // return doc.toObject();
612
+ // }
597
613
  count(params) {
598
614
  return __awaiter(this, void 0, void 0, function* () {
599
615
  const matchStages = MongoRepository.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
@@ -785,32 +801,56 @@ class MongoRepository {
785
801
  return result;
786
802
  });
787
803
  }
788
- deleteById(params) {
789
- return __awaiter(this, void 0, void 0, function* () {
790
- yield this.aggregateOfferModel.findOneAndRemove({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
791
- .exec();
792
- });
793
- }
804
+ // public async deleteById(params: {
805
+ // project: { id: string };
806
+ // id: string;
807
+ // }) {
808
+ // await this.aggregateOfferModel.findOneAndRemove(
809
+ // { _id: { $eq: params.id } },
810
+ // { projection: { _id: 1 } }
811
+ // )
812
+ // .exec();
813
+ // }
794
814
  /**
795
815
  * サブカタログから集計オファーIDリストを検索する
796
816
  */
797
817
  searchAggregateOfferIdsBySubOfferCatalog(params) {
798
818
  return __awaiter(this, void 0, void 0, function* () {
799
- const matchStages = [{ $match: { _id: { $eq: params.id } } }];
800
- if (Array.isArray(params.itemListElementIds)) {
801
- matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
802
- }
803
- const itemListElements = yield this.offerCatalogModel.aggregate([
804
- { $unwind: '$itemListElement' },
805
- ...matchStages,
806
- {
807
- $project: {
808
- _id: 0,
809
- id: '$itemListElement.id'
819
+ let itemListElements;
820
+ if (params.isOfferCatalogItem) {
821
+ const matchStages = [{ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(params.id) } } }]; // ObjectIdなので注意
822
+ if (Array.isArray(params.itemListElementIds)) {
823
+ matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
824
+ }
825
+ itemListElements = yield this.offerCatalogItemModel.aggregate([
826
+ { $unwind: '$itemListElement' },
827
+ ...matchStages,
828
+ {
829
+ $project: {
830
+ _id: 0,
831
+ id: '$itemListElement.id'
832
+ }
810
833
  }
834
+ ])
835
+ .exec();
836
+ }
837
+ else {
838
+ const matchStages = [{ $match: { _id: { $eq: params.id } } }];
839
+ if (Array.isArray(params.itemListElementIds)) {
840
+ matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
811
841
  }
812
- ])
813
- .exec();
842
+ itemListElements = yield this.offerCatalogModel.aggregate([
843
+ { $unwind: '$itemListElement' },
844
+ ...matchStages,
845
+ {
846
+ $project: {
847
+ _id: 0,
848
+ id: '$itemListElement.id'
849
+ }
850
+ }
851
+ ])
852
+ .exec();
853
+ }
814
854
  return (Array.isArray(itemListElements))
815
855
  ? itemListElements.map((element) => element.id)
816
856
  : [];
@@ -82,10 +82,6 @@ export declare class MongoRepository {
82
82
  };
83
83
  }): Promise<import("mongodb").UpdateResult | undefined>;
84
84
  search(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
85
- /**
86
- * 強制的に親カタログのみ検索する
87
- */
88
- searchParentCatalogsForcibly(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
89
85
  findItemListElementById(params: {
90
86
  id: string;
91
87
  project: {
@@ -282,14 +282,6 @@ class MongoRepository {
282
282
  return aggregate.exec();
283
283
  });
284
284
  }
285
- /**
286
- * 強制的に親カタログのみ検索する
287
- */
288
- searchParentCatalogsForcibly(params) {
289
- return __awaiter(this, void 0, void 0, function* () {
290
- return this.search(Object.assign(Object.assign({}, params), { itemListElement: Object.assign(Object.assign({}, params.itemListElement), { typeOf: { $eq: factory.offerType.Offer } }) }));
291
- });
292
- }
293
285
  findItemListElementById(params) {
294
286
  return __awaiter(this, void 0, void 0, function* () {
295
287
  const doc = yield this.offerCatalogModel.findOne({