@infrab4a/connect 2.0.0-beta.0 → 2.0.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.
@@ -518,7 +518,7 @@ var Exclusivities;
518
518
  Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
519
519
  })(Exclusivities || (Exclusivities = {}));
520
520
 
521
- const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
521
+ const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
522
522
  class Coupon extends BaseModel {
523
523
  get isInfluencer() {
524
524
  return !isNil(this.influencerEmail);
@@ -1273,7 +1273,7 @@ const withFindFirestore = (MixinBase) => {
1273
1273
  if (orderByKeys.length) {
1274
1274
  const filtersKeysWithUnordered = Object.keys(filters || {}).filter((filterKey) => !orderByKeys.includes(filterKey));
1275
1275
  if (filtersKeysWithUnordered.length)
1276
- filtersKeysWithUnordered.forEach((filterKey) => (orderBy = Object.assign({ [filterKey]: 'asc' }, orderBy)));
1276
+ filtersKeysWithUnordered.forEach((filterKey) => (orderBy = Object.assign(Object.assign({}, (![Where.EQUALS].includes(filters[filterKey].operator) ? { [filterKey]: 'asc' } : {})), orderBy)));
1277
1277
  Object.keys(orderBy).forEach((fieldName) => (query = query.orderBy(fieldName, orderBy[fieldName])));
1278
1278
  }
1279
1279
  query = yield this.defineLimits(query, filters, limits);
@@ -2042,7 +2042,9 @@ FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
2042
2042
  return false;
2043
2043
  const converter = fieldOption.to
2044
2044
  ? fieldOption.to
2045
- : (value) => (filter.operator === Where.LIKE && value.indexOf('%') < 0 ? `%${value}%` : value);
2045
+ : (value) => filter.operator === Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
2046
+ ? `%${value}%`
2047
+ : value;
2046
2048
  return Array.isArray(filter.value) && !fieldOption.fields && [Where.IN, Where.NOTIN].includes(filter.operator)
2047
2049
  ? filter.value.map((fieldValue) => converter(fieldValue))
2048
2050
  : converter(filter.value);
@@ -2466,10 +2468,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2466
2468
  type: HasuraGraphQLColumnType.Jsonb,
2467
2469
  from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
2468
2470
  bindPersistData: (value) => {
2469
- var _a, _b;
2470
2471
  return {
2471
2472
  brand_condition: value.brand,
2472
- tag_condition: `{"${((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || ''}"}`,
2473
+ tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
2473
2474
  };
2474
2475
  },
2475
2476
  bindFindFilter: (sentence) => {
@@ -2732,6 +2733,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2732
2733
  const product = Number.isNaN(+identifiers.id)
2733
2734
  ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2734
2735
  : yield _super.get.call(this, identifiers);
2736
+ if (product.productId)
2737
+ throw new NotFoundError('Product not found, it is a variant');
2735
2738
  product.reviews = yield this.findReviewsByProduct(+product.id);
2736
2739
  return product;
2737
2740
  });
@@ -3016,9 +3019,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3016
3019
  });
3017
3020
  var _a;
3018
3021
  return __awaiter(this, void 0, void 0, function* () {
3019
- return Number.isNaN(+identifiers.id)
3022
+ const variant = Number.isNaN(+identifiers.id)
3020
3023
  ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
3021
- : _super.get.call(this, identifiers);
3024
+ : yield _super.get.call(this, identifiers);
3025
+ if (!variant.productId)
3026
+ throw new NotFoundError(`Variant not found, it is a product`);
3027
+ return variant;
3022
3028
  });
3023
3029
  }
3024
3030
  find(params) {