@chevre/domain 21.2.0-alpha.66 → 21.2.0-alpha.68

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,22 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ import { chevre } from '../../../lib/index';
3
+
4
+ import * as mongoose from 'mongoose';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const sellerRepo = new chevre.repository.Seller(mongoose.connection);
12
+ const sellers = await sellerRepo.search({
13
+ hasMerchantReturnPolicy: { itemCondition: { id: { $eq: '646dc7848b3c1437d43dbfeb' } } }
14
+ });
15
+ console.log('sellers:', sellers);
16
+ }
17
+
18
+ main()
19
+ .then(() => {
20
+ console.log('success!');
21
+ })
22
+ .catch(console.error);
@@ -75,3 +75,9 @@ schema.index({ additionalProperty: 1, branchCode: 1 }, {
75
75
  additionalProperty: { $exists: true }
76
76
  }
77
77
  });
78
+ schema.index({ 'hasMerchantReturnPolicy.itemCondition.id': 1, branchCode: 1 }, {
79
+ name: 'searchByHasMerchantReturnPolicyItemConditionId',
80
+ partialFilterExpression: {
81
+ 'hasMerchantReturnPolicy.itemCondition.id': { $exists: true }
82
+ }
83
+ });
@@ -32,21 +32,12 @@ 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;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
36
36
  // MongoDB検索条件
37
37
  const andConditions = [];
38
- // tslint:disable-next-line:no-single-line-block-comment
39
- /* istanbul ignore else */
40
- if (params.project !== undefined) {
41
- if (params.project.id !== undefined && params.project.id !== null) {
42
- if (typeof params.project.id.$eq === 'string') {
43
- andConditions.push({
44
- 'project.id': {
45
- $eq: params.project.id.$eq
46
- }
47
- });
48
- }
49
- }
38
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
39
+ if (typeof projectIdEq === 'string') {
40
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
50
41
  }
51
42
  const nameRegex = params.name;
52
43
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
@@ -67,7 +58,7 @@ class MongoRepository {
67
58
  ]
68
59
  });
69
60
  }
