@chevre/domain 21.9.0-alpha.1 → 21.9.0-alpha.2

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.
@@ -14,7 +14,8 @@ 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
21
  useIncludeInDataCatalog: true
@@ -0,0 +1,89 @@
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
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
65
+ typeOf: string;
66
+ additionalProperty: any[];
67
+ identifier: string;
68
+ itemListElement: any[];
69
+ name?: any;
70
+ project?: any;
71
+ alternateName?: any;
72
+ description?: any;
73
+ itemOffered?: any;
74
+ dateSynced?: Date | undefined;
75
+ }>> & Omit<import("mongoose").FlatRecord<{
76
+ typeOf: string;
77
+ additionalProperty: any[];
78
+ identifier: string;
79
+ itemListElement: any[];
80
+ name?: any;
81
+ project?: any;
82
+ alternateName?: any;
83
+ description?: any;
84
+ itemOffered?: any;
85
+ dateSynced?: Date | undefined;
86
+ }> & {
87
+ _id: import("mongoose").Types.ObjectId;
88
+ }, never>>;
89
+ 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
+ // _id: String,
14
+ identifier: {
15
+ type: String,
16
+ required: true
17
+ },
18
+ name: mongoose_1.SchemaTypes.Mixed,
19
+ description: mongoose_1.SchemaTypes.Mixed,
20
+ alternateName: mongoose_1.SchemaTypes.Mixed,
21
+ typeOf: {
22
+ type: String,
23
+ required: true
24
+ },
25
+ itemListElement: [mongoose_1.SchemaTypes.Mixed],
26
+ itemOffered: mongoose_1.SchemaTypes.Mixed,
27
+ additionalProperty: [mongoose_1.SchemaTypes.Mixed],
28
+ dateSynced: Date
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,6 +77,7 @@ 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;
@@ -25,6 +25,7 @@ const uniqid = require("uniqid");
25
25
  const factory = require("../factory");
26
26
  const aggregateOffer_1 = require("./mongoose/schemas/aggregateOffer");
27
27
  const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
28
+ const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
28
29
  const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
29
30
  /**
30
31
  * 単価オファーリポジトリ
@@ -33,6 +34,7 @@ class MongoRepository {
33
34
  constructor(connection) {
34
35
  this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, aggregateOffer_1.schema);
35
36
  this.offerCatalogModel = connection.model(offerCatalog_1.modelName, offerCatalog_1.schema);
37
+ this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, offerCatalogItem_1.schema);
36
38
  }
37
39
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
38
40
  static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
@@ -442,7 +444,8 @@ class MongoRepository {
442
444
  searchAllByOfferCatalogId(params) {
443
445
  return __awaiter(this, void 0, void 0, function* () {
444
446
  const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
445
- id: params.subOfferCatalog.id
447
+ id: params.subOfferCatalog.id,
448
+ isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
446
449
  });
447
450
  let offers = [];
448
451
  if (sortedOfferIds.length > 0) {
@@ -470,7 +473,7 @@ class MongoRepository {
470
473
  .exec();
471
474
  aggregateOfferIds = searchDistinctAggregateOfferIdsResult;
472
475
  }
473
- const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog(Object.assign({ id: params.subOfferCatalog.id }, (Array.isArray(aggregateOfferIds)) ? { itemListElementIds: aggregateOfferIds } : undefined));
476
+ const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog(Object.assign({ id: params.subOfferCatalog.id, isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem }, (Array.isArray(aggregateOfferIds)) ? { itemListElementIds: aggregateOfferIds } : undefined));
474
477
  let offers = [];
475
478
  if (sortedOfferIds.length > 0) {
476
479
  const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
@@ -506,14 +509,15 @@ class MongoRepository {
506
509
  var _a;
507
510
  return __awaiter(this, void 0, void 0, function* () {
508
511
  const sortedOfferIds = yield this.searchAggregateOfferIdsBySubOfferCatalog({
509
- id: params.subOfferCatalog.id
512
+ id: params.subOfferCatalog.id,
513
+ isOfferCatalogItem: params.subOfferCatalog.isOfferCatalogItem
510
514
  });
511
515
  let offers = [];
512
516
  if (sortedOfferIds.length > 0) {
513
517
  const searchOffersConditions = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.useIncludeInDataCatalog)
514
518
  ? { includedInDataCatalog: { id: { $in: [params.subOfferCatalog.id] } } }
515
519
  : { parentOffer: { id: { $in: sortedOfferIds } } }), (typeof ((_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id) === 'string')
516
- ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } }
520
+ ? { availableAtOrFrom: { id: { $eq: params.availableAtOrFrom.id } } } // store.idでのフィルターをmongoで処理(2023-01-27~)
517
521
  : undefined), { priceSpecification: {
518
522
  appliesToMovieTicket: Object.assign(Object.assign({}, (Array.isArray(params.unacceptedPaymentMethod) && params.unacceptedPaymentMethod.length > 0)
519
523
  ? {
@@ -800,17 +804,33 @@ class MongoRepository {
800
804
  if (Array.isArray(params.itemListElementIds)) {
801
805
  matchStages.push({ $match: { 'itemListElement.id': { $exists: true, $in: params.itemListElementIds } } });
802
806
  }
803
- const itemListElements = yield this.offerCatalogModel.aggregate([
804
- { $unwind: '$itemListElement' },
805
- ...matchStages,
806
- {
807
- $project: {
808
- _id: 0,
809
- id: '$itemListElement.id'
807
+ let itemListElements;
808
+ if (params.isOfferCatalogItem) {
809
+ itemListElements = yield this.offerCatalogItemModel.aggregate([
810
+ { $unwind: '$itemListElement' },
811
+ ...matchStages,
812
+ {
813
+ $project: {
814
+ _id: 0,
815
+ id: '$itemListElement.id'
816
+ }
810
817
  }
811
- }
812
- ])
813
- .exec();
818
+ ])
819
+ .exec();
820
+ }
821
+ else {
822
+ itemListElements = yield this.offerCatalogModel.aggregate([
823
+ { $unwind: '$itemListElement' },
824
+ ...matchStages,
825
+ {
826
+ $project: {
827
+ _id: 0,
828
+ id: '$itemListElement.id'
829
+ }
830
+ }
831
+ ])
832
+ .exec();
833
+ }
814
834
  return (Array.isArray(itemListElements))
815
835
  ? itemListElements.map((element) => element.id)
816
836
  : [];
@@ -85,7 +85,6 @@ export declare class MongoRepository {
85
85
  /**
86
86
  * 強制的に親カタログのみ検索する
87
87
  */
