@chevre/domain 22.14.0-alpha.15 → 22.14.0-alpha.17

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.
@@ -0,0 +1,36 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import * as factory from '../../../factory';
3
+ interface IProductOffer {
4
+ project: {
5
+ id: string;
6
+ typeOf: factory.organizationType.Project;
7
+ };
8
+ typeOf: factory.offerType.Offer;
9
+ /**
10
+ * プロダクトオファーコード
11
+ */
12
+ identifier: string;
13
+ itemOffered: {
14
+ typeOf: factory.offerType.AggregateOffer;
15
+ /**
16
+ * プロダクトオファーコレクションコード
17
+ */
18
+ identifier: string;
19
+ };
20
+ availability: factory.itemAvailability.InStock | factory.itemAvailability.OutOfStock;
21
+ validFrom: Date;
22
+ validThrough: Date;
23
+ acceptedPaymentMethod?: {
24
+ typeOf: 'PaymentMethod';
25
+ identifier: string;
26
+ };
27
+ validForMemberTier?: Pick<factory.issuer.IMemberProgramTier, 'identifier' | 'typeOf'>;
28
+ }
29
+ type IDocType = IProductOffer;
30
+ type IModel = Model<IDocType>;
31
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
32
+ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
33
+ declare const modelName = "ProductOffer";
34
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
35
+ declare function createSchema(): ISchema;
36
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -3,25 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.modelName = exports.indexes = void 0;
4
4
  exports.createSchema = createSchema;
5
5
  const mongoose_1 = require("mongoose");
6
- const settings_1 = require("../../../../settings");
7
- const writeConcern_1 = require("../../writeConcern");
8
- const modelName = 'Offer.Event';
6
+ const settings_1 = require("../../../settings");
7
+ const writeConcern_1 = require("../writeConcern");
8
+ const modelName = 'ProductOffer';
9
9
  exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
- seller: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
12
  typeOf: { type: String, required: true },
14
13
  identifier: { type: String, required: true },
15
14
  itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
- availableAtOrFrom: { type: mongoose_1.SchemaTypes.Mixed, required: true },
15
+ availability: { type: String, required: true },
17
16
  validFrom: { type: Date, required: true },
18
17
  validThrough: { type: Date, required: true },
19
- validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: true }
18
+ // availableAtOrFrom: { type: SchemaTypes.Mixed, required: false },
19
+ validForMemberTier: { type: mongoose_1.SchemaTypes.Mixed, required: false },
20
+ acceptedPaymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: false }
20
21
  };
