@chevre/domain 21.19.0-alpha.8 → 21.19.0

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 (53) hide show
  1. package/example/src/chevre/deleteOldPaymentServices.ts +18 -0
  2. package/example/src/chevre/processAction.ts +42 -0
  3. package/example/src/chevre/searchOffers.ts +2 -1
  4. package/example/src/chevre/upsertProductsByProductId.ts +99 -0
  5. package/lib/chevre/repo/action.d.ts +9 -4
  6. package/lib/chevre/repo/action.js +24 -3
  7. package/lib/chevre/repo/aggregateOffer.js +28 -22
  8. package/lib/chevre/repo/offer.js +28 -22
  9. package/lib/chevre/repo/offerCatalog.js +13 -9
  10. package/lib/chevre/repo/offerCatalogItem.js +14 -10
  11. package/lib/chevre/repo/paymentService.d.ts +3 -7
  12. package/lib/chevre/repo/paymentService.js +28 -55
  13. package/lib/chevre/repo/paymentServiceProvider.js +1 -4
  14. package/lib/chevre/repo/product.d.ts +19 -7
  15. package/lib/chevre/repo/product.js +47 -14
  16. package/lib/chevre/service/code.js +1 -3
  17. package/lib/chevre/service/delivery.js +2 -6
  18. package/lib/chevre/service/event/createEvent.js +1 -3
  19. package/lib/chevre/service/event.js +2 -6
  20. package/lib/chevre/service/moneyTransfer.js +1 -3
  21. package/lib/chevre/service/notification.js +2 -6
  22. package/lib/chevre/service/offer/event/authorize.js +1 -2
  23. package/lib/chevre/service/offer/eventServiceByCOA.js +2 -4
  24. package/lib/chevre/service/offer/moneyTransfer/authorize.js +1 -3
  25. package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -3
  26. package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -3
  27. package/lib/chevre/service/offer/product.js +1 -2
  28. package/lib/chevre/service/order/confirmPayTransaction.js +1 -3
  29. package/lib/chevre/service/order/placeOrder.js +2 -6
  30. package/lib/chevre/service/order/returnOrder.js +1 -3
  31. package/lib/chevre/service/order/sendOrder.js +1 -2
  32. package/lib/chevre/service/payment/any.js +1 -2
  33. package/lib/chevre/service/payment/creditCard.js +2 -5
  34. package/lib/chevre/service/payment/faceToFace.js +2 -5
  35. package/lib/chevre/service/payment/movieTicket.js +2 -6
  36. package/lib/chevre/service/payment/paymentCard.js +2 -4
  37. package/lib/chevre/service/product.js +1 -3
  38. package/lib/chevre/service/reserve/cancelReservation.js +2 -6
  39. package/lib/chevre/service/reserve/confirmReservation.js +1 -3
  40. package/lib/chevre/service/reserve/useReservation.js +1 -3
  41. package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -3
  42. package/lib/chevre/service/task/confirmReserveTransaction.js +1 -3
  43. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.d.ts +2 -0
  44. package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +9 -5
  45. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -14
  46. package/lib/chevre/service/task/onResourceUpdated.js +2 -1
  47. package/lib/chevre/service/task/returnPayTransaction.js +1 -2
  48. package/lib/chevre/service/task/returnReserveTransaction.js +1 -2
  49. package/lib/chevre/service/transaction/deleteTransaction.js +1 -3
  50. package/lib/chevre/service/transaction/moneyTransfer.js +1 -2
  51. package/lib/chevre/settings.d.ts +0 -2
  52. package/lib/chevre/settings.js +1 -3
  53. package/package.json +3 -3
@@ -40,7 +40,7 @@ class MongoRepository {
40
40
  }
41
41
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
42
42
  static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
43
- 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, _44, _45, _46;
43
+ 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, _44, _45, _46, _47, _48;
44
44
  const matchStages = [];
45
45
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
46
46
  if (typeof projectIdEq === 'string') {
@@ -172,7 +172,13 @@ class MongoRepository {
172
172
  }
173
173
  });
174
174
  }
175
- 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;
175
+ const appliesToMovieTicketSize = (_z = (_y = params.priceSpecification) === null || _y === void 0 ? void 0 : _y.appliesToMovieTicket) === null || _z === void 0 ? void 0 : _z.$size;
176
+ if (typeof appliesToMovieTicketSize === 'number') {
177
+ matchStages.push({
178
+ $match: { 'offers.priceSpecification.appliesToMovieTicket': { $exists: true, $size: appliesToMovieTicketSize } }
179
+ });
180
+ }
181
+ const appliesToMovieTicketServiceTypeExist = (_2 = (_1 = (_0 = params.priceSpecification) === null || _0 === void 0 ? void 0 : _0.appliesToMovieTicket) === null || _1 === void 0 ? void 0 : _1.serviceType) === null || _2 === void 0 ? void 0 : _2.$exists;
176
182
  if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
