@chevre/domain 21.9.0-alpha.11 → 21.9.0-alpha.12

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.
@@ -138,6 +138,26 @@ export declare class MongoRepository {
138
138
  };
139
139
  };
140
140
  }): Promise<void>;
141
+ /**
142
+ * サブカタログに属するサブカタログを全て除外する
143
+ */
144
+ pullIncludedInOfferCatalogItemByCatalogItemId(params: {
145
+ project: {
146
+ id: string;
147
+ };
148
+ $pull: {
149
+ includedInOfferCatalogItem: {
150
+ $elemMatch: {
151
+ /**
152
+ * サブカタログID
153
+ */
154
+ id: {
155
+ $eq: string;
156
+ };
157
+ };
158
+ };
159
+ };
160
+ }): Promise<void>;
141
161
  deleteById(params: {
142
162
  project: {
143
163
  id: string;
@@ -639,6 +639,34 @@ class MongoRepository {
639
639
  .exec();
640
640
  });
641
641
  }
642
+ /**
643
+ * サブカタログに属するサブカタログを全て除外する
644
+ */
645
+ pullIncludedInOfferCatalogItemByCatalogItemId(params) {
646
+ return __awaiter(this, void 0, void 0, function* () {
647
+ yield this.aggregateOfferModel.updateMany({
648
+ 'project.id': { $eq: params.project.id },
649
+ 'offers.includedInOfferCatalogItem': {
650
+ $elemMatch: {
651
+ id: {
652
+ $exists: true,
653
+ $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
654
+ }
655
+ }
656
+ }
657
+ }, {
658
+ $pull: {
659
+ 'offers.$[].includedInOfferCatalogItem': {
660
+ id: {
661
+ $exists: true,
662
+ $eq: params.$pull.includedInOfferCatalogItem.$elemMatch.id.$eq
663
+ }
664
+ }
665
+ }
666
+ })
667
+ .exec();
668
+ });
669
+ }
642
670
  deleteById(params) {
643
671
  return __awaiter(this, void 0, void 0, function* () {
644
672
  yield this.aggregateOfferModel.findOneAndRemove({
@@ -39,7 +39,7 @@ class MongoRepository {
39
39
  }
40
40
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
41
41
  static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
42
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40;
42
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43;
43
43
  const matchStages = [];
44
44
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
45
45
  if (typeof projectIdEq === 'string') {
@@ -55,19 +55,30 @@ class MongoRepository {
55
55
  if (Array.isArray(includedInDataCatalogIdIn)) {
56
56
  matchStages.push({ $match: { 'offers.includedInDataCatalog.id': { $exists: true, $in: includedInDataCatalogIdIn } } });
57
57
  }
58
- const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
58
+ const includedInOfferCatalogItemIncludedInDataCatalogIdIn = (_j = (_h = (_g = params.includedInOfferCatalogItem) === null || _g === void 0 ? void 0 : _g.includedInDataCatalog) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
59
+ if (Array.isArray(includedInOfferCatalogItemIncludedInDataCatalogIdIn)) {
60
+ matchStages.push({
61
+ $match: {
62
+ 'offers.includedInOfferCatalogItem.includedInDataCatalog.id': {
63
+ $exists: true,
64
+ $in: includedInOfferCatalogItemIncludedInDataCatalogIdIn
65
+ }
66
+ }
67
+ });
68
+ }
69
+ const idEq = (_k = params.id) === null || _k === void 0 ? void 0 : _k.$eq;
59
70
  if (typeof idEq === 'string') {
60
71
  matchStages.push({
61
72
  $match: { 'offers.id': { $eq: idEq } }
62
73
  });
63
74
  }
64
- const idIn = (_h = params.id) === null || _h === void 0 ? void 0 : _h.$in;
75
+ const idIn = (_l = params.id) === null || _l === void 0 ? void 0 : _l.$in;
65
76
  if (Array.isArray(idIn)) {
66
77
  matchStages.push({
67
78
  $match: { 'offers.id': { $in: idIn } }
68
79
  });
69
80
  }
70
- const identifierEq = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
81
+ const identifierEq = (_m = params.identifier) === null || _m === void 0 ? void 0 : _m.$eq;
71
82
  if (typeof identifierEq === 'string') {
72
83
  matchStages.push({
73
84
  $match: {
@@ -75,7 +86,7 @@ class MongoRepository {
75
86
  }
76
87
  });
77
88
  }
78
- const identifierIn = (_k = params.identifier) === null || _k === void 0 ? void 0 : _k.$in;
89
+ const identifierIn = (_o = params.identifier) === null || _o === void 0 ? void 0 : _o.$in;
79
90
  if (Array.isArray(identifierIn)) {
80
91
  matchStages.push({
81
92
  $match: {
@@ -83,7 +94,7 @@ class MongoRepository {
83
94
  }
84
95
  });
85
96
  }
86
- const identifierRegex = (_l = params.identifier) === null || _l === void 0 ? void 0 : _l.$regex;
97
+ const identifierRegex = (_p = params.identifier) === null || _p === void 0 ? void 0 : _p.$regex;
87
98
  if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
88
99
  matchStages.push({
89
100
  $match: {
@@ -91,7 +102,7 @@ class MongoRepository {
91
102
  }
92
103
  });
93
104
  }
94
- const nameRegex = (_m = params.name) === null || _m === void 0 ? void 0 : _m.$regex;
105
+ const nameRegex = (_q = params.name) === null || _q === void 0 ? void 0 : _q.$regex;
95
106
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
96
107
  const nameRegexExp = new RegExp(nameRegex);
97
108
  matchStages.push({
@@ -105,7 +116,7 @@ class MongoRepository {
105
116
  }
106
117
  });
107
118
  }
108
- const itemOfferedTypeOfEq = (_p = (_o = params.itemOffered) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
119
+ const itemOfferedTypeOfEq = (_s = (_r = params.itemOffered) === null || _r === void 0 ? void 0 : _r.typeOf) === null || _s === void 0 ? void 0 : _s.$eq;
109
120
  if (typeof itemOfferedTypeOfEq === 'string') {
110
121
  matchStages.push({
111
122
  $match: {
@@ -113,7 +124,7 @@ class MongoRepository {
113
124
  }
114
125
  });
115
126
  }
116
- const categoryCodeValueIn = (_r = (_q = params.category) === null || _q === void 0 ? void 0 : _q.codeValue) === null || _r === void 0 ? void 0 : _r.$in;
127
+ const categoryCodeValueIn = (_u = (_t = params.category) === null || _t === void 0 ? void 0 : _t.codeValue) === null || _u === void 0 ? void 0 : _u.$in;
117
128
  if (Array.isArray(categoryCodeValueIn)) {
118
129
  matchStages.push({
119
130
  $match: {
@@ -121,7 +132,7 @@ class MongoRepository {
121
132
  }
122
133
  });
123
134
  }
124
- const eligibleMembershipTypeCodeValueEq = (_t = (_s = params.eligibleMembershipType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
135
+ const eligibleMembershipTypeCodeValueEq = (_w = (_v = params.eligibleMembershipType) === null || _v === void 0 ? void 0 : _v.codeValue) === null || _w === void 0 ? void 0 : _w.$eq;
125
136
  if (typeof eligibleMembershipTypeCodeValueEq === 'string') {
126
137
  matchStages.push({
127
138
  $match: {
@@ -132,7 +143,7 @@ class MongoRepository {
132
143
  }
133
144
  });
134
145
  }
135
- const eligibleMonetaryAmountCurrencyEq = (_v = (_u = params.eligibleMonetaryAmount) === null || _u === void 0 ? void 0 : _u.currency) === null || _v === void 0 ? void 0 : _v.$eq;
146
+ const eligibleMonetaryAmountCurrencyEq = (_y = (_x = params.eligibleMonetaryAmount) === null || _x === void 0 ? void 0 : _x.currency) === null || _y === void 0 ? void 0 : _y.$eq;
136
147
  if (typeof eligibleMonetaryAmountCurrencyEq === 'string') {
137
148
  matchStages.push({
138
149
  $match: {
@@ -143,7 +154,7 @@ class MongoRepository {
143
154
  }
144
155
  });
145
156
  }
146
- const eligibleSeatingTypeCodeValueEq = (_x = (_w = params.eligibleSeatingType) === null || _w === void 0 ? void 0 : _w.codeValue) === null || _x === void 0 ? void 0 : _x.$eq;
157
+ const eligibleSeatingTypeCodeValueEq = (_0 = (_z = params.eligibleSeatingType) === null || _z === void 0 ? void 0 : _z.codeValue) === null || _0 === void 0 ? void 0 : _0.$eq;
147
158
  if (typeof eligibleSeatingTypeCodeValueEq === 'string') {
148
159
  matchStages.push({
149
160
  $match: {
@@ -154,7 +165,7 @@ class MongoRepository {
154
165
  }
155
166
  });
156
167
  }
157
- const appliesToMovieTicketServiceTypeExist = (_0 = (_z = (_y = params.priceSpecification) === null || _y === void 0 ? void 0 : _y.appliesToMovieTicket) === null || _z === void 0 ? void 0 : _z.serviceType) === null || _0 === void 0 ? void 0 : _0.$exists;
168
+ const appliesToMovieTicketServiceTypeExist = (_3 = (_2 = (_1 = params.priceSpecification) === null || _1 === void 0 ? void 0 : _1.appliesToMovieTicket) === null || _2 === void 0 ? void 0 : _2.serviceType) === null || _3 === void 0 ? void 0 : _3.$exists;
158
169
  if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
159
170
  matchStages.push({
160
171
  $match: {
@@ -164,7 +175,7 @@ class MongoRepository {
164
175
  }
165
176
  });
166
177
  }
167
- const appliesToMovieTicketServiceTypeEq = (_3 = (_2 = (_1 = params.priceSpecification) === null || _1 === void 0 ? void 0 : _1.appliesToMovieTicket) === null || _2 === void 0 ? void 0 : _2.serviceType) === null || _3 === void 0 ? void 0 : _3.$eq;
178
+ const appliesToMovieTicketServiceTypeEq = (_6 = (_5 = (_4 = params.priceSpecification) === null || _4 === void 0 ? void 0 : _4.appliesToMovieTicket) === null || _5 === void 0 ? void 0 : _5.serviceType) === null || _6 === void 0 ? void 0 : _6.$eq;
168
179
  if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
169
180
  matchStages.push({
170
181
  $match: {
@@ -175,7 +186,7 @@ class MongoRepository {
175
186
  }
176
187
  });
177
188
  }
178
- const appliesToMovieTicketServiceOutputTypeOfEq = (_7 = (_6 = (_5 = (_4 = params.priceSpecification) === null || _4 === void 0 ? void 0 : _4.appliesToMovieTicket) === null || _5 === void 0 ? void 0 : _5.serviceOutput) === null || _6 === void 0 ? void 0 : _6.typeOf) === null || _7 === void 0 ? void 0 : _7.$eq;
189
+ const appliesToMovieTicketServiceOutputTypeOfEq = (_10 = (_9 = (_8 = (_7 = params.priceSpecification) === null || _7 === void 0 ? void 0 : _7.appliesToMovieTicket) === null || _8 === void 0 ? void 0 : _8.serviceOutput) === null || _9 === void 0 ? void 0 : _9.typeOf) === null || _10 === void 0 ? void 0 : _10.$eq;
179
190
  if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
180
191
  matchStages.push({
181
192
  $match: {
@@ -186,7 +197,7 @@ class MongoRepository {
186
197
  }
187
198
  });
188
199
  }
189
- const appliesToMovieTicketServiceOutputTypeOfNin = (_11 = (_10 = (_9 = (_8 = params.priceSpecification) === null || _8 === void 0 ? void 0 : _8.appliesToMovieTicket) === null || _9 === void 0 ? void 0 : _9.serviceOutput) === null || _10 === void 0 ? void 0 : _10.typeOf) === null || _11 === void 0 ? void 0 : _11.$nin;
200
+ const appliesToMovieTicketServiceOutputTypeOfNin = (_14 = (_13 = (_12 = (_11 = params.priceSpecification) === null || _11 === void 0 ? void 0 : _11.appliesToMovieTicket) === null || _12 === void 0 ? void 0 : _12.serviceOutput) === null || _13 === void 0 ? void 0 : _13.typeOf) === null || _14 === void 0 ? void 0 : _14.$nin;
190
201
  if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
191
202
  matchStages.push({
192
203
  $match: {
@@ -197,7 +208,7 @@ class MongoRepository {
197
208
  });
198
209
  }
199
210
  if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
200
- const priceSpecificationPriceGte = (_12 = params.priceSpecification.price) === null || _12 === void 0 ? void 0 : _12.$gte;
211
+ const priceSpecificationPriceGte = (_15 = params.priceSpecification.price) === null || _15 === void 0 ? void 0 : _15.$gte;
201
212
  if (typeof priceSpecificationPriceGte === 'number') {
202
213
  matchStages.push({
203
214
  $match: {
@@ -208,7 +219,7 @@ class MongoRepository {
208
219
  }
209
220
  });
210
221
  }
211
- const priceSpecificationPriceLte = (_13 = params.priceSpecification.price) === null || _13 === void 0 ? void 0 : _13.$lte;
222
+ const priceSpecificationPriceLte = (_16 = params.priceSpecification.price) === null || _16 === void 0 ? void 0 : _16.$lte;
212
223
  if (typeof priceSpecificationPriceLte === 'number') {
213
224
  matchStages.push({
214
225
  $match: {
@@ -219,7 +230,7 @@ class MongoRepository {
219
230
  }
220
231
  });
221
232
  }
222
- const accountsReceivableGte = (_15 = (_14 = params.priceSpecification.accounting) === null || _14 === void 0 ? void 0 : _14.accountsReceivable) === null || _15 === void 0 ? void 0 : _15.$gte;
233
+ const accountsReceivableGte = (_18 = (_17 = params.priceSpecification.accounting) === null || _17 === void 0 ? void 0 : _17.accountsReceivable) === null || _18 === void 0 ? void 0 : _18.$gte;
223
234
  if (typeof accountsReceivableGte === 'number') {
224
235
  matchStages.push({
225
236
  $match: {
@@ -230,7 +241,7 @@ class MongoRepository {
230
241
  }
231
242
  });
232
243
  }
233
- const accountsReceivableLte = (_17 = (_16 = params.priceSpecification.accounting) === null || _16 === void 0 ? void 0 : _16.accountsReceivable) === null || _17 === void 0 ? void 0 : _17.$lte;
244
+ const accountsReceivableLte = (_20 = (_19 = params.priceSpecification.accounting) === null || _19 === void 0 ? void 0 : _19.accountsReceivable) === null || _20 === void 0 ? void 0 : _20.$lte;
234
245
  if (typeof accountsReceivableLte === 'number') {
235
246
  matchStages.push({
236
247
  $match: {
@@ -241,7 +252,7 @@ class MongoRepository {
241
252
  }
242
253
  });
243
254
  }
244
- const accountingCodeValueEq = (_20 = (_19 = (_18 = params.priceSpecification.accounting) === null || _18 === void 0 ? void 0 : _18.operatingRevenue) === null || _19 === void 0 ? void 0 : _19.codeValue) === null || _20 === void 0 ? void 0 : _20.$eq;
255
+ const accountingCodeValueEq = (_23 = (_22 = (_21 = params.priceSpecification.accounting) === null || _21 === void 0 ? void 0 : _21.operatingRevenue) === null || _22 === void 0 ? void 0 : _22.codeValue) === null || _23 === void 0 ? void 0 : _23.$eq;
245
256
  if (typeof accountingCodeValueEq === 'string') {
246
257
  matchStages.push({
247
258
  $match: {
@@ -252,7 +263,7 @@ class MongoRepository {
252
263
  }
253
264
  });
254
265
  }
255
- const accountingCodeValueIn = (_23 = (_22 = (_21 = params.priceSpecification.accounting) === null || _21 === void 0 ? void 0 : _21.operatingRevenue) === null || _22 === void 0 ? void 0 : _22.codeValue) === null || _23 === void 0 ? void 0 : _23.$in;
266
+ const accountingCodeValueIn = (_26 = (_25 = (_24 = params.priceSpecification.accounting) === null || _24 === void 0 ? void 0 : _24.operatingRevenue) === null || _25 === void 0 ? void 0 : _25.codeValue) === null || _26 === void 0 ? void 0 : _26.$in;
256
267
  if (Array.isArray(accountingCodeValueIn)) {
257
268
  matchStages.push({
258
269
  $match: {
@@ -263,7 +274,7 @@ class MongoRepository {
263
274
  }
264
275
  });
265
276
  }
266
- const referenceQuantityValueEq = (_25 = (_24 = params.priceSpecification.referenceQuantity) === null || _24 === void 0 ? void 0 : _24.value) === null || _25 === void 0 ? void 0 : _25.$eq;
277
+ const referenceQuantityValueEq = (_28 = (_27 = params.priceSpecification.referenceQuantity) === null || _27 === void 0 ? void 0 : _27.value) === null || _28 === void 0 ? void 0 : _28.$eq;
267
278
  if (typeof referenceQuantityValueEq === 'number') {
268
279
  matchStages.push({
269
280
  $match: {
@@ -275,7 +286,7 @@ class MongoRepository {
275
286
  });
276
287
  }
277
288
  }
278
- const availabilityEq = (_26 = params.availability) === null || _26 === void 0 ? void 0 : _26.$eq;
289
+ const availabilityEq = (_29 = params.availability) === null || _29 === void 0 ? void 0 : _29.$eq;
279
290
  if (typeof availabilityEq === 'string') {
280
291
  matchStages.push({
281
292
  $match: {
@@ -283,7 +294,7 @@ class MongoRepository {
283
294
  }
284
295
  });
285
296
  }
286
- const availableAtOrFromIdEq = (_28 = (_27 = params.availableAtOrFrom) === null || _27 === void 0 ? void 0 : _27.id) === null || _28 === void 0 ? void 0 : _28.$eq;
297
+ const availableAtOrFromIdEq = (_31 = (_30 = params.availableAtOrFrom) === null || _30 === void 0 ? void 0 : _30.id) === null || _31 === void 0 ? void 0 : _31.$eq;
287
298
  if (typeof availableAtOrFromIdEq === 'string') {
288
299
  matchStages.push({
289
300
  $match: {
@@ -294,7 +305,7 @@ class MongoRepository {
294
305
  }
295
306
  });
296
307
  }
297
- const availableAtOrFromIdIn = (_30 = (_29 = params.availableAtOrFrom) === null || _29 === void 0 ? void 0 : _29.id) === null || _30 === void 0 ? void 0 : _30.$in;
308
+ const availableAtOrFromIdIn = (_33 = (_32 = params.availableAtOrFrom) === null || _32 === void 0 ? void 0 : _32.id) === null || _33 === void 0 ? void 0 : _33.$in;
298
309
  if (Array.isArray(availableAtOrFromIdIn)) {
299
310
  matchStages.push({
300
311
  $match: {
@@ -305,7 +316,7 @@ class MongoRepository {
305
316
  }
306
317
  });
307
318
  }
308
- const addOnItemOfferedIdEq = (_33 = (_32 = (_31 = params.addOn) === null || _31 === void 0 ? void 0 : _31.itemOffered) === null || _32 === void 0 ? void 0 : _32.id) === null || _33 === void 0 ? void 0 : _33.$eq;
319
+ const addOnItemOfferedIdEq = (_36 = (_35 = (_34 = params.addOn) === null || _34 === void 0 ? void 0 : _34.itemOffered) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$eq;
309
320
  if (typeof addOnItemOfferedIdEq === 'string') {
310
321
  matchStages.push({
311
322
  $match: {
@@ -313,7 +324,7 @@ class MongoRepository {
313
324
  }
314
325
  });
315
326
  }
316
- const addOnItemOfferedIdIn = (_36 = (_35 = (_34 = params.addOn) === null || _34 === void 0 ? void 0 : _34.itemOffered) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$in;
327
+ const addOnItemOfferedIdIn = (_39 = (_38 = (_37 = params.addOn) === null || _37 === void 0 ? void 0 : _37.itemOffered) === null || _38 === void 0 ? void 0 : _38.id) === null || _39 === void 0 ? void 0 : _39.$in;
317
328
  if (Array.isArray(addOnItemOfferedIdIn)) {
318
329
  matchStages.push({
319
330
  $match: {
@@ -321,7 +332,7 @@ class MongoRepository {
321
332
  }
322
333
  });
323
334
  }
324
- const hasMerchantReturnPolicyIdEq = (_38 = (_37 = params.hasMerchantReturnPolicy) === null || _37 === void 0 ? void 0 : _37.id) === null || _38 === void 0 ? void 0 : _38.$eq;
335
+ const hasMerchantReturnPolicyIdEq = (_41 = (_40 = params.hasMerchantReturnPolicy) === null || _40 === void 0 ? void 0 : _40.id) === null || _41 === void 0 ? void 0 : _41.$eq;
325
336
  if (typeof hasMerchantReturnPolicyIdEq === 'string') {
326
337
  matchStages.push({
327
338
  $match: {
@@ -332,7 +343,7 @@ class MongoRepository {
332
343
  }
333
344
  });
334
345
  }
335
- const additionalPropertyAll = (_39 = params.additionalProperty) === null || _39 === void 0 ? void 0 : _39.$all;
346
+ const additionalPropertyAll = (_42 = params.additionalProperty) === null || _42 === void 0 ? void 0 : _42.$all;
336
347
  if (Array.isArray(additionalPropertyAll)) {
337
348
  matchStages.push({
338
349
  $match: {
@@ -343,7 +354,7 @@ class MongoRepository {
343
354
  }
344
355
  });
345
356
  }
346
- const additionalPropertyElemMatch = (_40 = params.additionalProperty) === null || _40 === void 0 ? void 0 : _40.$elemMatch;
357
+ const additionalPropertyElemMatch = (_43 = params.additionalProperty) === null || _43 === void 0 ? void 0 : _43.$elemMatch;
347
358
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
348
359
  matchStages.push({
349
360
  $match: {
@@ -22,8 +22,6 @@ function syncOfferCatalog(params) {
22
22
  var _a;
23
23
  if (params.isDeleted) {
24
24
  for (const offerCatalogId of params.ids) {
25
- // 検索しても存在しない
26
- // const offerCatalogs = await repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
27
25
  // カタログを含む全集計オファーからカタログを除外
28
26
  yield repos.aggregateOffer.pullIncludedInDataCatalog({
29
27
  project: { id: params.project.id },
@@ -31,6 +29,20 @@ function syncOfferCatalog(params) {
31
29
  includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
32
30
  }
33
31
  });
32
+ // 記載サブカタログ同期
33
+ yield repos.aggregateOffer.pullIncludedInOfferCatalogItemByCatalogId({
34
+ project: { id: params.project.id },
35
+ $pull: {
36
+ includedInOfferCatalogItem: { $elemMatch: { includedInDataCatalog: { id: { $eq: offerCatalogId } } } }
37
+ }
38
+ });
39
+ // 記載サブカタログ同期
40
+ yield repos.aggregateOffer.pullIncludedInOfferCatalogItemByCatalogItemId({
41
+ project: { id: params.project.id },
42
+ $pull: {
43
+ includedInOfferCatalogItem: { $elemMatch: { id: { $eq: offerCatalogId } } }
44
+ }
45
+ });
34
46
  }
35
47
  }
36
48
  else {
@@ -45,35 +57,18 @@ function syncOfferCatalog(params) {
45
57
  const itemListElementTypeOf = (_a = offerCatalogs.shift()) === null || _a === void 0 ? void 0 : _a.itemListElementTypeOf;
46
58
  switch (itemListElementTypeOf) {
47
59
  case factory.offerType.Offer:
48
- // 集計オファーIDリストを検索
49
- let aggregateOfferIds;
60
+ // includedInDataCatalogを単価オファーへ同期
61
+ yield syncOfferCatalogOfOffer2offer({
62
+ id: offerCatalogId,
63
+ project: { id: params.project.id },
64
+ isOfferCatalogItem: params.isOfferCatalogItem
65
+ })(repos);
50
66
  if (params.isOfferCatalogItem) {
51
- const { itemListElement } = yield repos.offerCatalogItem.findItemListElementById({
52
- id: offerCatalogId,
53
- project: { id: params.project.id }
54
- });
55
- aggregateOfferIds = itemListElement.map((element) => element.id);
56
- }
57
- else {
58
- const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
67
+ // offerCatalogItemの場合、記載サブカタログ情報を単価オファーへ同期(2023-09-21~)
68
+ yield syncOfferCatalogItem2offer({
59
69
  id: offerCatalogId,
60
70
  project: { id: params.project.id }
61
- });
62
- aggregateOfferIds = itemListElement.map((element) => element.id);
63
- }
64
- // カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
65
- yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
66
- includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
67
- } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
68
- if (aggregateOfferIds.length > 0) {
69
- // 新しいカタログに含まれる全集計オファーにカタログを追加
70
- yield repos.aggregateOffer.pushIncludedInDataCatalog({
71
- project: { id: params.project.id },
72
- id: { $in: aggregateOfferIds },
73
- $push: {
74
- includedInDataCatalog: { $each: [{ id: offerCatalogId }] }
75
- }
76
- });
71
+ })(repos);
77
72
  }
78
73
  // 同期済記録を補完
79
74
  if (params.isOfferCatalogItem) {
@@ -85,10 +80,11 @@ function syncOfferCatalog(params) {
85
80
  break;
86
81
  case 'OfferCatalog':
87
82
  // 記載サブカタログ情報を単価オファーへ同期(2023-09-21~)
88
- yield syncCatalogOfCatalog2offer({
83
+ yield syncOfferCatalog2offer({
89
84
  id: offerCatalogId,
90
85
  project: { id: params.project.id }
91
86
  })(repos);
87
+ yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
92
88
  break;
93
89
  default:
94
90
  // no op
@@ -98,7 +94,41 @@ function syncOfferCatalog(params) {
98
94
  });
99
95
  }
100
96
  exports.syncOfferCatalog = syncOfferCatalog;
101
- function syncCatalogOfCatalog2offer(params) {
97
+ function syncOfferCatalogOfOffer2offer(params) {
98
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
99
+ // 集計オファーIDリストを検索
100
+ let aggregateOfferIds;
101
+ if (params.isOfferCatalogItem) {
102
+ const { itemListElement } = yield repos.offerCatalogItem.findItemListElementById({
103
+ id: params.id,
104
+ project: { id: params.project.id }
105
+ });
106
+ aggregateOfferIds = itemListElement.map((element) => element.id);
107
+ }
108
+ else {
109
+ const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
110
+ id: params.id,
111
+ project: { id: params.project.id }
112
+ });
113
+ aggregateOfferIds = itemListElement.map((element) => element.id);
114
+ }
115
+ // カタログを含み、かつ、新しいカタログに含まれない集計オファーからカタログを除外
116
+ yield repos.aggregateOffer.pullIncludedInDataCatalog(Object.assign({ project: { id: params.project.id }, $pull: {
117
+ includedInDataCatalog: { $elemMatch: { id: { $eq: params.id } } }
118
+ } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
119
+ if (aggregateOfferIds.length > 0) {
120
+ // 新しいカタログに含まれる全集計オファーにカタログを追加
121
+ yield repos.aggregateOffer.pushIncludedInDataCatalog({
122
+ project: { id: params.project.id },
123
+ id: { $in: aggregateOfferIds },
124
+ $push: {
125
+ includedInDataCatalog: { $each: [{ id: params.id }] }
126
+ }
127
+ });
128
+ }
129
+ });
130
+ }
131
+ function syncOfferCatalog2offer(params) {
102
132
  return (repos) => __awaiter(this, void 0, void 0, function* () {
103
133
  // サブカタログIDリストを検索
104
134
  let offerCatalogItemIds;
@@ -110,33 +140,11 @@ function syncCatalogOfCatalog2offer(params) {
110
140
  // サブカタログごとに同期
111
141
  if (offerCatalogItemIds.length > 0) {
112
142
  for (const offerCatalogItemId of offerCatalogItemIds) {
113
- // 集計オファーIDリストを検索
114
- let aggregateOfferIds;
115
- const findSubCatalogItemListElementResult = yield repos.offerCatalogItem.findItemListElementById({
143
+ yield syncSubCatalogs2offer({
116
144
  id: offerCatalogItemId,
117
- project: { id: params.project.id }
118
- });
119
- aggregateOfferIds = findSubCatalogItemListElementResult.itemListElement.map((element) => element.id);
120
- yield repos.aggregateOffer.pullIncludedInOfferCatalogItem(Object.assign({ project: { id: params.project.id }, $pull: {
121
- includedInOfferCatalogItem: {
122
- $elemMatch: {
123
- id: { $eq: offerCatalogItemId },
124
- includedInDataCatalog: { id: { $eq: params.id } }
125
- }
126
- }
127
- } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
128
- if (aggregateOfferIds.length > 0) {
129
- yield repos.aggregateOffer.pushIncludedInOfferCatalogItem({
130
- project: { id: params.project.id },
131
- id: { $in: aggregateOfferIds },
132
- $push: {
133
- includedInOfferCatalogItem: {
134
- id: { $eq: offerCatalogItemId },
135
- includedInDataCatalog: { id: { $eq: params.id } }
136
- }
137
- }
138
- });
139
- }
145
+ includedInDataCatalog: { id: params.id },
146
+ project: params.project
147
+ })(repos);
140
148
  }
141
149
  }
142
150
  else {
@@ -152,12 +160,59 @@ function syncCatalogOfCatalog2offer(params) {
152
160
  }
153
161
  });
154
162
  }
155
- // tslint:disable-next-line:no-suspicious-comment
156
- // TODO 同期済記録を補完
157
- // if (params.isOfferCatalogItem) {
158
- // await repos.offerCatalogItem.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
159
- // } else {
160
- // await repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
161
- // }
163
+ });
164
+ }
165
+ function syncOfferCatalogItem2offer(params) {
166
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
167
+ // 記載カタログを検索
168
+ const offerCatalogs = yield repos.offerCatalog.search({
169
+ project: { id: { $eq: params.project.id } },
170
+ itemListElement: {
171
+ id: { $in: [params.id] },
172
+ typeOf: { $eq: 'OfferCatalog' }
173
+ }
174
+ });
175
+ for (const offerCatalog of offerCatalogs) {
176
+ yield syncSubCatalogs2offer({
177
+ id: params.id,
178
+ includedInDataCatalog: { id: String(offerCatalog.id) },
179
+ project: params.project
180
+ })(repos);
181
+ }
182
+ });
183
+ }
184
+ /**
185
+ * サブカタログ+カタログを単価オファーへ同期する
186
+ */
187
+ function syncSubCatalogs2offer(params) {
188
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
189
+ const offerCatalogItemId = params.id;
190
+ // 集計オファーIDリストを検索
191
+ let aggregateOfferIds;
192
+ const findSubCatalogItemListElementResult = yield repos.offerCatalogItem.findItemListElementById({
193
+ id: offerCatalogItemId,
194
+ project: { id: params.project.id }
195
+ });
196
+ aggregateOfferIds = findSubCatalogItemListElementResult.itemListElement.map((element) => element.id);
197
+ yield repos.aggregateOffer.pullIncludedInOfferCatalogItem(Object.assign({ project: { id: params.project.id }, $pull: {
198
+ includedInOfferCatalogItem: {
199
+ $elemMatch: {
200
+ id: { $eq: offerCatalogItemId },
201
+ includedInDataCatalog: { id: { $eq: params.includedInDataCatalog.id } }
202
+ }
203
+ }
204
+ } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
205
+ if (aggregateOfferIds.length > 0) {
206
+ yield repos.aggregateOffer.pushIncludedInOfferCatalogItem({
207
+ project: { id: params.project.id },
208
+ id: { $in: aggregateOfferIds },
209
+ $push: {
210
+ includedInOfferCatalogItem: {
211
+ id: { $eq: offerCatalogItemId },
212
+ includedInDataCatalog: { id: { $eq: params.includedInDataCatalog.id } }
213
+ }
214
+ }
215
+ });
216
+ }
162
217
  });
163
218
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.330.0-alpha.2",
12
+ "@chevre/factory": "4.330.0-alpha.3",
13
13
  "@cinerino/sdk": "3.168.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -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.11"
120
+ "version": "21.9.0-alpha.12"
121
121
  }