21
22
  const schemaOptions = {
22
23
  autoIndex: settings_1.MONGO_AUTO_INDEX,
23
24
  autoCreate: false,
24
- collection: 'offers.event',
25
+ collection: 'productOffers',
25
26
  id: true,
26
27
  read: settings_1.MONGO_READ_PREFERENCE,
27
28
  writeConcern: writeConcern_1.writeConcern,
@@ -46,56 +47,11 @@ const indexes = [
46
47
  [
47
48
  { validFrom: 1 },
48
49
  { name: 'validFrom' }
49
- ],
50
- [
51
- {
52
- 'itemOffered.id': 1,
53
- identifier: 1
54
- },
55
- {
56
- name: 'uniqueByItemOfferedAndIdentifier',
57
- unique: true
58
- }
59
- ],
60
- [
61
- {
62
- 'itemOffered.id': 1,
63
- 'availableAtOrFrom.id': 1,
64
- 'validForMemberTier.identifier': 1
65
- },
66
- {
67
- name: 'uniqueByItemOfferedAndAvailableAt',
68
- unique: true
69
- }
70
- ],
71
- [
72
- { 'project.id': 1, validFrom: 1 },
73
- { name: 'projectId' }
74
- ],
75
- [
76
- { 'seller.id': 1, validFrom: 1 },
77
- { name: 'sellerId' }
78
- ],
79
- [
80
- { identifier: 1, validFrom: 1 },
81
- { name: 'identifier' }
82
- ],
83
- [
84
- { 'itemOffered.id': 1, validFrom: 1 },
85
- { name: 'itemOfferedId' }
86
- ],
87
- [
88
- { 'availableAtOrFrom.id': 1, validFrom: 1 },
89
- { name: 'availableAtOrFromId' }
90
- ],
91
- [
92
- { 'validForMemberTier.identifier': 1, validFrom: 1 },
93
- { name: 'validForMemberTierIdentifier' }
94
50
  ]
95
51
  ];
96
52
  exports.indexes = indexes;
97
53
  /**
98
- * イベントオファー(クライアントごとの有効期間)スキーマ
54
+ * プロダクトオファー(汎用的なオファー設定)スキーマ
99
55
  */
100
56
  let schema;
101
57
  function createSchema() {
@@ -1,77 +1,72 @@
1
- import { Connection } from 'mongoose';
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection, FilterQuery } from 'mongoose';
2
3
  import * as factory from '../factory';
4
+ import { IDocType } from './mongoose/schemas/productOffer';
5
+ export { IDocType as IProductOffer };
6
+ interface ISearchConditions {
7
+ limit?: number;
8
+ page?: number;
9
+ sort?: {
10
+ validFrom?: factory.sortType;
11
+ };
12
+ project?: {
13
+ id?: {
14
+ $eq?: string;
15
+ };
16
+ };
17
+ itemOffered?: {
18
+ identifier?: {
19
+ $eq?: string;
20
+ };
21
+ };
22
+ validForMemberTier?: {
23
+ identifier?: {
24
+ $eq?: string;
25
+ };
26
+ };
27
+ validFrom?: {
28
+ $lte?: Date;
29
+ };
30
+ validThrough?: {
31
+ $gte?: Date;
32
+ };
33
+ }
34
+ export type ISavingOffer = Pick<IDocType, 'identifier' | 'itemOffered' | 'project' | 'typeOf' | 'validFrom' | 'validThrough' | 'availability' | 'validForMemberTier' | 'acceptedPaymentMethod'> & {
35
+ id?: never;
36
+ };
37
+ type IUnset = {
38
+ [key in keyof IDocType]?: 1;
39
+ };
40
+ type IDocWithId = IDocType & {
41
+ id: string;
42
+ };
43
+ type IKeyOfProjection = keyof IDocType;
3
44
  /**
4
45
  * プロダクトオファーリポジトリ
5
46
  */
6
47
  export declare class ProductOfferRepo {
7
- private readonly productModel;
48
+ private readonly productOfferModel;
8
49
  constructor(connection: Connection);
50
+ static CREATE_MONGO_CONDITIONS(params: ISearchConditions): FilterQuery<IDocType>[];
51
+ findProductOffers(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
9
52
  /**
10
- * プロダクトオファー検索
53
+ * オファーコードとオファーコレクションコードをキーにして冪等置換
11
54
  */
12
- search(params: {
13
- limit?: number;
14
- page?: number;
15
- project?: {
16
- id?: {
17
- $eq?: string;
18
- };
19
- };
20
- itemOffered?: {
21
- id?: {
22
- $eq?: string;
23
- };
24
- };
25
- seller?: {
26
- id?: {
27
- $eq?: string;
28
- };
29
- };
30
- }): Promise<(Pick<factory.product.IOffer, 'availabilityEnds' | 'availabilityStarts' | 'seller' | 'validFrom' | 'validThrough'> & {
31
- itemOffered: Pick<factory.product.IProduct, 'id' | 'name' | 'typeOf'>;
32
- })[]>;
33
- create(params: factory.product.IOffer & {
34
- project: {
35
- id: string;
36
- };
37
- itemOffered: {
38
- /**
39
- * プロダクトID
40
- */
41
- id: string;
55
+ upsertOffersByIdentifier(params: {
56
+ $set: Pick<IDocType, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'project' | 'typeOf' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
57
+ id?: never;
42
58
  };
59
+ $unset: IUnset;
60
+ }[], options: {
61
+ /**
62
+ * falseの場合setOnInsertのみ
63
+ * trueの場合setのみ
64
+ */
65
+ update: boolean;
43
66
  }): Promise<{
44
- id: string;
45
- }>;
46
- update(params: factory.product.IOffer & {
47
- project: {
67
+ bulkWriteResult: BulkWriteResult;
68
+ modifiedNotes: {
48
69
  id: string;
49
- };
50
- itemOffered: {
51
- /**
52
- * プロダクトID
53
- */
54
- id: string;
55
- };
56
- }): Promise<{
57
- id: string;
58
- }>;
59
- deleteOne(params: Pick<factory.product.IOffer, 'seller'> & {
60
- project: {
61
- id: string;
62
- };
63
- itemOffered: {
64
- /**
65
- * プロダクトID
66
- */
67
- id: string;
68
- };
69
- }): Promise<{
70
- id: string;
71
- }>;
72
- deleteManyBySellerId(params: Pick<factory.product.IOffer, 'seller'> & {
73
- project: {
74
- id: string;
75
- };
76
- }): Promise<import("mongoose").UpdateWriteOpResult>;
70
+ }[];
71
+ } | void>;
77
72
  }
@@ -10,191 +10,149 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProductOfferRepo = void 0;
13
- const mongoose_1 = require("mongoose");
14
- const product_1 = require("./mongoose/schemas/product");
15
13
  const factory = require("../factory");
16
14
  const settings_1 = require("../settings");
15
+ const productOffer_1 = require("./mongoose/schemas/productOffer");
16
+ const AVAILABLE_PROJECT_FIELDS = [
17
+ 'identifier',
18
+ 'project',
19
+ 'itemOffered',
20
+ 'typeOf',
21
+ 'validFrom',
22
+ 'validThrough',
23
+ 'availability',
24
+ 'acceptedPaymentMethod',
25
+ 'validForMemberTier'
26
+ ];
17
27
  /**
18
28
  * プロダクトオファーリポジトリ
19
29
  */
20
30
  class ProductOfferRepo {
21
31
  constructor(connection) {
22
- this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
32
+ this.productOfferModel = connection.model(productOffer_1.modelName, (0, productOffer_1.createSchema)());
23
33
  }
24
- /**
25
- * プロダクトオファー検索
26
- */
27
- search(params) {
34
+ static CREATE_MONGO_CONDITIONS(params) {
35
+ var _a, _b, _c, _d, _e, _f, _g, _h;
36
+ const andConditions = [];
37
+ // const idIn = params.id?.$in;
38
+ // if (Array.isArray(idIn)) {
39
+ // andConditions.push({ _id: { $in: idIn } });
40
+ // }
41
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
42
+ if (typeof projectIdEq === 'string') {
43
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
44
+ }
45
+ const itemOfferedIdentifierEq = (_d = (_c = params.itemOffered) === null || _c === void 0 ? void 0 : _c.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
46
+ if (typeof itemOfferedIdentifierEq === 'string') {
47
+ andConditions.push({ 'itemOffered.identifier': { $eq: itemOfferedIdentifierEq } });
48
+ }
49
+ const validForMemberTierIdentifierEq = (_f = (_e = params.validForMemberTier) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$eq;
50
+ if (typeof validForMemberTierIdentifierEq === 'string') {
51
+ andConditions.push({ 'validForMemberTier.identifier': { $exists: true, $eq: validForMemberTierIdentifierEq } });
52
+ }
53
+ const validFromLte = (_g = params.validFrom) === null || _g === void 0 ? void 0 : _g.$lte;
54
+ if (validFromLte instanceof Date) {
55
+ andConditions.push({ validFrom: { $lte: validFromLte } });
56
+ }
57
+ const validThroughGte = (_h = params.validThrough) === null || _h === void 0 ? void 0 : _h.$gte;
58
+ if (validThroughGte instanceof Date) {
59
+ andConditions.push({ validThrough: { $gte: validThroughGte } });
60
+ }
61
+ return andConditions;
62
+ }
63
+ findProductOffers(params, inclusion) {
28
64
  return __awaiter(this, void 0, void 0, function* () {
29
- var _a, _b, _c, _d, _e, _f;
30
- const matchStages = [{
31
- $match: {
32
- typeOf: {
33
- $in: [
34
- factory.product.ProductType.MembershipService,
35
- factory.product.ProductType.PaymentCard
36
- ]
37
- }
38
- }
39
- }];
40
- const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
41
- if (typeof projectIdEq === 'string') {
42
- matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
65
+ var _a;
66
+ const conditions = ProductOfferRepo.CREATE_MONGO_CONDITIONS(params);
67
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
68
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
69
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
43
70
  }
44
- const itemOfferedIdEq = (_d = (_c = params.itemOffered) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
45
- if (typeof itemOfferedIdEq === 'string') {
46
- matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(itemOfferedIdEq) } } });
71
+ else {
72
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
47
73
  }
48
- const sellerIdEq = (_f = (_e = params.seller) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
49
- if (typeof sellerIdEq === 'string') {
50
- matchStages.push({ $match: { 'offers.seller.id': { $exists: true, $eq: sellerIdEq } } });
74
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
75
+ const query = this.productOfferModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
76
+ if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
77
+ query.sort({ validFrom: params.sort.validFrom });
51
78
  }
52
- const aggregate = this.productModel.aggregate([
53
- { $sort: { productID: factory.sortType.Ascending } },
54
- {
55
- $unwind: {
56
- path: '$offers'
57
- }
58
- },
59
- ...matchStages,
60
- {
61
- $project: {
62
- _id: 0,
63
- itemOffered: {
64
- id: { $toString: '$_id' },
65
- name: '$name',
66
- typeOf: '$typeOf'
67
- },
68
- availabilityEnds: '$offers.availabilityEnds',
69
- availabilityStarts: '$offers.availabilityStarts',
70
- validFrom: '$offers.validFrom',
71
- validThrough: '$offers.validThrough',
72
- seller: '$offers.seller'
73
- }
74
- }
75
- ]);
76
79
  if (typeof params.limit === 'number' && params.limit > 0) {
77
80
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
78
- aggregate.limit(params.limit * page)
81
+ query.limit(params.limit)
79
82
  .skip(params.limit * (page - 1));
80
83
  }
81
- return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
84
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
85
+ .lean()
82
86
  .exec();
83
87
  });
84
88
  }
85
- create(params) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- var _a;
88
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
89
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
90
- throw new factory.errors.ArgumentNull('seller.id');
91
- }
92
- // プロダクト存在確認
93
- let doc = yield this.productModel.findOne({
94
- 'project.id': { $eq: params.project.id },
95
- _id: { $eq: params.itemOffered.id }
96
- }, { _id: 1 })
97
- .exec();
98
- if (doc === null) {
99
- throw new factory.errors.NotFound('Product');
100
- }
101
- const creatingOffer = {
102
- priceCurrency: factory.priceCurrency.JPY,
103
- availabilityEnds: params.availabilityEnds,
104
- availabilityStarts: params.availabilityStarts,
105
- validFrom: params.validFrom,
106
- validThrough: params.validThrough,
107
- seller: { id: sellerId },
108
- typeOf: factory.offerType.Offer
109
- };
110
- doc = yield this.productModel.findOneAndUpdate({
111
- 'project.id': { $eq: params.project.id },
112
- _id: { $eq: params.itemOffered.id },
113
- 'offers.seller.id': { $ne: sellerId }
114
- }, {
115
- $push: { offers: creatingOffer }
116
- }, {
117
- new: true,
118
- projection: { _id: 1 }
119
- })
120
- .exec();
121
- // 存在しなければプロバイダーID重複
122
- if (doc === null) {
123
- throw new factory.errors.AlreadyInUse('offers.seller', ['id']);
124
- }
125
- return doc.toObject();
126
- });
127
- }
128
- update(params) {
129
- return __awaiter(this, void 0, void 0, function* () {
130
- var _a;
131
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
132
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
133
- throw new factory.errors.ArgumentNull('seller.id');
134
- }
135
- const doc = yield this.productModel.findOneAndUpdate({
136
- 'project.id': { $eq: params.project.id },
137
- _id: { $eq: params.itemOffered.id },
138
- 'offers.seller.id': { $exists: true, $eq: sellerId }
139
- }, Object.assign(Object.assign(Object.assign(Object.assign({}, (params.availabilityEnds instanceof Date)
140
- ? { 'offers.$[offerBySeller].availabilityEnds': params.availabilityEnds }
141
- : undefined), (params.availabilityStarts instanceof Date)
142
- ? { 'offers.$[offerBySeller].availabilityStarts': params.availabilityStarts }
143
- : undefined), (params.validFrom instanceof Date)
144
- ? { 'offers.$[offerBySeller].validFrom': params.validFrom }
145
- : undefined), (params.validThrough instanceof Date)
146
- ? { 'offers.$[offerBySeller].validThrough': params.validThrough }
147
- : undefined), {
148
- new: true,
149
- arrayFilters: [
150
- { 'offerBySeller.seller.id': { $eq: sellerId } }
151
- ],
152
- projection: { _id: 1 }
153
- })
154
- .exec();
155
- if (doc === null) {
156
- throw new factory.errors.NotFound('Product');
157
- }
158
- return doc.toObject();
159
- });
160
- }
161
- deleteOne(params) {
89
+ /**
90
+ * オファーコードとオファーコレクションコードをキーにして冪等置換
91
+ */
92
+ upsertOffersByIdentifier(params, options) {
162
93
  return __awaiter(this, void 0, void 0, function* () {
163
- var _a;
164
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
165
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
166
- throw new factory.errors.ArgumentNull('seller.id');
167
- }
168
- const doc = yield this.productModel.findOneAndUpdate({
169
- 'project.id': { $eq: params.project.id },
170
- _id: { $eq: params.itemOffered.id },
171
- 'offers.seller.id': { $exists: true, $eq: sellerId }
172
- }, {
173
- $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
174
- }, {
175
- projection: { _id: 1 }
176
- })
177
- .exec();
178
- if (doc === null) {
179
- throw new factory.errors.NotFound('Product');
94
+ const { update } = options;
95
+ const bulkWriteOps = [];
96
+ const queryFilters = [];
97
+ if (Array.isArray(params)) {
98
+ params.forEach(({ $set, $unset }) => {
99
+ const { availability, identifier, itemOffered, project, validFrom, validThrough, acceptedPaymentMethod, validForMemberTier } = $set;
100
+ if (typeof identifier !== 'string' || identifier === '') {
101
+ throw new factory.errors.ArgumentNull('identifier');
102
+ }
103
+ if (typeof itemOffered.identifier !== 'string' || itemOffered.identifier === '') {
104
+ throw new factory.errors.ArgumentNull('itemOffered.identifier');
105
+ }
106
+ // リソースのユニークネスを保証するfilter
107
+ const filter = {
108
+ 'project.id': { $eq: project.id },
109
+ 'itemOffered.identifier': { $eq: itemOffered.identifier },
110
+ identifier: { $eq: identifier }
111
+ };
112
+ queryFilters.push({
113
+ 'project.id': { $eq: project.id },
114
+ 'itemOffered.identifier': { $eq: itemOffered.identifier },
115
+ identifier: { $eq: identifier }
116
+ });
117
+ if (update === true) {
118
+ const setFields = Object.assign(Object.assign({ availability,
119
+ validFrom,
120
+ validThrough }, (typeof (acceptedPaymentMethod === null || acceptedPaymentMethod === void 0 ? void 0 : acceptedPaymentMethod.typeOf) === 'string') ? { acceptedPaymentMethod } : undefined), (typeof (validForMemberTier === null || validForMemberTier === void 0 ? void 0 : validForMemberTier.typeOf) === 'string') ? { validForMemberTier } : undefined);
121
+ const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
122
+ const updateOne = {
123
+ filter,
124
+ update: updateFilter,
125
+ upsert: false
126
+ };
127
+ bulkWriteOps.push({ updateOne });
128
+ }
129
+ else {
130
+ const setOnInsert = Object.assign(Object.assign({ itemOffered, identifier, project, typeOf: factory.offerType.Offer, availability,
131
+ validFrom,
132
+ validThrough }, (typeof (acceptedPaymentMethod === null || acceptedPaymentMethod === void 0 ? void 0 : acceptedPaymentMethod.typeOf) === 'string') ? { acceptedPaymentMethod } : undefined), (typeof (validForMemberTier === null || validForMemberTier === void 0 ? void 0 : validForMemberTier.typeOf) === 'string') ? { validForMemberTier } : undefined);
133
+ const updateFilter = {
134
+ $setOnInsert: setOnInsert
135
+ };
136
+ const updateOne = {
137
+ filter,
138
+ update: updateFilter,
139
+ upsert: true
140
+ };
141
+ bulkWriteOps.push({ updateOne });
142
+ }
143
+ });
180
144
  }
181
- return doc.toObject();
182
- });
183
- }
184
- deleteManyBySellerId(params) {
185
- return __awaiter(this, void 0, void 0, function* () {
186
- var _a;
187
- const sellerId = (_a = params.seller) === null || _a === void 0 ? void 0 : _a.id;
188
- if (typeof sellerId !== 'string' || sellerId.length === 0) {
189
- throw new factory.errors.ArgumentNull('seller.id');
145
+ if (bulkWriteOps.length > 0) {
146
+ const bulkWriteResult = yield this.productOfferModel.bulkWrite(bulkWriteOps, { ordered: false });
147
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
148
+ const modifiedNotes = yield this.productOfferModel.find({ $or: queryFilters }, {
149
+ _id: 0,
150
+ id: { $toString: '$_id' }
151
+ })
152
+ .lean()
153
+ .exec();
154
+ return { bulkWriteResult, modifiedNotes };
190
155
  }
191
- return this.productModel.updateMany({
192
- 'project.id': { $eq: params.project.id },
193
- 'offers.seller.id': { $exists: true, $eq: sellerId }
194
- }, {
195
- $pull: { offers: { 'seller.id': { $exists: true, $eq: sellerId } } }
196
- })
197
- .exec();
198
156
  });
199
157
  }
200
158
  }
@@ -34,7 +34,6 @@ import type { MerchantReturnPolicyRepo } from './repo/merchantReturnPolicy';
34
34
  import type { MessageRepo } from './repo/message';
35
35
  import type { NoteRepo } from './repo/note';
36
36
  import type { NoteAboutOrderRepo } from './repo/noteAboutOrder';
37
- import type { EventOfferRepo } from './repo/offer/event';
38
37
  import type { OfferRepo } from './repo/offer/unitPriceInCatalog';
39
38
  import type { OfferCatalogRepo } from './repo/offerCatalog';
40
39
  import type { OfferCatalogItemRepo } from './repo/offerCatalogItem';
@@ -180,10 +179,6 @@ export type Event = EventRepo;
180
179
  export declare namespace Event {
181
180
  function createInstance(...params: ConstructorParameters<typeof EventRepo>): Promise<EventRepo>;
182
181
  }
183
- export type EventOffer = EventOfferRepo;
184
- export declare namespace EventOffer {
185
- function createInstance(...params: ConstructorParameters<typeof EventOfferRepo>): Promise<EventOfferRepo>;
186
- }
187
182
  export type EventSellerMakesOffer = EventSellerMakesOfferRepo;
188
183
  export declare namespace EventSellerMakesOffer {
189
184
  function createInstance(...params: ConstructorParameters<typeof EventSellerMakesOfferRepo>): Promise<EventSellerMakesOfferRepo>;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
- exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Permit = void 0;
12
+ exports.Permit = exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
+ exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -310,19 +310,6 @@ var Event;
310
310
  }
311
311
  Event.createInstance = createInstance;
312
312
  })(Event || (exports.Event = Event = {}));
