@infrab4a/connect 0.6.1 → 0.7.1

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 (33) hide show
  1. package/bundles/infrab4a-connect.umd.js +16 -6
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/esm2015/lib/domain/general/model/types/base-model-builder.type.js +1 -1
  4. package/esm2015/lib/domain/general/repository/types/repository-find-filters.type.js +1 -1
  5. package/esm2015/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +10 -4
  6. package/esm2015/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +4 -4
  7. package/esm2015/lib/utils/index.js +3 -3
  8. package/fesm2015/infrab4a-connect.js +13 -7
  9. package/fesm2015/infrab4a-connect.js.map +1 -1
  10. package/lib/domain/general/model/types/base-model-builder.type.d.ts +1 -1
  11. package/lib/domain/general/repository/types/repository-find-filters.type.d.ts +5 -1
  12. package/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +1 -1
  13. package/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +1 -1
  14. package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
  15. package/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -1
  16. package/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +1 -1
  17. package/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +1 -1
  18. package/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +1 -1
  19. package/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +1 -1
  20. package/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +1 -1
  21. package/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +1 -1
  22. package/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +1 -1
  23. package/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +1 -1
  24. package/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +1 -1
  25. package/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +1 -1
  26. package/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +1 -1
  27. package/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +1 -1
  28. package/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +1 -1
  29. package/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +1 -1
  30. package/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +1 -1
  31. package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +1 -1
  32. package/lib/utils/index.d.ts +2 -2
  33. package/package.json +1 -1
@@ -1214,6 +1214,10 @@
1214
1214
  };
1215
1215
 
1216
1216
  var withFindFirestore = function (MixinBase) {
1217
+ var checkIfIsFilterOption = function (filter) { return !lodash.isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
1218
+ var getValueFromFilter = function (filter) {
1219
+ return checkIfIsFilterOption(filter) ? filter.value : filter;
1220
+ };
1217
1221
  return /** @class */ (function (_super) {
1218
1222
  __extends(FindFirestore, _super);
1219
1223
  function FindFirestore() {
@@ -1229,7 +1233,9 @@
1229
1233
  }
1230
1234
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1231
1235
  return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
1232
- return queryReference.where(fieldName.toString(), options.operator, options.value);
1236
+ if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value))
1237
+ return Object.keys(options).reduce(function (queryReferenceWithWhere, key) { return _this.buildWhereSentence(queryReferenceWithWhere, fieldName + "." + key, options[key]); }, queryReference);
1238
+ return queryReference.where(fieldName.toString(), (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1233
1239
  };
1234
1240
  return _this;
1235
1241
  }
@@ -1261,7 +1267,7 @@
1261
1267
  if (!this.isSubCollection(this))
1262
1268
  return this.collectionName;
1263
1269
  var parentIdField = this.parentIdField;
1264
- var parentId = (_a = filters.find(function (groupFilter) { var _a; return Boolean((_a = groupFilter[parentIdField]) === null || _a === void 0 ? void 0 : _a.value); })) === null || _a === void 0 ? void 0 : _a[parentIdField].value;
1270
+ var parentId = getValueFromFilter((_a = filters.find(function (groupFilter) { return Boolean(getValueFromFilter(groupFilter[parentIdField])); })) === null || _a === void 0 ? void 0 : _a[parentIdField]);
1265
1271
  return this.parentRepository.collectionName + "/" + parentId + "/" + this.collectionName;
1266
1272
  };
1267
1273
  FindFirestore.prototype.defineLimits = function (query, filters, limits) {
@@ -1366,7 +1372,7 @@
1366
1372
  model = new this.model();
1367
1373
  keyField = model.identifierFields().shift();
1368
1374
  docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
1369
- return [4 /*yield*/, docRef.update(this.paramsToPlain(data))];
1375
+ return [4 /*yield*/, docRef.set(this.paramsToPlain(data), { merge: true })];
1370
1376
  case 1:
1371
1377
  _b.sent();
1372
1378
  return [4 /*yield*/, docRef.get()];
@@ -1385,11 +1391,11 @@
1385
1391
  UpdateFirestore.prototype.paramsToPlain = function (params) {
1386
1392
  var model = this.model;
1387
1393
  if (params instanceof model)
1388
- return params.toPlain();
1389
- return Object.keys(params).reduce(function (data, currentKey) {
1394
+ return params;
1395
+ return new model(Object.keys(params).reduce(function (data, currentKey) {
1390
1396
  var _b;
1391
1397
  return (Object.assign(Object.assign({}, data), (_b = {}, _b[currentKey] = getValueByAction(params[currentKey]), _b)));
1392
- }, {});
1398
+ }, {}));
1393
1399
  };
1394
1400
  return UpdateFirestore;
1395
1401
  }(MixinBase));
@@ -1952,6 +1958,10 @@
1952
1958
  enumerable: true,
1953
1959
  get: function () { return lodash.isNumber; }
1954
1960
  });
1961
+ Object.defineProperty(exports, 'isObject', {
1962
+ enumerable: true,
1963
+ get: function () { return lodash.isObject; }
1964
+ });
1955
1965
  Object.defineProperty(exports, 'isString', {
1956
1966
  enumerable: true,
1957
1967
  get: function () { return lodash.isString; }