@infrab4a/connect 2.0.7 → 2.0.9-beta.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.
@@ -3880,7 +3880,7 @@
3880
3880
  return __generator(this, function (_c) {
3881
3881
  switch (_c.label) {
3882
3882
  case 0:
3883
- plainData = this.paramsToPlain({ products: products });
3883
+ if (!('action' in products && products.action === 'remove')) return [3 /*break*/, 2];
3884
3884
  return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
3885
3885
  where: {
3886
3886
  type: 'category_product_bool_exp',
@@ -3889,6 +3889,20 @@
3889
3889
  },
3890
3890
  })];
3891
3891
  case 1:
3892
+ _c.sent();
3893
+ return [2 /*return*/, []];
3894
+ case 2:
3895
+ plainData = this.paramsToPlain({ products: products });
3896
+ if (!plainData.products || plainData.products.length <= 0)
3897
+ return [2 /*return*/, []];
3898
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
3899
+ where: {
3900
+ type: 'category_product_bool_exp',
3901
+ required: true,
3902
+ value: { category_id: { _eq: categoryId } },
3903
+ },
3904
+ })];
3905
+ case 3:
3892
3906
  _c.sent();
3893
3907
  return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
3894
3908
  objects: {
@@ -3897,7 +3911,7 @@
3897
3911
  value: plainData.products.map(function (productId) { return ({ category_id: categoryId, product_id: productId }); }),
3898
3912
  },
3899
3913
  })];
3900
- case 2:
3914
+ case 4:
3901
3915
  _c.sent();
3902
3916
  return [2 /*return*/, plainData.products];
3903
3917
  }
@@ -4032,6 +4046,13 @@
4032
4046
  ],
4033
4047
  },
4034
4048
  },
4049
+ {
4050
+ reviews: {
4051
+ columnName: 'reviews',
4052
+ foreignKeyColumn: { productId: 'id' },
4053
+ fields: _this.reviewsFields,
4054
+ },
4055
+ },
4035
4056
  ]);
4036
4057
  return _this;
4037
4058
  }
@@ -4124,10 +4145,12 @@
4124
4145
  find: { get: function () { return _super_1.prototype.find; } }
4125
4146
  });
4126
4147
  return __awaiter(this, void 0, void 0, function () {
4127
- var _a, filters, options;
4148
+ var _a, filters, fields, options, bindFields;
4128
4149
  return __generator(this, function (_c) {
4129
- _a = params || {}, filters = _a.filters, options = __rest(_a, ["filters"]);
4130
- return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }) }))];
4150
+ _a = params || {}, filters = _a.filters, fields = _a.fields, options = __rest(_a, ["filters", "fields"]);
4151
+ bindFields = fields ||
4152
+ this.fields.map(function (field) { return typeof field === 'string' ? field : Object.keys(field).shift(); });
4153
+ return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }), fields: bindFields }))];
4131
4154
  });
4132
4155
  });
4133
4156
  };
@@ -4236,7 +4259,7 @@
4236
4259
  return __generator(this, function (_c) {
4237
4260
  switch (_c.label) {
4238
4261
  case 0:
4239
- plainData = this.paramsToPlain({ categories: categories });
4262
+ if (!('action' in categories && categories.action === 'remove')) return [3 /*break*/, 2];
4240
4263
  return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
4241
4264
  where: {
4242
4265
  type: 'category_product_bool_exp',
@@ -4245,6 +4268,20 @@
4245
4268
  },
4246
4269
  })];
4247
4270
  case 1:
4271
+ _c.sent();
4272
+ return [2 /*return*/, []];
4273
+ case 2:
4274
+ plainData = this.paramsToPlain({ categories: categories });
4275
+ if (!plainData.categories || plainData.categories.length <= 0)
4276
+ return [2 /*return*/, []];
4277
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
4278
+ where: {
4279
+ type: 'category_product_bool_exp',
4280
+ required: true,
4281
+ value: { product_id: { _eq: productId } },
4282
+ },
4283
+ })];
4284
+ case 3:
4248
4285
  _c.sent();
4249
4286
  return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
4250
4287
  objects: {
@@ -4253,7 +4290,7 @@
4253
4290
  value: plainData.categories.map(function (categoryId) { return ({ category_id: categoryId, product_id: productId }); }),
4254
4291
  },
4255
4292
  })];
4256
- case 2:
4293
+ case 4:
4257
4294
  _c.sent();
4258
4295
  return [2 /*return*/, plainData.categories];
4259
4296
  }
@@ -4303,8 +4340,6 @@
4303
4340
  return __generator(this, function (_c) {
4304
4341
  switch (_c.label) {
4305
4342
  case 0:
4306
- if (!reviews)
4307
- return [2 /*return*/, []];
4308
4343
  if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
4309
4344
  return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
4310
4345
  var review;
@@ -4327,6 +4362,8 @@
4327
4362
  return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
4328
4363
  case 3:
4329
4364
  plainData = this.paramsToPlain({ reviews: reviews });
4365
+ if (!plainData.reviews || plainData.reviews.length <= 0)
4366
+ return [2 /*return*/, []];
4330
4367
  return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
4331
4368
  var review, _c, _d;
4332
4369
  return __generator(this, function (_e) {