@infrab4a/connect 0.2.2 → 0.3.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.
- package/bundles/infrab4a-connect.umd.js +58 -16
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/lib/domain/catalog/models/category.js +1 -1
- package/esm2015/lib/domain/general/repository/enums/index.js +2 -1
- package/esm2015/lib/domain/general/repository/enums/update-option-actions.enum.js +9 -0
- package/esm2015/lib/domain/general/repository/types/index.js +2 -1
- package/esm2015/lib/domain/general/repository/types/repository-find-filters.type.js +1 -1
- package/esm2015/lib/domain/general/repository/types/repository-update-params.type.js +2 -0
- package/esm2015/lib/domain/general/repository/update.repository.js +1 -1
- package/esm2015/lib/domain/shopping/models/coupons/coupon.js +1 -1
- package/esm2015/lib/domain/shopping/models/coupons/financial-coupon.js +3 -3
- package/esm2015/lib/infra/firebase/firestore/mixins/with-firestore.mixin.js +11 -2
- package/esm2015/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +28 -4
- package/esm2015/lib/utils/index.js +2 -1
- package/esm2015/lib/utils/types/index.js +2 -0
- package/esm2015/lib/utils/types/prop.type.js +2 -0
- package/fesm2015/infrab4a-connect.js +48 -9
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/lib/domain/catalog/models/category.d.ts +2 -0
- package/lib/domain/general/repository/enums/index.d.ts +1 -0
- package/lib/domain/general/repository/enums/update-option-actions.enum.d.ts +7 -0
- package/lib/domain/general/repository/types/index.d.ts +1 -0
- package/lib/domain/general/repository/types/repository-find-filters.type.d.ts +1 -2
- package/lib/domain/general/repository/types/repository-update-params.type.d.ts +11 -0
- package/lib/domain/general/repository/update.repository.d.ts +2 -1
- package/lib/domain/shopping/models/coupons/coupon.d.ts +3 -3
- package/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +3 -2
- package/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +4 -3
- package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +3 -2
- package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +3 -2
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/types/index.d.ts +1 -0
- package/lib/utils/types/prop.type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('class-transformer'), require('lodash'), require('ts-md5'), require('firebase/app')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'class-transformer', 'lodash', 'ts-md5', 'firebase/app'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), global["class-transformer"], global.lodash, global.tsMd5, global.firebase));
|
|
5
|
-
})(this, (function (exports, classTransformer, lodash, tsMd5, firebase) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('class-transformer'), require('lodash'), require('ts-md5'), require('firebase'), require('firebase/app')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'class-transformer', 'lodash', 'ts-md5', 'firebase', 'firebase/app'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), global["class-transformer"], global.lodash, global.tsMd5, global.firebase, global.firebase$1));
|
|
5
|
+
})(this, (function (exports, classTransformer, lodash, tsMd5, firebase, firebase$1) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
10
|
+
var firebase__default$1 = /*#__PURE__*/_interopDefaultLegacy(firebase$1);
|
|
10
11
|
|
|
11
12
|
var BaseModel = /** @class */ (function () {
|
|
12
13
|
function BaseModel(args) {
|
|
@@ -32,6 +33,15 @@
|
|
|
32
33
|
Where["LIKE"] = "like";
|
|
33
34
|
})(exports.Where || (exports.Where = {}));
|
|
34
35
|
|
|
36
|
+
exports.UpdateOptionActions = void 0;
|
|
37
|
+
(function (UpdateOptionActions) {
|
|
38
|
+
UpdateOptionActions["UPDATE"] = "update";
|
|
39
|
+
UpdateOptionActions["MERGE"] = "merge";
|
|
40
|
+
UpdateOptionActions["REMOVE"] = "remove";
|
|
41
|
+
UpdateOptionActions["REMOVE_FIELD"] = "removeField";
|
|
42
|
+
UpdateOptionActions["NULL"] = "null";
|
|
43
|
+
})(exports.UpdateOptionActions || (exports.UpdateOptionActions = {}));
|
|
44
|
+
|
|
35
45
|
exports.UserType = void 0;
|
|
36
46
|
(function (UserType) {
|
|
37
47
|
UserType["B2C"] = "Cliente Transacional";
|
|
@@ -702,8 +712,8 @@
|
|
|
702
712
|
checkoutType: exports.CheckoutTypes.ECOMMERCE,
|
|
703
713
|
discount: 30,
|
|
704
714
|
user: userId,
|
|
705
|
-
createdAt: Date.now(),
|
|
706
|
-
expiresIn: Date.now() + COUPON_EXPIRATION,
|
|
715
|
+
createdAt: new Date(Date.now()),
|
|
716
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
707
717
|
});
|
|
708
718
|
};
|
|
709
719
|
return FinancialCoupon;
|
|
@@ -971,7 +981,15 @@
|
|
|
971
981
|
var _this = this;
|
|
972
982
|
return {
|
|
973
983
|
toFirestore: function (data) { return data.toPlain(); },
|
|
974
|
-
fromFirestore: function (snap) {
|
|
984
|
+
fromFirestore: function (snap) {
|
|
985
|
+
var data = snap.data();
|
|
986
|
+
Object.keys(data).forEach(function (key) {
|
|
987
|
+
if (data[key] instanceof firebase__default["default"].firestore.Timestamp) {
|
|
988
|
+
data[key] = data[key].toDate();
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
return _this.model.toInstance(Object.assign({ id: snap.id }, data));
|
|
992
|
+
},
|
|
975
993
|
};
|
|
976
994
|
};
|
|
977
995
|
return class_1;
|
|
@@ -1154,6 +1172,19 @@
|
|
|
1154
1172
|
};
|
|
1155
1173
|
|
|
1156
1174
|
var withUpdateFirestore = function (MixinBase) {
|
|
1175
|
+
var getValueFromParams = function (params, field) { var _a; return (lodash.isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
|
|
1176
|
+
var getValueByAction = function (options) {
|
|
1177
|
+
var fieldValues = firebase__default["default"].firestore.FieldValue;
|
|
1178
|
+
if (options.action === exports.UpdateOptionActions.REMOVE_FIELD)
|
|
1179
|
+
return fieldValues.delete();
|
|
1180
|
+
if (Array.isArray(options.value)) {
|
|
1181
|
+
if (options.action === exports.UpdateOptionActions.MERGE)
|
|
1182
|
+
return fieldValues.arrayUnion(options.value);
|
|
1183
|
+
if (options.action === exports.UpdateOptionActions.REMOVE)
|
|
1184
|
+
return fieldValues.arrayRemove(options.value);
|
|
1185
|
+
}
|
|
1186
|
+
return options.value;
|
|
1187
|
+
};
|
|
1157
1188
|
return /** @class */ (function (_super) {
|
|
1158
1189
|
__extends(UpdateFirestore, _super);
|
|
1159
1190
|
function UpdateFirestore() {
|
|
@@ -1161,17 +1192,19 @@
|
|
|
1161
1192
|
}
|
|
1162
1193
|
UpdateFirestore.prototype.update = function (data) {
|
|
1163
1194
|
return __awaiter(this, void 0, void 0, function () {
|
|
1164
|
-
var docRef, doc;
|
|
1165
|
-
return __generator(this, function (
|
|
1166
|
-
switch (
|
|
1195
|
+
var model, keyField, docRef, doc;
|
|
1196
|
+
return __generator(this, function (_b) {
|
|
1197
|
+
switch (_b.label) {
|
|
1167
1198
|
case 0:
|
|
1168
|
-
|
|
1169
|
-
|
|
1199
|
+
model = new this.model();
|
|
1200
|
+
keyField = model.identifierFields().shift();
|
|
1201
|
+
docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
1202
|
+
return [4 /*yield*/, docRef.update(this.paramsToPlain(data))];
|
|
1170
1203
|
case 1:
|
|
1171
|
-
|
|
1204
|
+
_b.sent();
|
|
1172
1205
|
return [4 /*yield*/, docRef.get()];
|
|
1173
1206
|
case 2:
|
|
1174
|
-
doc =
|
|
1207
|
+
doc = _b.sent();
|
|
1175
1208
|
return [2 /*return*/, doc.data()];
|
|
1176
1209
|
}
|
|
1177
1210
|
});
|
|
@@ -1179,9 +1212,18 @@
|
|
|
1179
1212
|
};
|
|
1180
1213
|
UpdateFirestore.prototype.buildCollectionPathForUpdate = function (identifiers) {
|
|
1181
1214
|
return this.isSubCollection(this)
|
|
1182
|
-
? this.parentRepository.collectionName + "/" + identifiers
|
|
1215
|
+
? this.parentRepository.collectionName + "/" + getValueFromParams(identifiers, this.parentIdField) + "/" + this.collectionName
|
|
1183
1216
|
: this.collectionName;
|
|
1184
1217
|
};
|
|
1218
|
+
UpdateFirestore.prototype.paramsToPlain = function (params) {
|
|
1219
|
+
var model = this.model;
|
|
1220
|
+
if (params instanceof model)
|
|
1221
|
+
return params.toPlain();
|
|
1222
|
+
return Object.keys(params).reduce(function (data, currentKey) {
|
|
1223
|
+
var _b;
|
|
1224
|
+
return (Object.assign(Object.assign({}, data), (_b = {}, _b[currentKey] = getValueByAction(data[currentKey]), _b)));
|
|
1225
|
+
}, {});
|
|
1226
|
+
};
|
|
1185
1227
|
return UpdateFirestore;
|
|
1186
1228
|
}(MixinBase));
|
|
1187
1229
|
};
|
|
@@ -1511,7 +1553,7 @@
|
|
|
1511
1553
|
var credentials, user;
|
|
1512
1554
|
return __generator(this, function (_a) {
|
|
1513
1555
|
switch (_a.label) {
|
|
1514
|
-
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default["default"].auth.GoogleAuthProvider())];
|
|
1556
|
+
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default$1["default"].auth.GoogleAuthProvider())];
|
|
1515
1557
|
case 1:
|
|
1516
1558
|
credentials = _a.sent();
|
|
1517
1559
|
user = credentials.user;
|