177
183
  matchStages.push({
178
184
  $match: {
@@ -182,7 +188,7 @@ class MongoRepository {
182
188
  }
183
189
  });
184
190
  }
185
- 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;
191
+ const appliesToMovieTicketServiceTypeEq = (_5 = (_4 = (_3 = params.priceSpecification) === null || _3 === void 0 ? void 0 : _3.appliesToMovieTicket) === null || _4 === void 0 ? void 0 : _4.serviceType) === null || _5 === void 0 ? void 0 : _5.$eq;
186
192
  if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
187
193
  matchStages.push({
188
194
  $match: {
@@ -193,7 +199,7 @@ class MongoRepository {
193
199
  }
194
200
  });
195
201
  }
196
- 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;
202
+ const appliesToMovieTicketServiceOutputTypeOfEq = (_9 = (_8 = (_7 = (_6 = params.priceSpecification) === null || _6 === void 0 ? void 0 : _6.appliesToMovieTicket) === null || _7 === void 0 ? void 0 : _7.serviceOutput) === null || _8 === void 0 ? void 0 : _8.typeOf) === null || _9 === void 0 ? void 0 : _9.$eq;
197
203
  if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
198
204
  matchStages.push({
199
205
  $match: {
@@ -204,7 +210,7 @@ class MongoRepository {
204
210
  }
205
211
  });
206
212
  }