313
- var EventOffer;
314
- (function (EventOffer) {
315
- let repo;
316
- function createInstance(...params) {
317
- return __awaiter(this, void 0, void 0, function* () {
318
- if (repo === undefined) {
319
- repo = (yield Promise.resolve().then(() => require('./repo/offer/event'))).EventOfferRepo;
320
- }
321
- return new repo(...params);
322
- });
323
- }
324
- EventOffer.createInstance = createInstance;
325
- })(EventOffer || (exports.EventOffer = EventOffer = {}));
326
313
  var EventSellerMakesOffer;
327
314
  (function (EventSellerMakesOffer) {
328
315
  let repo;
@@ -5,7 +5,6 @@ import type { OfferRepo } from '../../../../repo/offer/unitPriceInCatalog';
5
5
  import type { OfferCatalogRepo } from '../../../../repo/offerCatalog';
6
6
  import type { PaymentServiceRepo } from '../../../../repo/paymentService';
7
7
  import type { ProductRepo } from '../../../../repo/product';
8
- import type { ProductOfferRepo } from '../../../../repo/productOffer';
9
8
  type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
10
9
  declare function createSubReservations(params: {
11
10
  acceptedOffers: factory.assetTransaction.reserve.IAcceptedTicketOfferWithoutDetail[];
@@ -25,6 +24,5 @@ declare function createSubReservations(params: {
25
24
  offerCatalog: OfferCatalogRepo;
26
25
  paymentService: PaymentServiceRepo;
27
26
  product: ProductRepo;
28
- productOffer: ProductOfferRepo;
29
27
  }) => Promise<IObjectSubReservation[]>;
30
28
  export { createSubReservations };