@infrab4a/connect 1.0.0-beta.22 → 1.0.0-beta.24
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 +71 -39
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/generic/repository/create.repository.d.ts +2 -2
- package/domain/generic/repository/find.repository.d.ts +2 -1
- package/domain/users/errors/unauthorized.error.d.ts +2 -1
- package/domain/users/errors/user-already-registered.error.d.ts +2 -1
- package/domain/users/errors/weak-password.error.d.ts +2 -1
- package/errors/duplicated-results.error.d.ts +2 -1
- package/errors/invalid-argument.error.d.ts +2 -1
- package/errors/not-found.error.d.ts +2 -1
- package/errors/required-argument.error.d.ts +2 -1
- package/esm2015/domain/generic/repository/create.repository.js +1 -1
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/users/errors/unauthorized.error.js +3 -2
- package/esm2015/domain/users/errors/user-already-registered.error.js +3 -2
- package/esm2015/domain/users/errors/weak-password.error.js +3 -2
- package/esm2015/errors/duplicated-results.error.js +3 -2
- package/esm2015/errors/invalid-argument.error.js +3 -2
- package/esm2015/errors/not-found.error.js +3 -2
- package/esm2015/errors/required-argument.error.js +3 -2
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -2
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +9 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +21 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +3 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +8 -6
- package/fesm2015/infrab4a-connect.js +49 -16
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-md5'), require('axios'), require('firebase'), require('gql-query-builder'), require('node-fetch')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-md5', 'axios', 'firebase', 'gql-query-builder', 'node-fetch'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global["ts-md5"], global.axios, global.firebase, global["gql-query-builder"], global["node-fetch"]));
|
|
5
|
-
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsMd5, axios, firebase, gqlQueryBuilder, fetch) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-custom-error'), require('ts-md5'), require('axios'), require('firebase'), require('gql-query-builder'), require('node-fetch')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-custom-error', 'ts-md5', 'axios', 'firebase', 'gql-query-builder', 'node-fetch'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global.tsCustomError, global["ts-md5"], global.axios, global.firebase, global["gql-query-builder"], global["node-fetch"]));
|
|
5
|
+
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsCustomError, tsMd5, axios, firebase, gqlQueryBuilder, fetch) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -1047,7 +1047,7 @@
|
|
|
1047
1047
|
return _this;
|
|
1048
1048
|
}
|
|
1049
1049
|
return UnauthorizedError;
|
|
1050
|
-
}(
|
|
1050
|
+
}(tsCustomError.CustomError));
|
|
1051
1051
|
|
|
1052
1052
|
exports.SignInMethods = void 0;
|
|
1053
1053
|
(function (SignInMethods) {
|
|
@@ -1106,7 +1106,7 @@
|
|
|
1106
1106
|
return _this;
|
|
1107
1107
|
}
|
|
1108
1108
|
return UserAlreadyRegisteredError;
|
|
1109
|
-
}(
|
|
1109
|
+
}(tsCustomError.CustomError));
|
|
1110
1110
|
|
|
1111
1111
|
var WeakPasswordError = /** @class */ (function (_super) {
|
|
1112
1112
|
__extends(WeakPasswordError, _super);
|
|
@@ -1117,7 +1117,7 @@
|
|
|
1117
1117
|
return _this;
|
|
1118
1118
|
}
|
|
1119
1119
|
return WeakPasswordError;
|
|
1120
|
-
}(
|
|
1120
|
+
}(tsCustomError.CustomError));
|
|
1121
1121
|
|
|
1122
1122
|
var Register = /** @class */ (function () {
|
|
1123
1123
|
function Register(registerService, userRepository) {
|
|
@@ -1612,7 +1612,7 @@
|
|
|
1612
1612
|
return _this;
|
|
1613
1613
|
}
|
|
1614
1614
|
return InvalidArgumentError;
|
|
1615
|
-
}(
|
|
1615
|
+
}(tsCustomError.CustomError));
|
|
1616
1616
|
|
|
1617
1617
|
var RequiredArgumentError = /** @class */ (function (_super) {
|
|
1618
1618
|
__extends(RequiredArgumentError, _super);
|
|
@@ -1623,7 +1623,7 @@
|
|
|
1623
1623
|
return _this;
|
|
1624
1624
|
}
|
|
1625
1625
|
return RequiredArgumentError;
|
|
1626
|
-
}(
|
|
1626
|
+
}(tsCustomError.CustomError));
|
|
1627
1627
|
|
|
1628
1628
|
var NotFoundError = /** @class */ (function (_super) {
|
|
1629
1629
|
__extends(NotFoundError, _super);
|
|
@@ -1633,7 +1633,7 @@
|
|
|
1633
1633
|
return _this;
|
|
1634
1634
|
}
|
|
1635
1635
|
return NotFoundError;
|
|
1636
|
-
}(
|
|
1636
|
+
}(tsCustomError.CustomError));
|
|
1637
1637
|
|
|
1638
1638
|
var DuplicatedResultsError = /** @class */ (function (_super) {
|
|
1639
1639
|
__extends(DuplicatedResultsError, _super);
|
|
@@ -1643,7 +1643,7 @@
|
|
|
1643
1643
|
return _this;
|
|
1644
1644
|
}
|
|
1645
1645
|
return DuplicatedResultsError;
|
|
1646
|
-
}(
|
|
1646
|
+
}(tsCustomError.CustomError));
|
|
1647
1647
|
|
|
1648
1648
|
var AxiosAdapter = /** @class */ (function () {
|
|
1649
1649
|
function AxiosAdapter(config) {
|
|
@@ -2404,7 +2404,9 @@
|
|
|
2404
2404
|
productIds = chunks_1_1.value;
|
|
2405
2405
|
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
2406
2406
|
return [3 /*break*/, 6];
|
|
2407
|
-
return [4 /*yield*/, this.collection('
|
|
2407
|
+
return [4 /*yield*/, this.collection('productsErpVitrine')
|
|
2408
|
+
.where(publishedField, '==', true)
|
|
2409
|
+
.where('id', 'in', productIds)];
|
|
2408
2410
|
case 3:
|
|
2409
2411
|
query = _b.sent();
|
|
2410
2412
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
@@ -2446,7 +2448,7 @@
|
|
|
2446
2448
|
var _this = _super.call(this) || this;
|
|
2447
2449
|
_this.firestore = firestore;
|
|
2448
2450
|
_this.reviews = {};
|
|
2449
|
-
_this.collectionName = '
|
|
2451
|
+
_this.collectionName = 'productsErpVitrine';
|
|
2450
2452
|
_this.model = Product;
|
|
2451
2453
|
return _this;
|
|
2452
2454
|
}
|
|
@@ -3339,18 +3341,18 @@
|
|
|
3339
3341
|
function FindHasuraGraphQLMixin() {
|
|
3340
3342
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3341
3343
|
_this.makeGraphQLWhere = function (filter, fields) { return Object.keys(filter).reduce(function (variables, fieldName) {
|
|
3342
|
-
var
|
|
3344
|
+
var _b;
|
|
3343
3345
|
var columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
|
|
3344
3346
|
if (!columnOption.bindFindFilter)
|
|
3345
|
-
return Object.assign(Object.assign({}, variables), (
|
|
3347
|
+
return Object.assign(Object.assign({}, variables), (_b = {}, _b[columnOption.columnName] = _this.buildWhereSentence(fieldName, filter[fieldName], fields), _b));
|
|
3346
3348
|
var builtFilter = columnOption.bindFindFilter(filter[fieldName]);
|
|
3347
3349
|
return Object.assign(Object.assign({}, variables), Object.keys(builtFilter).reduce(function (variablesList, columnName) {
|
|
3348
|
-
var
|
|
3349
|
-
return (Object.assign(Object.assign({}, variablesList), (
|
|
3350
|
+
var _b;
|
|
3351
|
+
return (Object.assign(Object.assign({}, variablesList), (_b = {}, _b[columnName] = _this.buildWhereSentence(fieldName, builtFilter[columnName], fields), _b)));
|
|
3350
3352
|
}, {}));
|
|
3351
3353
|
}, {}); };
|
|
3352
3354
|
_this.buildWhereSentence = function (field, options, fields) {
|
|
3353
|
-
var
|
|
3355
|
+
var _b;
|
|
3354
3356
|
var fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
3355
3357
|
if (!Array.isArray(options) &&
|
|
3356
3358
|
lodash.isObject(options) &&
|
|
@@ -3358,16 +3360,16 @@
|
|
|
3358
3360
|
lodash.isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
3359
3361
|
lodash.isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
3360
3362
|
return Object.keys(options).reduce(function (variables, key) {
|
|
3361
|
-
var
|
|
3363
|
+
var _b;
|
|
3362
3364
|
var fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
3363
3365
|
var columnName = fieldOptions.columnName;
|
|
3364
3366
|
var columnFields = fieldOptions.fields;
|
|
3365
|
-
return Object.assign(Object.assign({}, variables), (
|
|
3367
|
+
return Object.assign(Object.assign({}, variables), (_b = {}, _b[columnName] = _this.buildWhereSentence(key, options[key], columnFields || []), _b));
|
|
3366
3368
|
}, {});
|
|
3367
3369
|
if (!Array.isArray(options) && !lodash.isNil(fieldSentenceOptions.fields))
|
|
3368
|
-
return
|
|
3369
|
-
|
|
3370
|
-
|
|
3370
|
+
return _b = {},
|
|
3371
|
+
_b[fieldSentenceOptions.fields[0]] = _this.buildOperatorSentence(options, fieldSentenceOptions),
|
|
3372
|
+
_b;
|
|
3371
3373
|
if (lodash.isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
3372
3374
|
options = Object.values(options)[0];
|
|
3373
3375
|
return Array.isArray(options)
|
|
@@ -3375,10 +3377,10 @@
|
|
|
3375
3377
|
: _this.buildOperatorSentence(options, fieldSentenceOptions);
|
|
3376
3378
|
};
|
|
3377
3379
|
_this.buildOperatorSentence = function (options, fieldOption) {
|
|
3378
|
-
var
|
|
3379
|
-
return (
|
|
3380
|
-
|
|
3381
|
-
|
|
3380
|
+
var _b;
|
|
3381
|
+
return (_b = {},
|
|
3382
|
+
_b[_this.getHasuraOperator(options, fieldOption)] = FilterOptionHelper.GetValueFromFilter(options, fieldOption),
|
|
3383
|
+
_b);
|
|
3382
3384
|
};
|
|
3383
3385
|
_this.getHasuraOperator = function (options, fieldOption) { return FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
3384
3386
|
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
@@ -3394,12 +3396,12 @@
|
|
|
3394
3396
|
}
|
|
3395
3397
|
FindHasuraGraphQLMixin.prototype.find = function (options) {
|
|
3396
3398
|
return __awaiter(this, void 0, void 0, function () {
|
|
3397
|
-
var
|
|
3399
|
+
var _b, filters, limits, orderBy, variablesCount, variables, result, data, count;
|
|
3398
3400
|
var _this = this;
|
|
3399
|
-
return __generator(this, function (
|
|
3400
|
-
switch (
|
|
3401
|
+
return __generator(this, function (_c) {
|
|
3402
|
+
switch (_c.label) {
|
|
3401
3403
|
case 0:
|
|
3402
|
-
|
|
3404
|
+
_b = options || {}, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy;
|
|
3403
3405
|
variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy) ? {} : { order_by: { type: this.tableName + "_order_by!", list: true, value: orderBy } })), (lodash.isNil(filters)
|
|
3404
3406
|
? {}
|
|
3405
3407
|
: {
|
|
@@ -3413,7 +3415,14 @@
|
|
|
3413
3415
|
return [4 /*yield*/, this.query([
|
|
3414
3416
|
{
|
|
3415
3417
|
operation: this.tableName,
|
|
3416
|
-
fields:
|
|
3418
|
+
fields: options.fields
|
|
3419
|
+
? options.fields
|
|
3420
|
+
.map(function (fieldName) {
|
|
3421
|
+
var _a;
|
|
3422
|
+
return (_a = _this.fields.find(function (fieldOption) { return fieldOption === fieldName; })) !== null && _a !== void 0 ? _a : _this.fields.find(function (fieldOption) { return Object.keys(fieldOption).shift() === fieldName; });
|
|
3423
|
+
})
|
|
3424
|
+
.filter(Boolean)
|
|
3425
|
+
: this.fields,
|
|
3417
3426
|
variables: variables,
|
|
3418
3427
|
},
|
|
3419
3428
|
{
|
|
@@ -3423,7 +3432,7 @@
|
|
|
3423
3432
|
},
|
|
3424
3433
|
])];
|
|
3425
3434
|
case 1:
|
|
3426
|
-
result =
|
|
3435
|
+
result = _c.sent();
|
|
3427
3436
|
data = result[this.tableName].map(function (row) { return _this.convertDataFromHasura(row); });
|
|
3428
3437
|
count = result[this.tableName + "_aggregate"].aggregate.count;
|
|
3429
3438
|
return [2 /*return*/, { count: count, data: data }];
|
|
@@ -3638,7 +3647,26 @@
|
|
|
3638
3647
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3639
3648
|
products = [];
|
|
3640
3649
|
publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
3641
|
-
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {}))
|
|
3650
|
+
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
|
|
3651
|
+
'id',
|
|
3652
|
+
'name',
|
|
3653
|
+
'slug',
|
|
3654
|
+
'images',
|
|
3655
|
+
'miniatures',
|
|
3656
|
+
'price',
|
|
3657
|
+
'stock',
|
|
3658
|
+
'published',
|
|
3659
|
+
'publishedGlam',
|
|
3660
|
+
'CEST',
|
|
3661
|
+
'EAN',
|
|
3662
|
+
'NCM',
|
|
3663
|
+
'brand',
|
|
3664
|
+
'costPrice',
|
|
3665
|
+
'hasVariants',
|
|
3666
|
+
'isKit',
|
|
3667
|
+
'shopAvailability',
|
|
3668
|
+
'sku',
|
|
3669
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
|
|
3642
3670
|
case 1:
|
|
3643
3671
|
productsData = (_d.sent()).data;
|
|
3644
3672
|
products.push.apply(products, __spreadArray([], __read(productsData)));
|
|
@@ -4019,6 +4047,8 @@
|
|
|
4019
4047
|
return __generator(this, function (_c) {
|
|
4020
4048
|
switch (_c.label) {
|
|
4021
4049
|
case 0:
|
|
4050
|
+
if (!reviews)
|
|
4051
|
+
return [2 /*return*/, []];
|
|
4022
4052
|
if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
|
|
4023
4053
|
return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4024
4054
|
var review;
|
|
@@ -4221,15 +4251,17 @@
|
|
|
4221
4251
|
}, {}); },
|
|
4222
4252
|
bindFindFilter: function (sentence) {
|
|
4223
4253
|
var filters = Object.values(sentence).shift();
|
|
4224
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.price) && { price: filters.price })), (filters.fullPrice && { full_price: filters.fullPrice })), (filters.subscriberDiscountPercentage && {
|
|
4254
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
4225
4255
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
4226
|
-
})), (filters.subscriberPrice
|
|
4256
|
+
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
4257
|
+
subscriber_price: filters.subscriberPrice,
|
|
4258
|
+
}));
|
|
4227
4259
|
},
|
|
4228
|
-
bindPersistData: function (value
|
|
4260
|
+
bindPersistData: function (value) {
|
|
4229
4261
|
var priceData = Object.values(value).shift();
|
|
4230
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) && { price: priceData.price })), (priceData.fullPrice && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage && {
|
|
4262
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
4231
4263
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
4232
|
-
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
4264
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
4233
4265
|
},
|
|
4234
4266
|
},
|
|
4235
4267
|
},
|