207
- const appliesToMovieTicketServiceOutputTypeOfAll = (_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.$all;
213
+ const appliesToMovieTicketServiceOutputTypeOfAll = (_13 = (_12 = (_11 = (_10 = params.priceSpecification) === null || _10 === void 0 ? void 0 : _10.appliesToMovieTicket) === null || _11 === void 0 ? void 0 : _11.serviceOutput) === null || _12 === void 0 ? void 0 : _12.typeOf) === null || _13 === void 0 ? void 0 : _13.$all;
208
214
  if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfAll)) {
209
215
  matchStages.push({
210
216
  $match: {
@@ -215,7 +221,7 @@ class MongoRepository {
215
221
  }
216
222
  });
217
223
  }
218
- const appliesToMovieTicketServiceOutputTypeOfNin = (_15 = (_14 = (_13 = (_12 = params.priceSpecification) === null || _12 === void 0 ? void 0 : _12.appliesToMovieTicket) === null || _13 === void 0 ? void 0 : _13.serviceOutput) === null || _14 === void 0 ? void 0 : _14.typeOf) === null || _15 === void 0 ? void 0 : _15.$nin;
224
+ const appliesToMovieTicketServiceOutputTypeOfNin = (_17 = (_16 = (_15 = (_14 = params.priceSpecification) === null || _14 === void 0 ? void 0 : _14.appliesToMovieTicket) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.typeOf) === null || _17 === void 0 ? void 0 : _17.$nin;
219
225
  if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
220
226
  matchStages.push({
221
227
  $match: {
@@ -226,7 +232,7 @@ class MongoRepository {
226
232
  });
227
233
  }
228
234
  if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
229
- const priceSpecificationPriceGte = (_16 = params.priceSpecification.price) === null || _16 === void 0 ? void 0 : _16.$gte;
235
+ const priceSpecificationPriceGte = (_18 = params.priceSpecification.price) === null || _18 === void 0 ? void 0 : _18.$gte;
230
236
  if (typeof priceSpecificationPriceGte === 'number') {
231
237
  matchStages.push({
232
238
  $match: {
@@ -237,7 +243,7 @@ class MongoRepository {
237
243
  }
238
244
  });
239
245
  }
240
- const priceSpecificationPriceLte = (_17 = params.priceSpecification.price) === null || _17 === void 0 ? void 0 : _17.$lte;
246
+ const priceSpecificationPriceLte = (_19 = params.priceSpecification.price) === null || _19 === void 0 ? void 0 : _19.$lte;
241
247
  if (typeof priceSpecificationPriceLte === 'number') {
242
248
  matchStages.push({
243
249
  $match: {
@@ -248,7 +254,7 @@ class MongoRepository {
248
254
  }
249
255
  });
250
256
  }
251
- const accountsReceivableGte = (_19 = (_18 = params.priceSpecification.accounting) === null || _18 === void 0 ? void 0 : _18.accountsReceivable) === null || _19 === void 0 ? void 0 : _19.$gte;
257
+ const accountsReceivableGte = (_21 = (_20 = params.priceSpecification.accounting) === null || _20 === void 0 ? void 0 : _20.accountsReceivable) === null || _21 === void 0 ? void 0 : _21.$gte;
252
258
  if (typeof accountsReceivableGte === 'number') {
253
259
  matchStages.push({
254
260
  $match: {
@@ -259,7 +265,7 @@ class MongoRepository {
259
265
  }
260
266
  });
261
267
  }
262
- const accountsReceivableLte = (_21 = (_20 = params.priceSpecification.accounting) === null || _20 === void 0 ? void 0 : _20.accountsReceivable) === null || _21 === void 0 ? void 0 : _21.$lte;
268
+ const accountsReceivableLte = (_23 = (_22 = params.priceSpecification.accounting) === null || _22 === void 0 ? void 0 : _22.accountsReceivable) === null || _23 === void 0 ? void 0 : _23.$lte;
263
269
  if (typeof accountsReceivableLte === 'number') {
264
270
  matchStages.push({
265
271
  $match: {
@@ -270,7 +276,7 @@ class MongoRepository {
270
276
  }
271
277
  });
272
278
  }
273
- const accountingCodeValueEq = (_24 = (_23 = (_22 = params.priceSpecification.accounting) === null || _22 === void 0 ? void 0 : _22.operatingRevenue) === null || _23 === void 0 ? void 0 : _23.codeValue) === null || _24 === void 0 ? void 0 : _24.$eq;
279
+ const accountingCodeValueEq = (_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.$eq;
274
280
  if (typeof accountingCodeValueEq === 'string') {
275
281
  matchStages.push({
276
282
  $match: {
@@ -281,7 +287,7 @@ class MongoRepository {
281
287
  }
282
288
  });
283
289
  }
284
- const accountingCodeValueIn = (_27 = (_26 = (_25 = params.priceSpecification.accounting) === null || _25 === void 0 ? void 0 : _25.operatingRevenue) === null || _26 === void 0 ? void 0 : _26.codeValue) === null || _27 === void 0 ? void 0 : _27.$in;
290
+ const accountingCodeValueIn = (_29 = (_28 = (_27 = params.priceSpecification.accounting) === null || _27 === void 0 ? void 0 : _27.operatingRevenue) === null || _28 === void 0 ? void 0 : _28.codeValue) === null || _29 === void 0 ? void 0 : _29.$in;
285
291
  if (Array.isArray(accountingCodeValueIn)) {
286
292
  matchStages.push({
287
293
  $match: {
@@ -292,7 +298,7 @@ class MongoRepository {
292
298
  }
293
299
  });
294
300
  }
295
- const referenceQuantityValueEq = (_29 = (_28 = params.priceSpecification.referenceQuantity) === null || _28 === void 0 ? void 0 : _28.value) === null || _29 === void 0 ? void 0 : _29.$eq;
301
+ const referenceQuantityValueEq = (_31 = (_30 = params.priceSpecification.referenceQuantity) === null || _30 === void 0 ? void 0 : _30.value) === null || _31 === void 0 ? void 0 : _31.$eq;
296
302
  if (typeof referenceQuantityValueEq === 'number') {
297
303
  matchStages.push({
298
304
  $match: {
@@ -304,7 +310,7 @@ class MongoRepository {
304
310
  });
305
311
  }
306
312
  }
307
- const availabilityEq = (_30 = params.availability) === null || _30 === void 0 ? void 0 : _30.$eq;
313
+ const availabilityEq = (_32 = params.availability) === null || _32 === void 0 ? void 0 : _32.$eq;
308
314
  if (typeof availabilityEq === 'string') {
309
315
  matchStages.push({
310
316
  $match: {
@@ -312,7 +318,7 @@ class MongoRepository {
312
318
  }
313
319
  });
314
320
  }
315
- const availableAtOrFromIdEq = (_32 = (_31 = params.availableAtOrFrom) === null || _31 === void 0 ? void 0 : _31.id) === null || _32 === void 0 ? void 0 : _32.$eq;
321
+ const availableAtOrFromIdEq = (_34 = (_33 = params.availableAtOrFrom) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$eq;
316
322
  if (typeof availableAtOrFromIdEq === 'string') {
317
323
  matchStages.push({
318
324
  $match: {
@@ -323,7 +329,7 @@ class MongoRepository {
323
329
  }
324
330
  });
325
331
  }
326
- const availableAtOrFromIdIn = (_34 = (_33 = params.availableAtOrFrom) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$in;
332
+ const availableAtOrFromIdIn = (_36 = (_35 = params.availableAtOrFrom) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$in;
327
333
  if (Array.isArray(availableAtOrFromIdIn)) {
328
334
  matchStages.push({
329
335
  $match: {
@@ -334,7 +340,7 @@ class MongoRepository {
334
340
  }
335
341
  });
336
342
  }
337
- const addOnItemOfferedIdEq = (_37 = (_36 = (_35 = params.addOn) === null || _35 === void 0 ? void 0 : _35.itemOffered) === null || _36 === void 0 ? void 0 : _36.id) === null || _37 === void 0 ? void 0 : _37.$eq;
343
+ const addOnItemOfferedIdEq = (_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.$eq;
338
344
  if (typeof addOnItemOfferedIdEq === 'string') {
339
345
  matchStages.push({
340
346
  $match: {
@@ -342,7 +348,7 @@ class MongoRepository {
342
348
  }
343
349
  });
344
350
  }
345
- const addOnItemOfferedIdIn = (_40 = (_39 = (_38 = params.addOn) === null || _38 === void 0 ? void 0 : _38.itemOffered) === null || _39 === void 0 ? void 0 : _39.id) === null || _40 === void 0 ? void 0 : _40.$in;
351
+ const addOnItemOfferedIdIn = (_42 = (_41 = (_40 = params.addOn) === null || _40 === void 0 ? void 0 : _40.itemOffered) === null || _41 === void 0 ? void 0 : _41.id) === null || _42 === void 0 ? void 0 : _42.$in;
346
352
  if (Array.isArray(addOnItemOfferedIdIn)) {
347
353
  matchStages.push({
348
354
  $match: {
@@ -350,7 +356,7 @@ class MongoRepository {
350
356
  }
351
357
  });
352
358
  }
353
- const hasMerchantReturnPolicyIdEq = (_42 = (_41 = params.hasMerchantReturnPolicy) === null || _41 === void 0 ? void 0 : _41.id) === null || _42 === void 0 ? void 0 : _42.$eq;
359
+ const hasMerchantReturnPolicyIdEq = (_44 = (_43 = params.hasMerchantReturnPolicy) === null || _43 === void 0 ? void 0 : _43.id) === null || _44 === void 0 ? void 0 : _44.$eq;
354
360
  if (typeof hasMerchantReturnPolicyIdEq === 'string') {
355
361
  matchStages.push({
356
362
  $match: {
@@ -361,7 +367,7 @@ class MongoRepository {
361
367
  }
362
368
  });
363
369
  }
364
- const acceptedPaymentMethodIdentifierIn = (_44 = (_43 = params.acceptedPaymentMethod) === null || _43 === void 0 ? void 0 : _43.identifier) === null || _44 === void 0 ? void 0 : _44.$in;
370
+ const acceptedPaymentMethodIdentifierIn = (_46 = (_45 = params.acceptedPaymentMethod) === null || _45 === void 0 ? void 0 : _45.identifier) === null || _46 === void 0 ? void 0 : _46.$in;
365
371
  if (Array.isArray(acceptedPaymentMethodIdentifierIn)) {
366
372
  matchStages.push({
367
373
  $match: {
@@ -372,7 +378,7 @@ class MongoRepository {
372
378
  }
373
379
  });
374
380
  }
375
- const additionalPropertyAll = (_45 = params.additionalProperty) === null || _45 === void 0 ? void 0 : _45.$all;
381
+ const additionalPropertyAll = (_47 = params.additionalProperty) === null || _47 === void 0 ? void 0 : _47.$all;
376
382
  if (Array.isArray(additionalPropertyAll)) {
377
383
  matchStages.push({
378
384
  $match: {
@@ -383,7 +389,7 @@ class MongoRepository {
383
389
  }
384
390
  });
385
391
  }
386
- const additionalPropertyElemMatch = (_46 = params.additionalProperty) === null || _46 === void 0 ? void 0 : _46.$elemMatch;
392
+ const additionalPropertyElemMatch = (_48 = params.additionalProperty) === null || _48 === void 0 ? void 0 : _48.$elemMatch;
387
393
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
388
394
  matchStages.push({
389
395
  $match: {
@@ -32,7 +32,7 @@ class MongoRepository {
32
32
  }
33
33
  // tslint:disable-next-line:max-func-body-length
34
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;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
36
36
  // MongoDB検索条件
37
37
  const andConditions = [];
38
38
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -57,7 +57,11 @@ class MongoRepository {
57
57
  identifier: { $eq: identifierEq }
58
58
  });
59
59
  }
60
- const identifierRegex = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$regex;
60
+ const identifierIn = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$in;
61
+ if (Array.isArray(identifierIn)) {
62
+ andConditions.push({ identifier: { $in: identifierIn } });
63
+ }
64
+ const identifierRegex = (_g = params.identifier) === null || _g === void 0 ? void 0 : _g.$regex;
61
65
  if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
62
66
  andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
63
67
  }
@@ -69,11 +73,11 @@ class MongoRepository {
69
73
  ]
70
74
  });
71
75
  }
72
- const itemListElementTypeOfEq = (_h = (_g = params.itemListElement) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
76
+ const itemListElementTypeOfEq = (_j = (_h = params.itemListElement) === null || _h === void 0 ? void 0 : _h.typeOf) === null || _j === void 0 ? void 0 : _j.$eq;
73
77
  if (typeof itemListElementTypeOfEq === 'string') {
74
78
  andConditions.push({ 'itemListElement.typeOf': { $exists: true, $eq: itemListElementTypeOfEq } });
75
79
  }
76
- const itemListElementIdIn = (_k = (_j = params.itemListElement) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
80
+ const itemListElementIdIn = (_l = (_k = params.itemListElement) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$in;
77
81
  if (Array.isArray(itemListElementIdIn)) {
78
82
  andConditions.push({
79
83
  'itemListElement.id': {
@@ -82,7 +86,7 @@ class MongoRepository {
82
86
  }
83
87
  });
84
88
  }
85
- const itemListElementIdNin = (_m = (_l = params.itemListElement) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$nin;
89
+ const itemListElementIdNin = (_o = (_m = params.itemListElement) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$nin;
86
90
  if (Array.isArray(itemListElementIdNin)) {
87
91
  andConditions.push({
88
92
  'itemListElement.id': {
@@ -90,7 +94,7 @@ class MongoRepository {
90
94
  }
91
95
  });
92
96
  }
93
- const itemListElementIdAll = (_p = (_o = params.itemListElement) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$all;
97
+ const itemListElementIdAll = (_q = (_p = params.itemListElement) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$all;
94
98
  if (Array.isArray(itemListElementIdAll)) {
95
99
  andConditions.push({
96
100
  'itemListElement.id': {
@@ -99,7 +103,7 @@ class MongoRepository {
99
103
  }
100
104
  });
101
105
  }
102
- const itemOfferedTypeOfEq = (_r = (_q = params.itemOffered) === null || _q === void 0 ? void 0 : _q.typeOf) === null || _r === void 0 ? void 0 : _r.$eq;
106
+ const itemOfferedTypeOfEq = (_s = (_r = params.itemOffered) === null || _r === void 0 ? void 0 : _r.typeOf) === null || _s === void 0 ? void 0 : _s.$eq;
103
107
  if (typeof itemOfferedTypeOfEq === 'string') {
104
108
  andConditions.push({
105
109
  'itemOffered.typeOf': {
@@ -108,7 +112,7 @@ class MongoRepository {
108
112
  }
109
113
  });
110
114
  }
111
- 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;
115
+ const itemOfferedServiceTypeCodeValueEq = (_v = (_u = (_t = params.itemOffered) === null || _t === void 0 ? void 0 : _t.serviceType) === null || _u === void 0 ? void 0 : _u.codeValue) === null || _v === void 0 ? void 0 : _v.$eq;
112
116
  if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
113
117
  andConditions.push({
114
118
  'itemOffered.serviceType.codeValue': {
@@ -117,7 +121,7 @@ class MongoRepository {
117
121
  }
118
122
  });
119
123
  }
120
- const additionalPropertyElemMatch = (_v = params.additionalProperty) === null || _v === void 0 ? void 0 : _v.$elemMatch;
124
+ const additionalPropertyElemMatch = (_w = params.additionalProperty) === null || _w === void 0 ? void 0 : _w.$elemMatch;
121
125
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
122
126
  andConditions.push({
123
127
  additionalProperty: {
@@ -33,7 +33,7 @@ class MongoRepository {
33
33
  }
34
34
  // tslint:disable-next-line:max-func-body-length
35
35
  static CREATE_MONGO_CONDITIONS(params) {
36
- 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;
36
+ 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;
37
37
  // MongoDB検索条件
38
38
  const andConditions = [];
39
39
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -52,7 +52,11 @@ class MongoRepository {
52
52
  if (typeof identifierEq === 'string') {
53
53
  andConditions.push({ identifier: { $eq: identifierEq } });
54
54
  }
55
- const identifierRegex = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$regex;
55
+ const identifierIn = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$in;
56
+ if (Array.isArray(identifierIn)) {
57
+ andConditions.push({ identifier: { $in: identifierIn } });
58
+ }
59
+ const identifierRegex = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$regex;
56
60
  if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
57
61
  andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
58
62
  }
@@ -64,35 +68,35 @@ class MongoRepository {
64
68
  ]
65
69
  });
66
70
  }
67
- const itemListElementTypeOfEq = (_g = (_f = params.itemListElement) === null || _f === void 0 ? void 0 : _f.typeOf) === null || _g === void 0 ? void 0 : _g.$eq;
71
+ const itemListElementTypeOfEq = (_h = (_g = params.itemListElement) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
68
72
  if (typeof itemListElementTypeOfEq === 'string') {
69
73
  andConditions.push({ 'itemListElement.typeOf': { $exists: true, $eq: itemListElementTypeOfEq } });
70
74
  }
71
- const itemListElementIdIn = (_j = (_h = params.itemListElement) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
75
+ const itemListElementIdIn = (_k = (_j = params.itemListElement) === null || _j === void 0 ? void 0 : _j.id) === null || _k === void 0 ? void 0 : _k.$in;
72
76
  if (Array.isArray(itemListElementIdIn)) {
73
77
  andConditions.push({ 'itemListElement.id': { $exists: true, $in: itemListElementIdIn } });
74
78
  }
75
- const itemListElementIdNin = (_l = (_k = params.itemListElement) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$nin;
79
+ const itemListElementIdNin = (_m = (_l = params.itemListElement) === null || _l === void 0 ? void 0 : _l.id) === null || _m === void 0 ? void 0 : _m.$nin;
76
80
  if (Array.isArray(itemListElementIdNin)) {
77
81
  andConditions.push({ 'itemListElement.id': { $nin: itemListElementIdNin } });
78
82
  }
79
- const itemListElementIdAll = (_o = (_m = params.itemListElement) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$all;
83
+ const itemListElementIdAll = (_p = (_o = params.itemListElement) === null || _o === void 0 ? void 0 : _o.id) === null || _p === void 0 ? void 0 : _p.$all;
80
84
  if (Array.isArray(itemListElementIdAll)) {
81
85
  andConditions.push({ 'itemListElement.id': { $exists: true, $all: itemListElementIdAll } });
82
86
  }
83
- const itemOfferedTypeOfEq = (_q = (_p = params.itemOffered) === null || _p === void 0 ? void 0 : _p.typeOf) === null || _q === void 0 ? void 0 : _q.$eq;
87
+ const itemOfferedTypeOfEq = (_r = (_q = params.itemOffered) === null || _q === void 0 ? void 0 : _q.typeOf) === null || _r === void 0 ? void 0 : _r.$eq;
84
88
  if (typeof itemOfferedTypeOfEq === 'string') {
85
89
  andConditions.push({ 'itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq } });
86
90
  }
87
- const itemOfferedServiceTypeCodeValueEq = (_t = (_s = (_r = params.itemOffered) === null || _r === void 0 ? void 0 : _r.serviceType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
91
+ 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;
88
92
  if (typeof itemOfferedServiceTypeCodeValueEq === 'string') {
89
93
  andConditions.push({ 'itemOffered.serviceType.codeValue': { $exists: true, $eq: itemOfferedServiceTypeCodeValueEq } });
90
94
  }
91
- const additionalPropertyElemMatch = (_u = params.additionalProperty) === null || _u === void 0 ? void 0 : _u.$elemMatch;
95
+ const additionalPropertyElemMatch = (_v = params.additionalProperty) === null || _v === void 0 ? void 0 : _v.$elemMatch;
92
96
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
93
97
  andConditions.push({ additionalProperty: { $exists: true, $elemMatch: additionalPropertyElemMatch } });
94
98
  }
95
- const appliesToMovieTicketServiceOutputTypeOfIn = (_z = (_y = (_x = (_w = (_v = params.relatedOffer) === null || _v === void 0 ? void 0 : _v.priceSpecification) === null || _w === void 0 ? void 0 : _w.appliesToMovieTicket) === null || _x === void 0 ? void 0 : _x.serviceOutput) === null || _y === void 0 ? void 0 : _y.typeOf) === null || _z === void 0 ? void 0 : _z.$in;
99
+ const appliesToMovieTicketServiceOutputTypeOfIn = (_0 = (_z = (_y = (_x = (_w = params.relatedOffer) === null || _w === void 0 ? void 0 : _w.priceSpecification) === null || _x === void 0 ? void 0 : _x.appliesToMovieTicket) === null || _y === void 0 ? void 0 : _y.serviceOutput) === null || _z === void 0 ? void 0 : _z.typeOf) === null || _0 === void 0 ? void 0 : _0.$in;
96
100
  if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfIn)) {
97
101
  andConditions.push({
98
102
  'relatedOffer.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
@@ -5,12 +5,7 @@ type IKeyOfProjection4paymentService = keyof factory.service.paymentService.ISer
5
5
  /**
6
6
  * 決済サービス検索条件
7
7
  */
8
- type ISearchConditions4paymentService = factory.product.ISearchConditions & {
9
- typeOf?: {
10
- $eq?: factory.service.paymentService.PaymentServiceType;
11
- $in?: factory.service.paymentService.PaymentServiceType[];
12
- };
13
- };
8
+ type ISearchConditions4paymentService = factory.service.paymentService.ISearchConditions;
14
9
  /**
15
10
  * 決済サービスリポジトリ
16
11
  */
@@ -18,7 +13,7 @@ export declare class MongoRepository {
18
13
  private readonly paymentServiceModel;
19
14
  private readonly productModel;
20
15
  constructor(connection: Connection);
21
- static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): FilterQuery<import("@chevre/factory/lib/service/paymentService").IService>[];
16
+ static CREATE_MONGO_CONDITIONS(params: ISearchConditions4paymentService): FilterQuery<import("@chevre/factory/lib/service/paymentService").IService>[];
22
17
  /**
23
18
  * 決済サービスを保管する
24
19
  */
@@ -58,5 +53,6 @@ export declare class MongoRepository {
58
53
  id: string;
59
54
  }): Promise<factory.product.IAvailableChannel>;
60
55
  migratePaymentServicesToNewCollection(): Promise<void>;
56
+ deleteOldPaymentServices(): Promise<import("mongodb").DeleteResult>;
61
57
  }
62
58
  export {};
@@ -165,20 +165,11 @@ class MongoRepository {
165
165
  switch (typeOf) {
166
166
  case factory.service.paymentService.PaymentServiceType.CreditCard:
167
167
  case factory.service.paymentService.PaymentServiceType.MovieTicket:
168
- if (settings_1.USE_PAYMENT_SERVICE_COLLECTION) {
169
- doc = yield this.paymentServiceModel.findOneAndUpdate({
170
- _id: { $eq: params.id },
171
- typeOf: { $eq: typeOf }
172
- }, { $set: setFields }, { upsert: false, new: true, projection: { _id: 1 } })
173
- .exec();
174
- }
175
- else {
176
- doc = yield this.productModel.findOneAndUpdate({
177
- _id: { $eq: params.id },
178
- typeOf: { $eq: typeOf }
179
- }, { $set: setFields }, { upsert: false, new: true, projection: { _id: 1 } })
180
- .exec();
181
- }
168
+ doc = yield this.paymentServiceModel.findOneAndUpdate({
169
+ _id: { $eq: params.id },
170
+ typeOf: { $eq: typeOf }
171
+ }, { $set: setFields }, { upsert: false, new: true, projection: { _id: 1 } })
172
+ .exec();
182
173
  break;
183
174
  default:
184
175
  throw new factory.errors.NotImplemented(`${typeOf} not implemented`);
@@ -187,28 +178,14 @@ class MongoRepository {
187
178
  else {
188
179
  const _b = params.$set, { id } = _b, createParams = __rest(_b, ["id"]);
189
180
  if (params.createIfNotExist === true) {
190
- if (settings_1.USE_PAYMENT_SERVICE_COLLECTION) {
191
- doc = yield this.paymentServiceModel.findOneAndUpdate({
192
- 'project.id': { $eq: createParams.project.id },
193
- typeOf: { $eq: createParams.typeOf }
194
- }, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
195
- .exec();
196
- }
197
- else {
198
- doc = yield this.productModel.findOneAndUpdate({
199
- 'project.id': { $eq: createParams.project.id },
200
- typeOf: { $eq: createParams.typeOf }
201
- }, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
202
- .exec();
203
- }
181
+ doc = yield this.paymentServiceModel.findOneAndUpdate({
182
+ 'project.id': { $eq: createParams.project.id },
183
+ typeOf: { $eq: createParams.typeOf }
184
+ }, { $setOnInsert: createParams }, { new: true, upsert: true, projection: { _id: 1 } })
185
+ .exec();
204
186
  }
205
187
  else {
206
- if (settings_1.USE_PAYMENT_SERVICE_COLLECTION) {
207
- doc = yield this.paymentServiceModel.create(createParams);
208
- }
209
- else {
210
- doc = yield this.productModel.create(createParams);
211
- }
188
+ doc = yield this.paymentServiceModel.create(createParams);
212
189
  }
213
190
  }
214
191
  if (doc === null) {
@@ -224,15 +201,6 @@ class MongoRepository {
224
201
  var _a;
225
202
  return __awaiter(this, void 0, void 0, function* () {
226
203
  const andConditions = MongoRepository.CREATE_MONGO_CONDITIONS(conditions);
227
- // 強制的にtypeOfを絞る
228
- andConditions.push({
229
- typeOf: {
230
- $in: [
231
- factory.service.paymentService.PaymentServiceType.CreditCard,
232
- factory.service.paymentService.PaymentServiceType.MovieTicket
233
- ]
234
- }
235
- });
236
204
  let projection = {};
237
205
  if (Array.isArray(inclusion) && inclusion.length > 0) {
238
206
  inclusion.forEach((field) => {
@@ -253,9 +221,7 @@ class MongoRepository {
253
221
  });
254
222
  }
255
223
  }
256
- const query = (settings_1.USE_PAYMENT_SERVICE_COLLECTION)
257
- ? this.paymentServiceModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection)
258
- : this.productModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
224
+ const query = this.paymentServiceModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
259
225
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
260
226
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
261
227
  query.limit(conditions.limit)
@@ -273,14 +239,8 @@ class MongoRepository {
273
239
  }
274
240
  deletePaymentServiceById(params) {
275
241
  return __awaiter(this, void 0, void 0, function* () {
276
- if (settings_1.USE_PAYMENT_SERVICE_COLLECTION) {
277
- yield this.paymentServiceModel.findOneAndDelete({ _id: params.id })
278
- .exec();
279
- }
280
- else {
281
- yield this.productModel.findOneAndDelete({ _id: params.id })
282
- .exec();
283
- }
242
+ yield this.paymentServiceModel.findOneAndDelete({ _id: params.id })
243
+ .exec();
284
244
  });
285
245
  }
286
246
  /**
@@ -324,7 +284,7 @@ class MongoRepository {
324
284
  const existingPaymentService = doc.toObject();
325
285
  const { _id, id, createdAt, updatedAt, offers } = existingPaymentService, setFields = __rest(existingPaymentService, ["_id", "id", "createdAt", "updatedAt", "offers"]);
326
286
  // tslint:disable-next-line:no-console
327
- console.log('migrating paymentService...', setFields, id, i);
287
+ // console.log('migrating paymentService...', setFields, id, i);
328
288
  yield this.paymentServiceModel.findByIdAndUpdate(id, {
329
289
  // $setOnInsert: { _id },
330
290
  $set: setFields
@@ -335,5 +295,18 @@ class MongoRepository {
335
295
  }));
336
296
  });
337
297
  }
298
+ deleteOldPaymentServices() {
299
+ return __awaiter(this, void 0, void 0, function* () {
300
+ return this.productModel.deleteMany({
301
+ typeOf: {
302
+ $in: [
303
+ factory.service.paymentService.PaymentServiceType.CreditCard,
304
+ factory.service.paymentService.PaymentServiceType.MovieTicket
305
+ ]
306
+ }
307
+ })
308
+ .exec();
309
+ });
310
+ }
338
311
  }
339
312
  exports.MongoRepository = MongoRepository;
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MongoRepository = void 0;
13
13
  const mongoose_1 = require("mongoose");
14
14
  const paymentService_1 = require("./mongoose/schemas/paymentService");
15
- const product_1 = require("./mongoose/schemas/product");
16
15
  const factory = require("../factory");
17
16
  const settings_1 = require("../settings");
18
17
  /**
@@ -20,9 +19,7 @@ const settings_1 = require("../settings");
20
19
  */
21
20
  class MongoRepository {
22
21
  constructor(connection) {
23
- this.paymentServiceModel = (settings_1.USE_PAYMENT_SERVICE_COLLECTION)
24
- ? connection.model(paymentService_1.modelName, (0, paymentService_1.createSchema)())
25
- : connection.model(product_1.modelName, (0, product_1.createSchema)());
22
+ this.paymentServiceModel = connection.model(paymentService_1.modelName, (0, paymentService_1.createSchema)());
26
23
  }
27
24
  /**
28
25
  * 決済サービスプロバイダー検索
@@ -22,18 +22,14 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
+ import type { BulkWriteResult } from 'mongodb';
25
26
  import type { Connection, FilterQuery } from 'mongoose';
26
27
  import * as factory from '../factory';
27
28
  type IKeyOfProjection4product = keyof factory.product.IProduct | '_id';
28
29
  /**
29
30
  * プロダクト検索条件
30
31
  */
31
- type ISearchConditions4product = factory.product.ISearchConditions & {
32
- typeOf?: {
33
- $eq?: factory.product.ProductType;
34
- $in?: factory.product.ProductType[];
35
- };
36
- };
32
+ type ISearchConditions4product = factory.product.ISearchConditions;
37
33
  type IUnsetKey = keyof Pick<factory.product.IProduct, 'additionalProperty' | 'availableChannel' | 'hasOfferCatalog' | 'serviceOutput' | 'serviceType'>;
38
34
  /**
39
35
  * プロダクトリポジトリ
@@ -41,7 +37,7 @@ type IUnsetKey = keyof Pick<factory.product.IProduct, 'additionalProperty' | 'av
41
37
  export declare class MongoRepository {
42
38
  private readonly productModel;
43
39
  constructor(connection: Connection);
44
- static CREATE_MONGO_CONDITIONS(params: factory.product.ISearchConditions): FilterQuery<factory.product.IProduct>[];
40
+ static CREATE_MONGO_CONDITIONS(params: ISearchConditions4product): FilterQuery<factory.product.IProduct>[];
45
41
  /**
46
42
  * プロダクトを検索する
47
43
  */
@@ -70,6 +66,22 @@ export declare class MongoRepository {
70
66
  }): Promise<{
71
67
  id: string;
72
68
  }>;
69
+ /**
70
+ * プロダクトコードをキーにして冪等置換
71
+ */
72
+ upsertManyByProductId(params: {
73
+ $set: factory.product.IProduct & {
74
+ offers?: never;
75
+ };
76
+ $unset?: {
77
+ [key in IUnsetKey]?: 1;
78
+ };
79
+ }[]): Promise<{
80
+ bulkWriteResult: BulkWriteResult;
81
+ modifiedProducts: {
82
+ id: string;
83
+ }[];
84
+ } | void>;
73
85
  /**
74
86
  * プロダクトIDからavailableChannelを取得する
75
87
  */