70
- const branchCodeEq = (_a = params.branchCode) === null || _a === void 0 ? void 0 : _a.$eq;
61
+ const branchCodeEq = (_c = params.branchCode) === null || _c === void 0 ? void 0 : _c.$eq;
71
62
  if (typeof branchCodeEq === 'string') {
72
63
  andConditions.push({
73
64
  branchCode: {
@@ -75,7 +66,7 @@ class MongoRepository {
75
66
  }
76
67
  });
77
68
  }
78
- const branchCodeRegex = (_b = params.branchCode) === null || _b === void 0 ? void 0 : _b.$regex;
69
+ const branchCodeRegex = (_d = params.branchCode) === null || _d === void 0 ? void 0 : _d.$regex;
79
70
  if (typeof branchCodeRegex === 'string' && branchCodeRegex.length > 0) {
80
71
  andConditions.push({
81
72
  branchCode: {
@@ -83,7 +74,7 @@ class MongoRepository {
83
74
  }
84
75
  });
85
76
  }
86
- const additionalPropertyAll = (_c = params.additionalProperty) === null || _c === void 0 ? void 0 : _c.$all;
77
+ const additionalPropertyAll = (_e = params.additionalProperty) === null || _e === void 0 ? void 0 : _e.$all;
87
78
  if (Array.isArray(additionalPropertyAll)) {
88
79
  andConditions.push({
89
80
  additionalProperty: {
@@ -92,7 +83,7 @@ class MongoRepository {
92
83
  }
93
84
  });
94
85
  }
95
- const additionalPropertyIn = (_d = params.additionalProperty) === null || _d === void 0 ? void 0 : _d.$in;
86
+ const additionalPropertyIn = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$in;
96
87
  if (Array.isArray(additionalPropertyIn)) {
97
88
  andConditions.push({
98
89
  additionalProperty: {
@@ -101,7 +92,7 @@ class MongoRepository {
101
92
  }
102
93
  });
103
94
  }
104
- const additionalPropertyNin = (_e = params.additionalProperty) === null || _e === void 0 ? void 0 : _e.$nin;
95
+ const additionalPropertyNin = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$nin;
105
96
  if (Array.isArray(additionalPropertyNin)) {
106
97
  andConditions.push({
107
98
  additionalProperty: {
@@ -109,7 +100,7 @@ class MongoRepository {
109
100
  }
110
101
  });
111
102
  }
112
- const additionalPropertyElemMatch = (_f = params.additionalProperty) === null || _f === void 0 ? void 0 : _f.$elemMatch;
103
+ const additionalPropertyElemMatch = (_h = params.additionalProperty) === null || _h === void 0 ? void 0 : _h.$elemMatch;
113
104
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
114
105
  andConditions.push({
115
106
  additionalProperty: {
@@ -118,6 +109,15 @@ class MongoRepository {
118
109
  }
119
110
  });
120
111
  }
112
+ const hasMerchantReturnPolicyItemConditionIdEq = (_l = (_k = (_j = params.hasMerchantReturnPolicy) === null || _j === void 0 ? void 0 : _j.itemCondition) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
113
+ if (typeof hasMerchantReturnPolicyItemConditionIdEq === 'string') {
114
+ andConditions.push({
115
+ 'hasMerchantReturnPolicy.itemCondition.id': {
116
+ $exists: true,
117
+ $eq: hasMerchantReturnPolicyItemConditionIdEq
118
+ }
119
+ });
120
+ }
121
121
  return andConditions;
122
122
  }
123
123
  /**
@@ -237,6 +237,7 @@ function findApplicableReturnPolicy(params) {
237
237
  let applicalbleReturnPolicies = [];
238
238
  if (params.reason === factory.transaction.returnOrder.Reason.Customer) {
239
239
  // 適用可能なポリシーにフィルター
240
+ // tslint:disable-next-line:max-func-body-length
240
241
  applicalbleReturnPolicies = returnPolicies.filter((returnPolicy) => {
241
242
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
242
243
  let satisfyMerchantReturnDays = false;
@@ -285,7 +286,7 @@ function findApplicableReturnPolicy(params) {
285
286
  if (typeof gracePeriodMinValue === 'number') {
286
287
  satisfyGracePeriodMinValue = params.events.every((event) => {
287
288
  return moment(event.startDate)
288
- .isSameOrAfter(moment(params.returningDate)
289
+ .isAfter(moment(params.returningDate)
289
290
  .add(gracePeriodMinValue, 'seconds'));
290
291
  });
291
292
  }
@@ -293,16 +294,17 @@ function findApplicableReturnPolicy(params) {
293
294
  if (typeof (gracePeriodBeforeStartInDaysMax === null || gracePeriodBeforeStartInDaysMax === void 0 ? void 0 : gracePeriodBeforeStartInDaysMax.period.value) === 'number'
294
295
  && typeof gracePeriodBeforeStartInDaysMax.time === 'string') {
295
296
  satisfyGracePeriodInDaysMax = params.events.every((event) => {
296
- const minDate = moment(event.startDate)
297
+ const maxDate = moment(event.startDate)
297
298
  .tz(gracePeriodBeforeStartInDaysMax.timezone)
298
299
  .startOf('days')
299
300
  .subtract(gracePeriodBeforeStartInDaysMax.period.value, 'days')
300
301
  .format('YYYY-MM-DD');
301
- const returnMinDate = moment(`${minDate}T${gracePeriodBeforeStartInDaysMax.time}`)
302
- .tz(gracePeriodBeforeStartInDaysMax.timezone);
302
+ const returnMinDate = moment.tz(`${maxDate}T${gracePeriodBeforeStartInDaysMax.time}`, gracePeriodBeforeStartInDaysMax.timezone);
303
+ debug('returnMinDate:', returnMinDate, 'returningDate:', returningDate);
303
304
  return returnMinDate.isSameOrBefore(moment(returningDate));
304
305
  });
305
306
  }
307
+ debug('gracePeriodBeforeStartInDaysMax:', gracePeriodBeforeStartInDaysMax);
306
308
  const gracePeriodBeforeStartInDaysMin = (_j = (_h = offerItemCondition.itemOffered.serviceOutput) === null || _h === void 0 ? void 0 : _h.reservationFor.gracePeriodBeforeStartInDays) === null || _j === void 0 ? void 0 : _j.min;
307
309
  if (typeof (gracePeriodBeforeStartInDaysMin === null || gracePeriodBeforeStartInDaysMin === void 0 ? void 0 : gracePeriodBeforeStartInDaysMin.period.value) === 'number'
308
310
  && typeof gracePeriodBeforeStartInDaysMin.time === 'string') {
@@ -314,7 +316,7 @@ function findApplicableReturnPolicy(params) {
314
316
  .format('YYYY-MM-DD');
315
317
  const returnMaxDate = moment.tz(`${minDate}T${gracePeriodBeforeStartInDaysMin.time}`, gracePeriodBeforeStartInDaysMin.timezone);
316
318
  debug('returnMaxDate:', returnMaxDate, 'returningDate:', returningDate);
317
- return returnMaxDate.isSameOrAfter(moment(returningDate));
319
+ return returnMaxDate.isAfter(moment(returningDate));
318
320
  });
319
321
  }
320
322
  debug('satisfyGracePeriodInDaysMin:', satisfyGracePeriodInDaysMin);
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.8",
13
- "@cinerino/sdk": "3.156.0",
12
+ "@chevre/factory": "4.313.0-alpha.10",
13
+ "@cinerino/sdk": "3.157.0-alpha.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.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.2.0-alpha.66"
120
+ "version": "21.2.0-alpha.68"
121
121
  }