88
- searchParentCatalogsForcibly(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
89
88
  findItemListElementById(params: {
90
89
  id: string;
91
90
  project: {
@@ -285,11 +285,17 @@ class MongoRepository {
285
285
  /**
286
286
  * 強制的に親カタログのみ検索する
287
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
- }
288
+ // public async searchParentCatalogsForcibly(
289
+ // params: factory.offerCatalog.ISearchConditions
290
+ // ): Promise<IAggregatedOfferCatalog[]> {
291
+ // return this.search({
292
+ // ...params,
293
+ // itemListElement: {
294
+ // ...params.itemListElement,
295
+ // typeOf: { $eq: factory.offerType.Offer }
296
+ // }
297
+ // });
298
+ // }
293
299
  findItemListElementById(params) {
294
300
  return __awaiter(this, void 0, void 0, function* () {
295
301
  const doc = yield this.offerCatalogModel.findOne({
@@ -0,0 +1,32 @@
1
+ import { Connection } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'project' | 'typeOf' | 'identifier' | 'itemOffered' | 'additionalProperty'> & {
4
+ numberOfItems?: number;
5
+ itemListElementTypeOf: 'OfferCatalog';
6
+ };
7
+ /**
8
+ * オファーカタログアイテムリポジトリ
9
+ */
10
+ export declare class MongoRepository {
11
+ private readonly offerCatalogItemModel;
12
+ constructor(connection: Connection);
13
+ static CREATE_MONGO_CONDITIONS(params: factory.offerCatalog.ISearchConditions): any[];
14
+ save(params: factory.offerCatalog.IOfferCatalog): Promise<factory.offerCatalog.IOfferCatalog>;
15
+ /**
16
+ * 同期日時を更新する
17
+ */
18
+ updateDateSynced(params: {
19
+ id: string;
20
+ dateSynced: Date;
21
+ }): Promise<void>;
22
+ search(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
23
+ findItemListElementById(params: {
24
+ id: string;
25
+ project: {
26
+ id: string;
27
+ };
28
+ }): Promise<Pick<factory.offerCatalog.IOfferCatalog, 'itemListElement'>>;
29
+ deleteById(params: {
30
+ id: string;
31
+ }): Promise<void>;
32
+ }
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.MongoRepository = void 0;
24
+ const factory = require("../factory");
25
+ const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
26
+ /**
27
+ * オファーカタログアイテムリポジトリ
28
+ */
29
+ class MongoRepository {
30
+ constructor(connection) {
31
+ this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, offerCatalogItem_1.schema);
32
+ }
33
+ // tslint:disable-next-line:max-func-body-length
34
+ static CREATE_MONGO_CONDITIONS(params) {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
36
+ // MongoDB検索条件
37
+ const andConditions = [];
38
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
39
+ if (typeof projectIdEq === 'string') {
40
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
41
+ }
42
+ const idIn = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$in;
43
+ if (Array.isArray(idIn)) {
44
+ andConditions.push({ _id: { $in: idIn } });
45
+ }
46
+ const idRegex = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$regex;
47
+ if (typeof idRegex === 'string' && idRegex.length > 0) {
48
+ andConditions.push({ _id: { $regex: new RegExp(idRegex) } });
49
+ }
50
+ const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
51
+ if (typeof identifierEq === 'string') {
52
+ andConditions.push({
53
+ identifier: { $eq: identifierEq }
54
+ });
55
+ }
56
+ const identifierRegex = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$regex;
57
+ if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
58
+ andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
59
+ }
60
+ if (params.name !== undefined) {
61
+ andConditions.push({
62
+ $or: [
63
+ { 'name.ja': new RegExp(params.name) },
64
+ { 'name.en': new RegExp(params.name) }
65
+ ]
66
+ });
67
+ }
68
+ const itemListElementTypeOfEq = (_h = (_g = params.itemListElement) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
69
+ if (typeof itemListElementTypeOfEq === 'string') {
70
+ andConditions.push({ 'itemListElement.typeOf': { $exists: true, $eq: itemListElementTypeOfEq } });
71
+ }
72
+ const itemListElementIdIn = (_k = (_j = params.itemListElement) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
73
+ if (Array.isArray(itemListElementIdIn)) {
74
+ andConditions.push({ 'itemListElement.id': { $exists: true, $in: itemListElementIdIn } });
75
+ }
76
+ const itemListElementIdNin = (_m = (_l = params.itemListElement) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$nin;
77
+ if (Array.isArray(itemListElementIdNin)) {
78
+ andConditions.push({ 'itemListElement.id': { $nin: itemListElementIdNin } });
79
+ }
80
+ const itemListElementIdAll = (_p = (_o = params.itemListElement) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$all;
81
+ if (Array.isArray(itemListElementIdAll)) {
82
+ andConditions.push({ 'itemListElement.id': { $exists: true, $all: itemListElementIdAll } });
83
+ }
84
+ const itemOfferedTypeOfEq = (_r = (_q = params.itemOffered) === null || _q === void 0 ? void 0 : _q.typeOf) === null || _r === void 0 ? void 0 : _r.$eq;
85
+ if (typeof itemOfferedTypeOfEq === 'string') {
86
+ andConditions.push({ 'itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq } });
87
+ }
88
+ const itemOfferedServiceTypeCodeValueEq = (_u = (_t = (_s = params.itemOffered) === null || _s === void 0 ? void 0 : _s.serviceType) === null || _t === void 0 ? void 0 : _t.codeValue) === null || _u === void 0 ? void 0 : _u.$eq;
89
+ if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
90
+ andConditions.push({ 'itemOffered.serviceType.codeValue': { $exists: true, $eq: itemOfferedServiceTypeCodeValueEq } });
91
+ }
92
+ const additionalPropertyElemMatch = (_v = params.additionalProperty) === null || _v === void 0 ? void 0 : _v.$elemMatch;
93
+ if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
94
+ andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
95
+ }
96
+ return andConditions;
97
+ }
98
+ save(params) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ let doc;
101
+ if (typeof params.id !== 'string' || params.id.length === 0) {
102
+ const { id } = params, creatingDoc = __rest(params, ["id"]);
103
+ doc = yield this.offerCatalogItemModel.create(creatingDoc);
104
+ }
105
+ else {
106
+ const { id, identifier, project, typeOf } = params, updateFields = __rest(params, ["id", "identifier", "project", "typeOf"]);
107
+ doc = yield this.offerCatalogItemModel.findOneAndUpdate({ _id: { $eq: params.id } }, updateFields, { upsert: false, new: true })
108
+ .exec();
109
+ }
110
+ if (doc === null) {
111
+ throw new factory.errors.NotFound(this.offerCatalogItemModel.modelName);
112
+ }
113
+ return doc.toObject();
114
+ });
115
+ }
116
+ /**
117
+ * 同期日時を更新する
118
+ */
119
+ updateDateSynced(params) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ yield this.offerCatalogItemModel.updateOne({ _id: { $eq: params.id } }, { $set: { dateSynced: params.dateSynced } })
122
+ .exec();
123
+ });
124
+ }
125
+ search(params) {
126
+ var _a;
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
129
+ const matchStages = conditions.map((condition) => {
130
+ return { $match: condition };
131
+ });
132
+ const aggregate = this.offerCatalogItemModel.aggregate([
133
+ ...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
134
+ ...matchStages,
135
+ {
136
+ $project: {
137
+ _id: 0,
138
+ name: '$name',
139
+ description: '$description',
140
+ project: '$project',
141
+ typeOf: '$typeOf',
142
+ id: '$_id',
143
+ identifier: '$identifier',
144
+ itemOffered: '$itemOffered',
145
+ additionalProperty: '$additionalProperty',
146
+ numberOfItems: {
147
+ $cond: {
148
+ if: { $isArray: '$itemListElement' },
149
+ then: { $size: '$itemListElement' },
150
+ else: 0
151
+ }
152
+ },
153
+ itemListElementTypeOf: { $first: '$itemListElement.typeOf' }
154
+ }
155
+ }
156
+ ]);
157
+ if (typeof params.limit === 'number' && params.limit > 0) {
158
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
159
+ aggregate.limit(params.limit * page)
160
+ .skip(params.limit * (page - 1));
161
+ }
162
+ return aggregate.exec();
163
+ });
164
+ }
165
+ findItemListElementById(params) {
166
+ return __awaiter(this, void 0, void 0, function* () {
167
+ const doc = yield this.offerCatalogItemModel.findOne({
168
+ 'project.id': { $eq: params.project.id },
169
+ _id: { $eq: params.id }
170
+ }, { 'itemListElement.id': 1 })
171
+ .exec();
172
+ if (doc === null) {
173
+ throw new factory.errors.NotFound(this.offerCatalogItemModel.modelName);
174
+ }
175
+ return doc.toObject();
176
+ });
177
+ }
178
+ deleteById(params) {
179
+ return __awaiter(this, void 0, void 0, function* () {
180
+ yield this.offerCatalogItemModel.findOneAndRemove({ _id: params.id })
181
+ .exec();
182
+ });
183
+ }
184
+ }
185
+ exports.MongoRepository = MongoRepository;
@@ -21,6 +21,7 @@ import { MongoRepository as MemberRepo } from './repo/member';
21
21
  import { MongoRepository as MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
22
22
  import { MongoRepository as OfferRepo } from './repo/offer';
23
23
  import { MongoRepository as OfferCatalogRepo } from './repo/offerCatalog';
24
+ import { MongoRepository as OfferCatalogItemRepo } from './repo/offerCatalogItem';
24
25
  import { MongoRepository as OfferItemConditionRepo } from './repo/offerItemCondition';
25
26
  import { MongoRepository as OrderRepo } from './repo/order';
26
27
  import { MongoRepository as OwnershipInfoRepo } from './repo/ownershipInfo';
@@ -131,6 +132,8 @@ export declare class MerchantReturnPolicy extends MerchantReturnPolicyRepo {
131
132
  }
132
133
  export declare class OfferCatalog extends OfferCatalogRepo {
133
134
  }
135
+ export declare class OfferCatalogItem extends OfferCatalogItemRepo {
136
+ }
134
137
  export declare class OfferItemCondition extends OfferItemConditionRepo {
135
138
  }
136
139
  export declare class Offer extends OfferRepo {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
3
+ exports.rateLimit = exports.Trip = exports.TransactionNumber = exports.Transaction = exports.Telemetry = exports.Task = exports.StockHolder = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.Seller = exports.Role = exports.Reservation = exports.Project = exports.ProductOffer = exports.Product = exports.PriceSpecification = exports.Place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.OwnershipInfo = exports.OrderNumber = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.MerchantReturnPolicy = exports.Member = exports.Event = exports.EmailMessage = exports.Customer = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Code = exports.CategoryCode = exports.AssetTransaction = exports.action = exports.Aggregation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = void 0;
4
4
  // tslint:disable:max-classes-per-file completed-docs
5
5
  /**
6
6
  * リポジトリ
@@ -25,6 +25,7 @@ const member_1 = require("./repo/member");
25
25
  const merchantReturnPolicy_1 = require("./repo/merchantReturnPolicy");
26
26
  const offer_1 = require("./repo/offer");
27
27
  const offerCatalog_1 = require("./repo/offerCatalog");
28
+ const offerCatalogItem_1 = require("./repo/offerCatalogItem");
28
29
  const offerItemCondition_1 = require("./repo/offerItemCondition");
29
30
  const order_1 = require("./repo/order");
30
31
  const ownershipInfo_1 = require("./repo/ownershipInfo");
@@ -157,6 +158,9 @@ exports.MerchantReturnPolicy = MerchantReturnPolicy;
157
158
  class OfferCatalog extends offerCatalog_1.MongoRepository {
158
159
  }
159
160
  exports.OfferCatalog = OfferCatalog;
161
+ class OfferCatalogItem extends offerCatalogItem_1.MongoRepository {
162
+ }
163
+ exports.OfferCatalogItem = OfferCatalogItem;
160
164
  class OfferItemCondition extends offerItemCondition_1.MongoRepository {
161
165
  }
162
166
  exports.OfferItemCondition = OfferItemCondition;
@@ -28,12 +28,14 @@ function findEventOffers(params) {
28
28
  if (typeof offerCatalogId === 'string') {
29
29
  // サブカタログIDを決定
30
30
  let subOfferCatalogId = offerCatalogId;
31
+ let isOfferCatalogItem = false;
31
32
  const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: offerCatalogId });
32
33
  if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
33
34
  subOfferCatalogId = offerCatalogFirstElement.id;
35
+ isOfferCatalogItem = true;
34
36
  }
35
37
  const { offers } = yield repos.offer.searchAllByOfferCatalogId({
36
- subOfferCatalog: { id: subOfferCatalogId }
38
+ subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem }
37
39
  });
38
40
  availableOffers = offers;
39
41
  }
@@ -28,9 +28,11 @@ function searchTicketOffersByItemOffered(params) {
28
28
  }
29
29
  // サブカタログIDを決定
30
30
  let subOfferCatalogId = catalogId;
31
+ let isOfferCatalogItem = false;
31
32
  const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
32
33
  if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
33
34
  subOfferCatalogId = offerCatalogFirstElement.id;
35
+ isOfferCatalogItem = true;
34
36
  }
35
37
  if (params.withSortIndex) {
36
38
  // addSortIndexの場合はid指定廃止(2023-09-13~)
@@ -39,7 +41,7 @@ function searchTicketOffersByItemOffered(params) {
39
41
  }
40
42
  const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
41
43
  // ids: params.ids,
42
- subOfferCatalog: { id: subOfferCatalogId },
44
+ subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
43
45
  availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
44
46
  unacceptedPaymentMethod: params.unacceptedPaymentMethod,
45
47
  excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
@@ -57,7 +59,7 @@ function searchTicketOffersByItemOffered(params) {
57
59
  }
58
60
  const { offers } = yield repos.offer.searchByIdsAndOfferCatalogId({
59
61
  ids: params.ids,
60
- subOfferCatalog: { id: subOfferCatalogId },
62
+ subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
61
63
  availableAtOrFrom: { id: (_e = params.store) === null || _e === void 0 ? void 0 : _e.id },
62
64
  unacceptedPaymentMethod: params.unacceptedPaymentMethod,
63
65
  excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
@@ -27,9 +27,11 @@ function searchProductOffers(params) {
27
27
  }
28
28
  // サブカタログIDを決定
29
29
  let subOfferCatalogId = offerCatalogId;
30
+ let isOfferCatalogItem = false;
30
31
  const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: offerCatalogId });
31
32
  if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
32
33
  subOfferCatalogId = offerCatalogFirstElement.id;
34
+ isOfferCatalogItem = true;
33
35
  }
34
36
  let offers;
35
37
  let sortedOfferIds;
@@ -40,7 +42,7 @@ function searchProductOffers(params) {
40
42
  }
41
43
  const searchByOfferCatalogIdResult = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
42
44
  // ids: params.ids,
43
- subOfferCatalog: { id: subOfferCatalogId },
45
+ subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
44
46
  excludeAppliesToMovieTicket: false,
45
47
  limit: params.limit,
46
48
  page: params.page,
@@ -58,7 +60,7 @@ function searchProductOffers(params) {
58
60
  }
59
61
  const searchByOfferCatalogIdResult = yield repos.offer.searchByIdsAndOfferCatalogId({
60
62
  ids: params.ids,
61
- subOfferCatalog: { id: subOfferCatalogId },
63
+ subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
62
64
  excludeAppliesToMovieTicket: false,
63
65
  limit: params.limit,
64
66
  page: params.page,
package/package.json CHANGED
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.9.0-alpha.1"
120
+ "version": "21.9.0-alpha.2"
121
121
  }