@infrab4a/connect 3.13.3 → 3.13.6-beta.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 +725 -116
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/helpers/index.d.ts +1 -1
- package/domain/catalog/models/category-collection-children.d.ts +1 -2
- package/domain/catalog/models/category-filter.d.ts +1 -1
- package/domain/catalog/models/category.d.ts +1 -2
- package/domain/catalog/models/filter-option.d.ts +1 -2
- package/domain/catalog/models/filter.d.ts +1 -2
- package/domain/catalog/models/kit-product.d.ts +1 -1
- package/domain/catalog/models/product.d.ts +1 -2
- package/domain/catalog/models/variant.d.ts +1 -2
- package/domain/generic/model/base.model.d.ts +9 -5
- package/domain/generic/model/types/base-model-builder.type.d.ts +4 -2
- package/domain/generic/model/types/identifier-model.type.d.ts +6 -5
- package/domain/generic/model/types/model-base-structure.type.d.ts +9 -3
- package/domain/generic/model/types/non-function-property-name.type.d.ts +12 -3
- package/domain/generic/repository/get.repository.d.ts +2 -2
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
- package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
- package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
- package/domain/location/models/address.d.ts +4 -3
- package/domain/shopping/models/checkout.d.ts +5 -6
- package/domain/shopping/models/subscription/checkout.d.ts +3 -4
- package/domain/users/models/subscription/subscription.d.ts +3 -3
- package/domain/users/models/user-address.d.ts +1 -1
- package/domain/users/models/user.d.ts +3 -4
- package/esm2015/domain/catalog/helpers/index.js +2 -2
- package/esm2015/domain/catalog/helpers/round-product-price.helper.js +15 -0
- package/esm2015/domain/catalog/models/category-collection-children.js +1 -4
- package/esm2015/domain/catalog/models/category-filter.js +1 -4
- package/esm2015/domain/catalog/models/category.js +1 -4
- package/esm2015/domain/catalog/models/filter-option.js +1 -4
- package/esm2015/domain/catalog/models/filter.js +1 -4
- package/esm2015/domain/catalog/models/kit-product.js +2 -2
- package/esm2015/domain/catalog/models/product.js +1 -4
- package/esm2015/domain/catalog/models/variant.js +1 -4
- package/esm2015/domain/generic/model/base.model.js +3 -2
- package/esm2015/domain/generic/model/types/base-model-builder.type.js +1 -1
- package/esm2015/domain/generic/model/types/identifier-model.type.js +1 -1
- package/esm2015/domain/generic/model/types/model-base-structure.type.js +1 -1
- package/esm2015/domain/generic/model/types/non-function-property-name.type.js +1 -1
- package/esm2015/domain/generic/repository/get.repository.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-order-by-list.type.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-update-params.type.js +1 -1
- package/esm2015/domain/location/models/address.js +2 -2
- package/esm2015/domain/shopping/models/checkout.js +6 -7
- package/esm2015/domain/shopping/models/order.js +1 -1
- package/esm2015/domain/shopping/models/subscription/checkout.js +6 -6
- package/esm2015/domain/users/models/subscription/subscription.js +6 -6
- package/esm2015/domain/users/models/user-address.js +1 -1
- package/esm2015/domain/users/models/user.js +3 -3
- package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +8 -3
- package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +3 -3
- package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +2 -2
- package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +2 -2
- package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +1 -1
- package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
- package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +1 -1
- package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +19 -14
- package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +1 -1
- package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +23 -18
- package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +19 -3
- package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +5 -3
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +18 -4
- package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +5 -3
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +7 -4
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +7 -5
- package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +1 -1
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/esm2015/utils/decorators/debug.class.decorator.js +7 -0
- package/esm2015/utils/decorators/index.js +3 -0
- package/esm2015/utils/decorators/trace.method.decorator.js +81 -0
- package/esm2015/utils/helpers/class-name.helper.js +15 -0
- package/esm2015/utils/helpers/debug-decorator.helper.js +18 -0
- package/esm2015/utils/helpers/debug.helper.js +150 -0
- package/esm2015/utils/helpers/index.js +5 -0
- package/esm2015/utils/helpers/reflect.helper.js +165 -0
- package/esm2015/utils/index.js +4 -1
- package/esm2015/utils/log.utils.js +9 -0
- package/fesm2015/infrab4a-connect.js +557 -90
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/elasticsearch/adapters/axios.adapter.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +1 -1
- package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +4 -4
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +4 -4
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +1 -1
- package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
- package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +1 -1
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +5 -3
- package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +5 -5
- package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +4 -2
- package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +6 -5
- package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +2 -1
- package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +4 -4
- package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +11 -9
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +5 -4
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +5 -3
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +7 -3
- package/package.json +3 -2
- package/utils/decorators/debug.class.decorator.d.ts +2 -0
- package/utils/decorators/index.d.ts +2 -0
- package/utils/decorators/trace.method.decorator.d.ts +14 -0
- package/utils/helpers/class-name.helper.d.ts +3 -0
- package/utils/helpers/debug-decorator.helper.d.ts +9 -0
- package/utils/helpers/debug.helper.d.ts +60 -0
- package/utils/helpers/index.d.ts +4 -0
- package/utils/helpers/reflect.helper.d.ts +50 -0
- package/utils/index.d.ts +3 -0
- package/utils/log.utils.d.ts +7 -0
- package/esm2015/domain/catalog/helpers/RoundProdutcPriceHelper.js +0 -15
- /package/domain/catalog/helpers/{RoundProdutcPriceHelper.d.ts → round-product-price.helper.d.ts} +0 -0
|
@@ -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-custom-error'), require('axios'), require('firebase'), require('gql-query-builder')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-custom-error', 'axios', 'firebase', 'gql-query-builder'], 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-custom-error"], global.axios, global.firebase, global["gql-query-builder"]));
|
|
5
|
-
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsCustomError, axios, firebase, gqlQueryBuilder) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('rxjs'), require('debug'), require('ts-custom-error'), require('axios'), require('firebase'), require('gql-query-builder')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'rxjs', 'debug', 'ts-custom-error', 'axios', 'firebase', 'gql-query-builder'], 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.rxjs, global.debug, global["ts-custom-error"], global.axios, global.firebase, global["gql-query-builder"]));
|
|
5
|
+
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, rxjs, debug, tsCustomError, axios, firebase, gqlQueryBuilder) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
}
|
|
16
16
|
Object.defineProperty(BaseModel.prototype, "identifier", {
|
|
17
17
|
get: function () {
|
|
18
|
-
var _this = this;
|
|
19
18
|
var fields = this.constructor.identifiersFields.filter(function (field) { return field !== 'identifier'; });
|
|
19
|
+
var data = this;
|
|
20
20
|
return fields.reduce(function (object, field) {
|
|
21
21
|
var _a;
|
|
22
|
-
return (Object.assign(Object.assign({}, object), (_a = {}, _a[field] =
|
|
22
|
+
return (Object.assign(Object.assign({}, object), (_a = {}, _a[field] = data[field], _a)));
|
|
23
23
|
}, {});
|
|
24
24
|
},
|
|
25
25
|
enumerable: false,
|
|
@@ -816,20 +816,560 @@
|
|
|
816
816
|
__metadata("design:type", Payment)
|
|
817
817
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
818
818
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
819
|
+
exports.DebugNamespaces = void 0;
|
|
820
|
+
(function (DebugNamespaces) {
|
|
821
|
+
DebugNamespaces["ROOT"] = "connect";
|
|
822
|
+
DebugNamespaces["TRACE"] = "trace";
|
|
823
|
+
DebugNamespaces["ERROR"] = "error";
|
|
824
|
+
})(exports.DebugNamespaces || (exports.DebugNamespaces = {}));
|
|
825
|
+
var Logger = debug.debug(exports.DebugNamespaces.ROOT);
|
|
826
|
+
|
|
827
|
+
var ReflectHelper = /** @class */ (function () {
|
|
828
|
+
function ReflectHelper() {
|
|
823
829
|
}
|
|
824
|
-
Object.defineProperty(
|
|
830
|
+
Object.defineProperty(ReflectHelper, "items", {
|
|
825
831
|
get: function () {
|
|
826
|
-
return
|
|
832
|
+
return this._items;
|
|
827
833
|
},
|
|
828
834
|
enumerable: false,
|
|
829
835
|
configurable: true
|
|
830
836
|
});
|
|
831
|
-
|
|
832
|
-
|
|
837
|
+
Object.defineProperty(ReflectHelper, "keys", {
|
|
838
|
+
get: function () {
|
|
839
|
+
return Object.keys(ReflectHelper.items);
|
|
840
|
+
},
|
|
841
|
+
enumerable: false,
|
|
842
|
+
configurable: true
|
|
843
|
+
});
|
|
844
|
+
ReflectHelper.has = function (key, target, property) {
|
|
845
|
+
return (!lodash.isNil(key) &&
|
|
846
|
+
!lodash.isNil(ReflectHelper.items[key]) &&
|
|
847
|
+
(lodash.isNil(target) ||
|
|
848
|
+
(!lodash.isNil(ReflectHelper.items[key][target]) &&
|
|
849
|
+
(lodash.isNil(property) || !lodash.isNil(ReflectHelper.items[key][target][String(property)])))));
|
|
850
|
+
};
|
|
851
|
+
ReflectHelper.get = function (_a) {
|
|
852
|
+
var key = _a.key, target = _a.target, property = _a.property, _b = _a.own, own = _b === void 0 ? true : _b;
|
|
853
|
+
try {
|
|
854
|
+
if (own) {
|
|
855
|
+
return Reflect.getOwnMetadata(key, target, property) || null;
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
return Reflect.getMetadata(key, target, property) || null;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
catch (_err) {
|
|
862
|
+
return null;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
ReflectHelper.first = function (_a) {
|
|
866
|
+
var key = _a.key, target = _a.target, property = _a.property, _b = _a.own, own = _b === void 0 ? true : _b;
|
|
867
|
+
var values = ReflectHelper.get({ key: key, target: target, property: property, own: own });
|
|
868
|
+
return lodash.isArray(values) ? lodash.first(values) : values;
|
|
869
|
+
};
|
|
870
|
+
ReflectHelper.last = function (_a) {
|
|
871
|
+
var key = _a.key, target = _a.target, property = _a.property, _b = _a.own, own = _b === void 0 ? true : _b;
|
|
872
|
+
var values = ReflectHelper.get({ key: key, target: target, property: property, own: own });
|
|
873
|
+
return lodash.isArray(values) ? lodash.last(values) : values;
|
|
874
|
+
};
|
|
875
|
+
ReflectHelper.set = function (_a) {
|
|
876
|
+
var key = _a.key, target = _a.target, property = _a.property, value = _a.value, propertyDescriptor = _a.propertyDescriptor;
|
|
877
|
+
Reflect.defineMetadata(key, value, target, property);
|
|
878
|
+
ReflectHelper.put({ key: key, target: target, property: property, value: value, propertyDescriptor: propertyDescriptor });
|
|
879
|
+
};
|
|
880
|
+
ReflectHelper.add = function (_a) {
|
|
881
|
+
var key = _a.key, target = _a.target, property = _a.property, value = _a.value, propertyDescriptor = _a.propertyDescriptor;
|
|
882
|
+
var values = ReflectHelper.get({ key: key, target: target, property: property }) || new Array();
|
|
883
|
+
if (!Array.isArray(values))
|
|
884
|
+
values = [values];
|
|
885
|
+
values.push(value);
|
|
886
|
+
ReflectHelper.set({ key: key, target: target, property: property, value: values, propertyDescriptor: propertyDescriptor });
|
|
887
|
+
};
|
|
888
|
+
ReflectHelper.all = function (_a) {
|
|
889
|
+
var _this = this;
|
|
890
|
+
var key = _a.key;
|
|
891
|
+
var items = ReflectHelper.items[key] || {};
|
|
892
|
+
return lodash.flatten(Object.keys(items).map(function (item) { return lodash.flatten(_this.allFrom(key, items[item])); }));
|
|
893
|
+
};
|
|
894
|
+
ReflectHelper.allFrom = function (key, target) {
|
|
895
|
+
var _this = this;
|
|
896
|
+
return Object.keys(target)
|
|
897
|
+
.filter(function (property) { return property !== 'object'; })
|
|
898
|
+
.map(function (property) { return _this.allValuesFrom(key, target, property); });
|
|
899
|
+
};
|
|
900
|
+
ReflectHelper.allValuesFrom = function (key, target, property) {
|
|
901
|
+
var values = target[property];
|
|
902
|
+
var value = values.value;
|
|
903
|
+
var propertyDescriptor = values.propertyDescriptor;
|
|
904
|
+
if (!lodash.isArray(value))
|
|
905
|
+
value = [value];
|
|
906
|
+
return lodash.flatten(value.map(function (val) {
|
|
907
|
+
return {
|
|
908
|
+
key: key,
|
|
909
|
+
target: target.object,
|
|
910
|
+
property: property,
|
|
911
|
+
value: val,
|
|
912
|
+
propertyDescriptor: propertyDescriptor,
|
|
913
|
+
};
|
|
914
|
+
}));
|
|
915
|
+
};
|
|
916
|
+
ReflectHelper.delete = function (_a) {
|
|
917
|
+
var key = _a.key, target = _a.target, property = _a.property;
|
|
918
|
+
Reflect.deleteMetadata(key, target, property);
|
|
919
|
+
return ReflectHelper.remove(key, target, property);
|
|
920
|
+
};
|
|
921
|
+
ReflectHelper.clear = function (key) {
|
|
922
|
+
if (!key) {
|
|
923
|
+
ReflectHelper.keys.forEach(function (storedKey) {
|
|
924
|
+
ReflectHelper.clear(storedKey);
|
|
925
|
+
});
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
if (ReflectHelper.keys.includes(key)) {
|
|
929
|
+
Object.values(ReflectHelper.items[key]).forEach(function (target) {
|
|
930
|
+
if (ReflectHelper.has(key, target)) {
|
|
931
|
+
Object.values(ReflectHelper.items[key][target]).forEach(function (property) {
|
|
932
|
+
ReflectHelper.delete({
|
|
933
|
+
key: key,
|
|
934
|
+
target: target.object,
|
|
935
|
+
property: String(property),
|
|
936
|
+
});
|
|
937
|
+
ReflectHelper.remove(key, target, String(property));
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
ReflectHelper.delete({ key: key, target: target.object });
|
|
941
|
+
ReflectHelper.remove(key, target);
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
ReflectHelper.getType = function (_a) {
|
|
947
|
+
var target = _a.target, propertyKey = _a.propertyKey;
|
|
948
|
+
return Reflect.getMetadata('design:type', target, propertyKey);
|
|
949
|
+
};
|
|
950
|
+
ReflectHelper.getReturntype = function (_a) {
|
|
951
|
+
var target = _a.target, propertyKey = _a.propertyKey;
|
|
952
|
+
return Reflect.getMetadata('design:returntype', target, propertyKey);
|
|
953
|
+
};
|
|
954
|
+
ReflectHelper.getAllMethods = function (target) {
|
|
955
|
+
var props = [];
|
|
956
|
+
var obj = target;
|
|
957
|
+
do {
|
|
958
|
+
props.push.apply(props, __spreadArray([], __read(Object.getOwnPropertyNames(obj))));
|
|
959
|
+
} while ((obj = Object.getPrototypeOf(obj)));
|
|
960
|
+
return props.sort().filter(function (e, i, arr) {
|
|
961
|
+
if ([
|
|
962
|
+
'__defineGetter__',
|
|
963
|
+
'__defineSetter__',
|
|
964
|
+
'__lookupGetter__',
|
|
965
|
+
'__lookupSetter__',
|
|
966
|
+
'constructor',
|
|
967
|
+
'hasOwnProperty',
|
|
968
|
+
'isPrototypeOf',
|
|
969
|
+
'propertyIsEnumerable',
|
|
970
|
+
'toLocaleString',
|
|
971
|
+
'toString',
|
|
972
|
+
'valueOf',
|
|
973
|
+
].includes(e))
|
|
974
|
+
return false;
|
|
975
|
+
if (e != arr[i + 1] && typeof target[e] === 'function')
|
|
976
|
+
return true;
|
|
977
|
+
});
|
|
978
|
+
};
|
|
979
|
+
ReflectHelper.put = function (_a) {
|
|
980
|
+
var key = _a.key, target = _a.target, property = _a.property, value = _a.value, propertyDescriptor = _a.propertyDescriptor;
|
|
981
|
+
var index = target.constructor.name;
|
|
982
|
+
ReflectHelper.items[key] = ReflectHelper.items[key] || {};
|
|
983
|
+
ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
|
|
984
|
+
ReflectHelper.items[key][index].object = target;
|
|
985
|
+
if (lodash.isNil(property)) {
|
|
986
|
+
ReflectHelper.items[key][index].value = {
|
|
987
|
+
value: value,
|
|
988
|
+
propertyDescriptor: propertyDescriptor,
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
else {
|
|
992
|
+
ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
|
|
993
|
+
ReflectHelper.items[key][index][String(property)] = {
|
|
994
|
+
value: value,
|
|
995
|
+
propertyDescriptor: propertyDescriptor,
|
|
996
|
+
};
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
ReflectHelper.remove = function (key, target, property) {
|
|
1000
|
+
if (ReflectHelper.has(key, target, property))
|
|
1001
|
+
return delete ReflectHelper.items[key][target][String(property)];
|
|
1002
|
+
else if (ReflectHelper.has(key, target))
|
|
1003
|
+
return delete ReflectHelper.items[key][target];
|
|
1004
|
+
else if (ReflectHelper.has(key))
|
|
1005
|
+
return delete ReflectHelper.items[key];
|
|
1006
|
+
else
|
|
1007
|
+
return false;
|
|
1008
|
+
};
|
|
1009
|
+
return ReflectHelper;
|
|
1010
|
+
}());
|
|
1011
|
+
ReflectHelper._items = {};
|
|
1012
|
+
|
|
1013
|
+
var DebugDecoratorHelper = /** @class */ (function () {
|
|
1014
|
+
function DebugDecoratorHelper() {
|
|
1015
|
+
}
|
|
1016
|
+
DebugDecoratorHelper.set = function (target, options) {
|
|
1017
|
+
ReflectHelper.add({
|
|
1018
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
1019
|
+
target: target,
|
|
1020
|
+
value: options,
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
1023
|
+
DebugDecoratorHelper.get = function (target) {
|
|
1024
|
+
return ReflectHelper.first({
|
|
1025
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
1026
|
+
target: target,
|
|
1027
|
+
});
|
|
1028
|
+
};
|
|
1029
|
+
return DebugDecoratorHelper;
|
|
1030
|
+
}());
|
|
1031
|
+
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
1032
|
+
|
|
1033
|
+
var ClassNameHelper = /** @class */ (function () {
|
|
1034
|
+
function ClassNameHelper() {
|
|
1035
|
+
}
|
|
1036
|
+
ClassNameHelper.get = function (clazz) {
|
|
1037
|
+
if (!clazz)
|
|
1038
|
+
return null;
|
|
1039
|
+
var prototype = Object.getPrototypeOf(clazz);
|
|
1040
|
+
var names = lodash.compact([
|
|
1041
|
+
lodash.get(clazz, 'constructor.name'),
|
|
1042
|
+
lodash.get(prototype, 'constructor.name'),
|
|
1043
|
+
lodash.get(prototype, '__proto__.constructor.name'),
|
|
1044
|
+
]);
|
|
1045
|
+
return names.find(function (name) { return name !== 'class_1'; });
|
|
1046
|
+
};
|
|
1047
|
+
return ClassNameHelper;
|
|
1048
|
+
}());
|
|
1049
|
+
|
|
1050
|
+
var isDebuggable = function (object) {
|
|
1051
|
+
return 'debug' in object;
|
|
1052
|
+
};
|
|
1053
|
+
var DebugHelper = /** @class */ (function () {
|
|
1054
|
+
function DebugHelper() {
|
|
1055
|
+
var namespace = [];
|
|
1056
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1057
|
+
namespace[_i] = arguments[_i];
|
|
1058
|
+
}
|
|
1059
|
+
this.namespaces = new Set();
|
|
1060
|
+
this.push.apply(this, __spreadArray([], __read(namespace)));
|
|
1061
|
+
}
|
|
1062
|
+
DebugHelper.namespacesFor = function (target) {
|
|
1063
|
+
if (lodash.isNil(target))
|
|
1064
|
+
return [];
|
|
1065
|
+
var decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
|
|
1066
|
+
var namespaces = lodash.get(decorator, 'namespaces', []);
|
|
1067
|
+
var name = lodash.get(decorator, 'name', ClassNameHelper.get(target));
|
|
1068
|
+
return __spreadArray(__spreadArray([], __read(namespaces)), [name]);
|
|
1069
|
+
};
|
|
1070
|
+
DebugHelper.as = function () {
|
|
1071
|
+
var namespaces = [];
|
|
1072
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1073
|
+
namespaces[_i] = arguments[_i];
|
|
1074
|
+
}
|
|
1075
|
+
return new (DebugHelper.bind.apply(DebugHelper, __spreadArray([void 0], __read(namespaces))))();
|
|
1076
|
+
};
|
|
1077
|
+
DebugHelper.for = function (target) {
|
|
1078
|
+
var namespaces = [];
|
|
1079
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1080
|
+
namespaces[_i - 1] = arguments[_i];
|
|
1081
|
+
}
|
|
1082
|
+
var targetNamespaces = this.namespacesFor(target);
|
|
1083
|
+
return new (DebugHelper.bind.apply(DebugHelper, __spreadArray(__spreadArray([void 0], __read(targetNamespaces)), __read(namespaces))))();
|
|
1084
|
+
};
|
|
1085
|
+
DebugHelper.from = function (target) {
|
|
1086
|
+
var namespaces = [];
|
|
1087
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1088
|
+
namespaces[_i - 1] = arguments[_i];
|
|
1089
|
+
}
|
|
1090
|
+
if (this.isDebuggable(target)) {
|
|
1091
|
+
var debug = target.debug;
|
|
1092
|
+
if (namespaces)
|
|
1093
|
+
debug.push.apply(debug, __spreadArray([], __read(namespaces)));
|
|
1094
|
+
return debug;
|
|
1095
|
+
}
|
|
1096
|
+
return DebugHelper.for.apply(DebugHelper, __spreadArray([target], __read(namespaces)));
|
|
1097
|
+
};
|
|
1098
|
+
DebugHelper.clonedFrom = function (target) {
|
|
1099
|
+
var namespaces = [];
|
|
1100
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1101
|
+
namespaces[_i - 1] = arguments[_i];
|
|
1102
|
+
}
|
|
1103
|
+
if (this.isDebuggable(target)) {
|
|
1104
|
+
namespaces.push.apply(namespaces, __spreadArray([], __read(target.debug.entries)));
|
|
1105
|
+
}
|
|
1106
|
+
else if (!lodash.isNil(target)) {
|
|
1107
|
+
namespaces.push.apply(namespaces, __spreadArray([], __read(this.namespacesFor(target))));
|
|
1108
|
+
}
|
|
1109
|
+
return DebugHelper.for.apply(DebugHelper, __spreadArray([target], __read(namespaces)));
|
|
1110
|
+
};
|
|
1111
|
+
DebugHelper.clone = function (target) {
|
|
1112
|
+
var namespaces = [];
|
|
1113
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1114
|
+
namespaces[_i - 1] = arguments[_i];
|
|
1115
|
+
}
|
|
1116
|
+
var original;
|
|
1117
|
+
if (this.isDebuggable(target)) {
|
|
1118
|
+
original = target.debug;
|
|
1119
|
+
namespaces.push.apply(namespaces, __spreadArray([], __read(original.entries)));
|
|
1120
|
+
}
|
|
1121
|
+
return {
|
|
1122
|
+
original: original,
|
|
1123
|
+
debug: DebugHelper.for.apply(DebugHelper, __spreadArray([target], __read(namespaces))),
|
|
1124
|
+
};
|
|
1125
|
+
};
|
|
1126
|
+
DebugHelper.replace = function (target, attrs) {
|
|
1127
|
+
if (this.isDebuggable(target))
|
|
1128
|
+
target.debug = attrs.with;
|
|
1129
|
+
};
|
|
1130
|
+
DebugHelper.mock = function (target) {
|
|
1131
|
+
var namespaces = [];
|
|
1132
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1133
|
+
namespaces[_i - 1] = arguments[_i];
|
|
1134
|
+
}
|
|
1135
|
+
var _a = DebugHelper.clone.apply(DebugHelper, __spreadArray([target], __read(namespaces))), original = _a.original, debug = _a.debug;
|
|
1136
|
+
DebugHelper.replace(target, { with: debug });
|
|
1137
|
+
return { original: original, debug: debug };
|
|
1138
|
+
};
|
|
1139
|
+
Object.defineProperty(DebugHelper.prototype, "entries", {
|
|
1140
|
+
get: function () {
|
|
1141
|
+
return Array.from(lodash.get(this, 'namespaces', []));
|
|
1142
|
+
},
|
|
1143
|
+
enumerable: false,
|
|
1144
|
+
configurable: true
|
|
1145
|
+
});
|
|
1146
|
+
Object.defineProperty(DebugHelper.prototype, "namespace", {
|
|
1147
|
+
get: function () {
|
|
1148
|
+
return lodash.compact(lodash.flatten(this.entries)).join(':');
|
|
1149
|
+
},
|
|
1150
|
+
enumerable: false,
|
|
1151
|
+
configurable: true
|
|
1152
|
+
});
|
|
1153
|
+
DebugHelper.prototype.log = function (message) {
|
|
1154
|
+
var args = [];
|
|
1155
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1156
|
+
args[_i - 1] = arguments[_i];
|
|
1157
|
+
}
|
|
1158
|
+
this.logger.apply(this, __spreadArray([JSON.stringify(message)], __read(args.map(function (element) { return JSON.stringify(element); }))));
|
|
1159
|
+
DebugHelper.logs$.next({ namespace: this.namespace, message: message, args: args });
|
|
1160
|
+
return this;
|
|
1161
|
+
};
|
|
1162
|
+
DebugHelper.prototype.trace = function (message) {
|
|
1163
|
+
var args = [];
|
|
1164
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1165
|
+
args[_i - 1] = arguments[_i];
|
|
1166
|
+
}
|
|
1167
|
+
this.logger.extend(exports.DebugNamespaces.TRACE).apply(void 0, __spreadArray([message], __read(args)));
|
|
1168
|
+
DebugHelper.traces$.next({ namespace: this.namespace, message: message, args: args });
|
|
1169
|
+
return this;
|
|
1170
|
+
};
|
|
1171
|
+
DebugHelper.prototype.error = function (error) {
|
|
1172
|
+
var args = [];
|
|
1173
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1174
|
+
args[_i - 1] = arguments[_i];
|
|
1175
|
+
}
|
|
1176
|
+
this.logger.extend(exports.DebugNamespaces.ERROR).apply(void 0, __spreadArray([JSON.stringify(error)], __read(args.map(function (element) { return JSON.stringify(element); }))));
|
|
1177
|
+
DebugHelper.errors$.next({ namespace: this.namespace, error: error, args: args });
|
|
1178
|
+
return this;
|
|
1179
|
+
};
|
|
1180
|
+
DebugHelper.prototype.build = function () {
|
|
1181
|
+
var _this = this;
|
|
1182
|
+
this.logger = Logger;
|
|
1183
|
+
this.tracer = Logger;
|
|
1184
|
+
this.err = Logger;
|
|
1185
|
+
this.entries.forEach(function (namespace) {
|
|
1186
|
+
_this.logger = _this.logger.extend(namespace);
|
|
1187
|
+
_this.tracer = _this.tracer.extend(namespace);
|
|
1188
|
+
_this.err = _this.err.extend(namespace);
|
|
1189
|
+
});
|
|
1190
|
+
return this;
|
|
1191
|
+
};
|
|
1192
|
+
DebugHelper.prototype.with = function () {
|
|
1193
|
+
var namespace = [];
|
|
1194
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1195
|
+
namespace[_i] = arguments[_i];
|
|
1196
|
+
}
|
|
1197
|
+
return new (DebugHelper.bind.apply(DebugHelper, __spreadArray(__spreadArray([void 0], __read(this.entries)), __read(namespace))))();
|
|
1198
|
+
};
|
|
1199
|
+
DebugHelper.prototype.push = function () {
|
|
1200
|
+
var _this = this;
|
|
1201
|
+
var namespace = [];
|
|
1202
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1203
|
+
namespace[_i] = arguments[_i];
|
|
1204
|
+
}
|
|
1205
|
+
if (namespace) {
|
|
1206
|
+
namespace.filter(function (item) { return Boolean(item); }).forEach(function (item) { return _this.namespaces.add(item); });
|
|
1207
|
+
}
|
|
1208
|
+
return this.build();
|
|
1209
|
+
};
|
|
1210
|
+
DebugHelper.prototype.unshift = function () {
|
|
1211
|
+
var namespace = [];
|
|
1212
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1213
|
+
namespace[_i] = arguments[_i];
|
|
1214
|
+
}
|
|
1215
|
+
if (namespace) {
|
|
1216
|
+
return this.reset.apply(this, __spreadArray(__spreadArray([], __read(namespace)), __read(this.entries)));
|
|
1217
|
+
}
|
|
1218
|
+
return this;
|
|
1219
|
+
};
|
|
1220
|
+
DebugHelper.prototype.reset = function () {
|
|
1221
|
+
var namespace = [];
|
|
1222
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1223
|
+
namespace[_i] = arguments[_i];
|
|
1224
|
+
}
|
|
1225
|
+
this.namespaces = new Set(lodash.flatten(lodash.compact(namespace)));
|
|
1226
|
+
return this.build();
|
|
1227
|
+
};
|
|
1228
|
+
DebugHelper.prototype.startWith = function () {
|
|
1229
|
+
var namespace = [];
|
|
1230
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1231
|
+
namespace[_i] = arguments[_i];
|
|
1232
|
+
}
|
|
1233
|
+
var current = this.namespaces;
|
|
1234
|
+
this.namespaces = new Set(lodash.flatten(__spreadArray([lodash.compact(namespace)], __read(current))));
|
|
1235
|
+
return this.build();
|
|
1236
|
+
};
|
|
1237
|
+
DebugHelper.prototype.shift = function () {
|
|
1238
|
+
var list = this.entries;
|
|
1239
|
+
list.shift();
|
|
1240
|
+
return this.reset.apply(this, __spreadArray([], __read(list)));
|
|
1241
|
+
};
|
|
1242
|
+
DebugHelper.prototype.pop = function () {
|
|
1243
|
+
var list = this.entries;
|
|
1244
|
+
list.pop();
|
|
1245
|
+
return this.reset.apply(this, __spreadArray([], __read(list)));
|
|
1246
|
+
};
|
|
1247
|
+
DebugHelper.prototype.clear = function () {
|
|
1248
|
+
return this.reset();
|
|
1249
|
+
};
|
|
1250
|
+
DebugHelper.prototype.remove = function () {
|
|
1251
|
+
var _this = this;
|
|
1252
|
+
var namespace = [];
|
|
1253
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1254
|
+
namespace[_i] = arguments[_i];
|
|
1255
|
+
}
|
|
1256
|
+
if (namespace) {
|
|
1257
|
+
namespace.filter(function (item) { return Boolean(item); }).forEach(function (item) { return _this.namespaces.delete(item); });
|
|
1258
|
+
}
|
|
1259
|
+
return this.build();
|
|
1260
|
+
};
|
|
1261
|
+
DebugHelper.prototype.puts = function () {
|
|
1262
|
+
var args = [];
|
|
1263
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1264
|
+
args[_i] = arguments[_i];
|
|
1265
|
+
}
|
|
1266
|
+
return __spreadArray(["[" + this.namespace + "]"], __read(args)).join(' ');
|
|
1267
|
+
};
|
|
1268
|
+
return DebugHelper;
|
|
1269
|
+
}());
|
|
1270
|
+
DebugHelper.logs$ = new rxjs.Subject();
|
|
1271
|
+
DebugHelper.traces$ = new rxjs.Subject();
|
|
1272
|
+
DebugHelper.errors$ = new rxjs.Subject();
|
|
1273
|
+
DebugHelper.isDebuggable = isDebuggable;
|
|
1274
|
+
|
|
1275
|
+
function Debug(opts) {
|
|
1276
|
+
return function (target) {
|
|
1277
|
+
DebugDecoratorHelper.set(target.prototype, opts);
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
var ASYNC_IDENTIFIER = 'async';
|
|
1282
|
+
function Log(options) {
|
|
1283
|
+
if (options === void 0) { options = {}; }
|
|
1284
|
+
return Trace(Object.assign({ level: 'log' }, options));
|
|
1285
|
+
}
|
|
1286
|
+
function Trace(options) {
|
|
1287
|
+
if (options === void 0) { options = {}; }
|
|
1288
|
+
return function (target, propertyKey, propertyDescriptor) {
|
|
1289
|
+
var method = propertyDescriptor.value;
|
|
1290
|
+
var isPromise = method.toString().includes(ASYNC_IDENTIFIER);
|
|
1291
|
+
var args = {
|
|
1292
|
+
options: options,
|
|
1293
|
+
method: method,
|
|
1294
|
+
target: target,
|
|
1295
|
+
propertyKey: propertyKey,
|
|
1296
|
+
propertyDescriptor: propertyDescriptor,
|
|
1297
|
+
};
|
|
1298
|
+
propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
|
|
1299
|
+
return propertyDescriptor;
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
var traceCall = function (_a) {
|
|
1303
|
+
var target = _a.target, propertyKey = _a.propertyKey, propertyDescriptor = _a.propertyDescriptor, args = _a.args;
|
|
1304
|
+
if (!target.debug)
|
|
1305
|
+
target.debug = DebugHelper.for(target, propertyKey);
|
|
1306
|
+
return target.debug.push(propertyKey).trace('called', { target: target, propertyKey: propertyKey, propertyDescriptor: propertyDescriptor, args: args });
|
|
1307
|
+
};
|
|
1308
|
+
var promiseTracer = function (_a) {
|
|
1309
|
+
var options = _a.options, method = _a.method, propertyKey = _a.propertyKey, propertyDescriptor = _a.propertyDescriptor;
|
|
1310
|
+
return function () {
|
|
1311
|
+
var _this = this;
|
|
1312
|
+
var args = [];
|
|
1313
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1314
|
+
args[_i] = arguments[_i];
|
|
1315
|
+
}
|
|
1316
|
+
return new Promise(function (resolve, reject) {
|
|
1317
|
+
var debug = traceCall({ target: _this, propertyDescriptor: propertyDescriptor, propertyKey: propertyKey, args: args });
|
|
1318
|
+
if (lodash.get(options, 'level', '') === 'log') {
|
|
1319
|
+
debug.with('params').log(args);
|
|
1320
|
+
}
|
|
1321
|
+
return method
|
|
1322
|
+
.apply(_this, args)
|
|
1323
|
+
.then(function (result) {
|
|
1324
|
+
if (options.callbackFn) {
|
|
1325
|
+
options.callbackFn({ target: _this, result: result, args: args, namespace: [propertyKey] });
|
|
1326
|
+
}
|
|
1327
|
+
if (lodash.get(options, 'level', '') === 'log') {
|
|
1328
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
1329
|
+
}
|
|
1330
|
+
return resolve(result);
|
|
1331
|
+
})
|
|
1332
|
+
.catch(function (error) {
|
|
1333
|
+
debug.error.apply(debug, __spreadArray([error], __read(args)));
|
|
1334
|
+
debug.with('stack').error(error.stack).pop();
|
|
1335
|
+
return reject(error);
|
|
1336
|
+
})
|
|
1337
|
+
.finally(function () {
|
|
1338
|
+
return debug.trace('finally', { args: args }).pop();
|
|
1339
|
+
});
|
|
1340
|
+
});
|
|
1341
|
+
};
|
|
1342
|
+
};
|
|
1343
|
+
var functionTracer = function (_a) {
|
|
1344
|
+
var options = _a.options, target = _a.target, method = _a.method, propertyKey = _a.propertyKey, propertyDescriptor = _a.propertyDescriptor;
|
|
1345
|
+
return function () {
|
|
1346
|
+
var args = [];
|
|
1347
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1348
|
+
args[_i] = arguments[_i];
|
|
1349
|
+
}
|
|
1350
|
+
var debug = traceCall({ target: this || target, propertyDescriptor: propertyDescriptor, propertyKey: propertyKey, args: args });
|
|
1351
|
+
if (lodash.get(options, 'level', '') === 'log') {
|
|
1352
|
+
debug.with('params').log(args);
|
|
1353
|
+
}
|
|
1354
|
+
var result;
|
|
1355
|
+
try {
|
|
1356
|
+
result = method.apply(this, args);
|
|
1357
|
+
if (options.callbackFn)
|
|
1358
|
+
options.callbackFn({ target: this, result: result, args: args, namespace: [propertyKey] });
|
|
1359
|
+
if (lodash.get(options, 'level', '') === 'log') {
|
|
1360
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
1361
|
+
}
|
|
1362
|
+
return result;
|
|
1363
|
+
}
|
|
1364
|
+
catch (error) {
|
|
1365
|
+
debug.error.apply(debug, __spreadArray([error], __read(args))).pop();
|
|
1366
|
+
throw error;
|
|
1367
|
+
}
|
|
1368
|
+
finally {
|
|
1369
|
+
debug.trace('finally', { args: args }).pop();
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
};
|
|
833
1373
|
|
|
834
1374
|
var isUUID = function (value) { return lodash.isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value); };
|
|
835
1375
|
|
|
@@ -978,7 +1518,7 @@
|
|
|
978
1518
|
var instance = _super.toInstance.call(this, data);
|
|
979
1519
|
if (!lodash.isNil(data.firstName))
|
|
980
1520
|
instance.displayName = "" + data.firstName + (!lodash.isNil(data.lastName) ? " " + data.lastName : '');
|
|
981
|
-
return
|
|
1521
|
+
return;
|
|
982
1522
|
};
|
|
983
1523
|
User.prototype.toPlain = function () {
|
|
984
1524
|
var plain = _super.prototype.toPlain.call(this);
|
|
@@ -999,6 +1539,36 @@
|
|
|
999
1539
|
__metadata("design:type", BeautyProfile)
|
|
1000
1540
|
], User.prototype, "beautyProfile", void 0);
|
|
1001
1541
|
|
|
1542
|
+
var Address = /** @class */ (function (_super) {
|
|
1543
|
+
__extends(Address, _super);
|
|
1544
|
+
function Address() {
|
|
1545
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1546
|
+
}
|
|
1547
|
+
Object.defineProperty(Address, "identifiersFields", {
|
|
1548
|
+
get: function () {
|
|
1549
|
+
return ['id'];
|
|
1550
|
+
},
|
|
1551
|
+
enumerable: false,
|
|
1552
|
+
configurable: true
|
|
1553
|
+
});
|
|
1554
|
+
return Address;
|
|
1555
|
+
}(BaseModel));
|
|
1556
|
+
|
|
1557
|
+
var UserAddress = /** @class */ (function (_super) {
|
|
1558
|
+
__extends(UserAddress, _super);
|
|
1559
|
+
function UserAddress() {
|
|
1560
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1561
|
+
}
|
|
1562
|
+
Object.defineProperty(UserAddress, "identifiersFields", {
|
|
1563
|
+
get: function () {
|
|
1564
|
+
return ['id', 'userId'];
|
|
1565
|
+
},
|
|
1566
|
+
enumerable: false,
|
|
1567
|
+
configurable: true
|
|
1568
|
+
});
|
|
1569
|
+
return UserAddress;
|
|
1570
|
+
}(Address));
|
|
1571
|
+
|
|
1002
1572
|
var Subscription = /** @class */ (function (_super) {
|
|
1003
1573
|
__extends(Subscription, _super);
|
|
1004
1574
|
function Subscription() {
|
|
@@ -1022,12 +1592,12 @@
|
|
|
1022
1592
|
__metadata("design:type", SubscriptionPlan)
|
|
1023
1593
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
1024
1594
|
__decorate([
|
|
1025
|
-
classTransformer.Type(function () { return
|
|
1026
|
-
__metadata("design:type",
|
|
1595
|
+
classTransformer.Type(function () { return UserAddress; }),
|
|
1596
|
+
__metadata("design:type", UserAddress)
|
|
1027
1597
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
1028
1598
|
__decorate([
|
|
1029
|
-
classTransformer.Type(function () { return
|
|
1030
|
-
__metadata("design:type",
|
|
1599
|
+
classTransformer.Type(function () { return UserAddress; }),
|
|
1600
|
+
__metadata("design:type", UserAddress)
|
|
1031
1601
|
], Subscription.prototype, "billingAddress", void 0);
|
|
1032
1602
|
__decorate([
|
|
1033
1603
|
classTransformer.Type(function () { return Coupon; }),
|
|
@@ -1042,21 +1612,6 @@
|
|
|
1042
1612
|
__metadata("design:type", Array)
|
|
1043
1613
|
], Subscription.prototype, "payment", void 0);
|
|
1044
1614
|
|
|
1045
|
-
var UserAddress = /** @class */ (function (_super) {
|
|
1046
|
-
__extends(UserAddress, _super);
|
|
1047
|
-
function UserAddress() {
|
|
1048
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
1049
|
-
}
|
|
1050
|
-
Object.defineProperty(UserAddress, "identifiersFields", {
|
|
1051
|
-
get: function () {
|
|
1052
|
-
return ['id', 'userId'];
|
|
1053
|
-
},
|
|
1054
|
-
enumerable: false,
|
|
1055
|
-
configurable: true
|
|
1056
|
-
});
|
|
1057
|
-
return UserAddress;
|
|
1058
|
-
}(Address));
|
|
1059
|
-
|
|
1060
1615
|
var UserPaymentMethod = /** @class */ (function (_super) {
|
|
1061
1616
|
__extends(UserPaymentMethod, _super);
|
|
1062
1617
|
function UserPaymentMethod() {
|
|
@@ -1256,9 +1811,6 @@
|
|
|
1256
1811
|
function Filter() {
|
|
1257
1812
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1258
1813
|
}
|
|
1259
|
-
Filter.prototype.identifierFields = function () {
|
|
1260
|
-
return ['id'];
|
|
1261
|
-
};
|
|
1262
1814
|
Object.defineProperty(Filter, "identifiersFields", {
|
|
1263
1815
|
get: function () {
|
|
1264
1816
|
return ['id'];
|
|
@@ -1274,9 +1826,6 @@
|
|
|
1274
1826
|
function Category() {
|
|
1275
1827
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1276
1828
|
}
|
|
1277
|
-
Category.prototype.identifierFields = function () {
|
|
1278
|
-
return ['id'];
|
|
1279
|
-
};
|
|
1280
1829
|
Object.defineProperty(Category, "identifiersFields", {
|
|
1281
1830
|
get: function () {
|
|
1282
1831
|
return ['id'];
|
|
@@ -1300,9 +1849,6 @@
|
|
|
1300
1849
|
function CategoryCollectionChildren() {
|
|
1301
1850
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1302
1851
|
}
|
|
1303
|
-
CategoryCollectionChildren.prototype.identifierFields = function () {
|
|
1304
|
-
return ['collectionId', 'categoryId'];
|
|
1305
|
-
};
|
|
1306
1852
|
Object.defineProperty(CategoryCollectionChildren, "identifiersFields", {
|
|
1307
1853
|
get: function () {
|
|
1308
1854
|
return ['collectionId', 'categoryId'];
|
|
@@ -1323,9 +1869,6 @@
|
|
|
1323
1869
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1324
1870
|
}
|
|
1325
1871
|
Object.defineProperty(CategoryFilter, "identifiersFields", {
|
|
1326
|
-
// identifierFields(): NonFunctionPropertyNames<CategoryFilter>[] {
|
|
1327
|
-
// return ['id']
|
|
1328
|
-
// }
|
|
1329
1872
|
get: function () {
|
|
1330
1873
|
return ['id', 'filterId', 'categoryId'];
|
|
1331
1874
|
},
|
|
@@ -1355,9 +1898,6 @@
|
|
|
1355
1898
|
function FilterOption() {
|
|
1356
1899
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1357
1900
|
}
|
|
1358
|
-
FilterOption.prototype.identifierFields = function () {
|
|
1359
|
-
return ['id'];
|
|
1360
|
-
};
|
|
1361
1901
|
Object.defineProperty(FilterOption, "identifiersFields", {
|
|
1362
1902
|
get: function () {
|
|
1363
1903
|
return ['id'];
|
|
@@ -1395,9 +1935,6 @@
|
|
|
1395
1935
|
enumerable: false,
|
|
1396
1936
|
configurable: true
|
|
1397
1937
|
});
|
|
1398
|
-
Product.prototype.identifierFields = function () {
|
|
1399
|
-
return ['id'];
|
|
1400
|
-
};
|
|
1401
1938
|
Object.defineProperty(Product, "identifiersFields", {
|
|
1402
1939
|
get: function () {
|
|
1403
1940
|
return ['id'];
|
|
@@ -1423,7 +1960,7 @@
|
|
|
1423
1960
|
}
|
|
1424
1961
|
Object.defineProperty(KitProduct, "identifiersFields", {
|
|
1425
1962
|
get: function () {
|
|
1426
|
-
return ['productId', '
|
|
1963
|
+
return ['productId', 'kitProductId'];
|
|
1427
1964
|
},
|
|
1428
1965
|
enumerable: false,
|
|
1429
1966
|
configurable: true
|
|
@@ -1444,9 +1981,6 @@
|
|
|
1444
1981
|
function Variant() {
|
|
1445
1982
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1446
1983
|
}
|
|
1447
|
-
Variant.prototype.identifierFields = function () {
|
|
1448
|
-
return ['id'];
|
|
1449
|
-
};
|
|
1450
1984
|
Object.defineProperty(Variant, "identifiersFields", {
|
|
1451
1985
|
get: function () {
|
|
1452
1986
|
return ['id', 'productId'];
|
|
@@ -1552,12 +2086,12 @@
|
|
|
1552
2086
|
__metadata("design:type", User)
|
|
1553
2087
|
], Checkout.prototype, "user", void 0);
|
|
1554
2088
|
__decorate([
|
|
1555
|
-
classTransformer.Type(function () { return
|
|
1556
|
-
__metadata("design:type",
|
|
2089
|
+
classTransformer.Type(function () { return UserAddress; }),
|
|
2090
|
+
__metadata("design:type", UserAddress)
|
|
1557
2091
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
1558
2092
|
__decorate([
|
|
1559
|
-
classTransformer.Type(function () { return
|
|
1560
|
-
__metadata("design:type",
|
|
2093
|
+
classTransformer.Type(function () { return UserAddress; }),
|
|
2094
|
+
__metadata("design:type", UserAddress)
|
|
1561
2095
|
], Checkout.prototype, "billingAddress", void 0);
|
|
1562
2096
|
__decorate([
|
|
1563
2097
|
classTransformer.Type(function () { return ShippingMethod; }),
|
|
@@ -1607,12 +2141,12 @@
|
|
|
1607
2141
|
return CheckoutSubscription;
|
|
1608
2142
|
}(BaseModel));
|
|
1609
2143
|
__decorate([
|
|
1610
|
-
classTransformer.Type(function () { return
|
|
1611
|
-
__metadata("design:type",
|
|
2144
|
+
classTransformer.Type(function () { return UserAddress; }),
|
|
2145
|
+
__metadata("design:type", UserAddress)
|
|
1612
2146
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
1613
2147
|
__decorate([
|
|
1614
|
-
classTransformer.Type(function () { return
|
|
1615
|
-
__metadata("design:type",
|
|
2148
|
+
classTransformer.Type(function () { return UserAddress; }),
|
|
2149
|
+
__metadata("design:type", UserAddress)
|
|
1616
2150
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
1617
2151
|
__decorate([
|
|
1618
2152
|
classTransformer.Type(function () { return SubscriptionPlan; }),
|
|
@@ -2009,7 +2543,12 @@
|
|
|
2009
2543
|
})];
|
|
2010
2544
|
case 1:
|
|
2011
2545
|
search = _a.sent();
|
|
2012
|
-
search.hits = search.hits
|
|
2546
|
+
search.hits = search.hits
|
|
2547
|
+
.filter(function (e) { return e._source.name !== ''; })
|
|
2548
|
+
.map(function (hit) {
|
|
2549
|
+
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2550
|
+
return hit;
|
|
2551
|
+
});
|
|
2013
2552
|
return [2 /*return*/, search];
|
|
2014
2553
|
}
|
|
2015
2554
|
});
|
|
@@ -2327,34 +2866,34 @@
|
|
|
2327
2866
|
CreateFirestore.prototype.create = function (data) {
|
|
2328
2867
|
return __awaiter(this, void 0, void 0, function () {
|
|
2329
2868
|
var docRef, doc;
|
|
2330
|
-
return __generator(this, function (
|
|
2331
|
-
switch (
|
|
2869
|
+
return __generator(this, function (_c) {
|
|
2870
|
+
switch (_c.label) {
|
|
2332
2871
|
case 0: return [4 /*yield*/, this.save(this.model.toInstance(data))];
|
|
2333
2872
|
case 1:
|
|
2334
|
-
docRef =
|
|
2873
|
+
docRef = _c.sent();
|
|
2335
2874
|
return [4 /*yield*/, docRef.get()];
|
|
2336
2875
|
case 2:
|
|
2337
|
-
doc =
|
|
2876
|
+
doc = _c.sent();
|
|
2338
2877
|
return [2 /*return*/, doc.data()];
|
|
2339
2878
|
}
|
|
2340
2879
|
});
|
|
2341
2880
|
});
|
|
2342
2881
|
};
|
|
2343
2882
|
CreateFirestore.prototype.save = function (data) {
|
|
2344
|
-
var _a;
|
|
2883
|
+
var _a, _b;
|
|
2345
2884
|
return __awaiter(this, void 0, void 0, function () {
|
|
2346
2885
|
var id, collectionPath, docRef;
|
|
2347
|
-
return __generator(this, function (
|
|
2348
|
-
switch (
|
|
2886
|
+
return __generator(this, function (_c) {
|
|
2887
|
+
switch (_c.label) {
|
|
2349
2888
|
case 0:
|
|
2350
|
-
id = (_a = data
|
|
2889
|
+
id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
|
|
2351
2890
|
collectionPath = this.buildCollectionPathForAdd(data);
|
|
2352
2891
|
if (lodash.isEmpty(id))
|
|
2353
2892
|
return [2 /*return*/, this.collection(collectionPath).add(data)];
|
|
2354
2893
|
docRef = this.collection(collectionPath).doc(id);
|
|
2355
2894
|
return [4 /*yield*/, docRef.set(data)];
|
|
2356
2895
|
case 1:
|
|
2357
|
-
|
|
2896
|
+
_c.sent();
|
|
2358
2897
|
return [2 /*return*/, docRef];
|
|
2359
2898
|
}
|
|
2360
2899
|
});
|
|
@@ -3359,11 +3898,12 @@
|
|
|
3359
3898
|
BindFilterQueryHelper.BuildWhereSentence = function (field, options, fields) {
|
|
3360
3899
|
var _a;
|
|
3361
3900
|
var fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
3362
|
-
|
|
3901
|
+
var isNestedField = !Array.isArray(options) &&
|
|
3363
3902
|
lodash.isObject(options) &&
|
|
3364
3903
|
lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
3365
3904
|
lodash.isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
3366
|
-
lodash.isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
3905
|
+
lodash.isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
|
|
3906
|
+
if (isNestedField)
|
|
3367
3907
|
return Object.keys(options).reduce(function (variables, key) {
|
|
3368
3908
|
var _a;
|
|
3369
3909
|
var fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
@@ -3375,7 +3915,7 @@
|
|
|
3375
3915
|
return _a = {},
|
|
3376
3916
|
_a[fieldSentenceOptions.fields[0]] = BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
3377
3917
|
_a;
|
|
3378
|
-
if (lodash.isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
3918
|
+
if (!Array.isArray(options) && lodash.isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
3379
3919
|
options = Object.values(options)[0];
|
|
3380
3920
|
return Array.isArray(options)
|
|
3381
3921
|
? options.reduce(function (whereSentence, option) { return (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))); }, {})
|
|
@@ -3387,16 +3927,20 @@
|
|
|
3387
3927
|
_a[BindFilterQueryHelper.GetHasuraOperator(options, fieldOption)] = FilterOptionHelper.GetValueFromFilter(options, fieldOption),
|
|
3388
3928
|
_a);
|
|
3389
3929
|
};
|
|
3390
|
-
BindFilterQueryHelper.GetHasuraOperator = function (options, fieldOption) {
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3930
|
+
BindFilterQueryHelper.GetHasuraOperator = function (options, fieldOption) {
|
|
3931
|
+
if (!FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
3932
|
+
return HasuraGraphQLWhere.EQUALS;
|
|
3933
|
+
if (fieldOption.type === HasuraGraphQLColumnType.Jsonb)
|
|
3934
|
+
return BindFilterQueryHelper.GetHasuraJsonbOperator(options);
|
|
3935
|
+
return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find(function (graphQLOperator) { return graphQLOperator === Object.keys(exports.Where).find(function (operator) { return exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator); }); })];
|
|
3936
|
+
};
|
|
3937
|
+
BindFilterQueryHelper.GetHasuraJsonbOperator = function (options) {
|
|
3938
|
+
if (options.operator === exports.Where.IN)
|
|
3939
|
+
return '_contains';
|
|
3940
|
+
if (options.operator === exports.Where.LIKE)
|
|
3941
|
+
return '_has_keys_any';
|
|
3942
|
+
return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find(function (graphQLOperator) { return graphQLOperator === Object.keys(exports.Where).find(function (operator) { return exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator); }); })];
|
|
3943
|
+
};
|
|
3400
3944
|
|
|
3401
3945
|
var GraphQLFieldHelper = /** @class */ (function () {
|
|
3402
3946
|
function GraphQLFieldHelper() {
|
|
@@ -3406,7 +3950,7 @@
|
|
|
3406
3950
|
GraphQLFieldHelper.CheckIsGraphQLParams = function (params) { return !lodash.isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation; };
|
|
3407
3951
|
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = function (fields) {
|
|
3408
3952
|
return fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
|
|
3409
|
-
var _b
|
|
3953
|
+
var _b;
|
|
3410
3954
|
if (lodash.isString(field))
|
|
3411
3955
|
return field.toString();
|
|
3412
3956
|
var fieldName = Object.keys(field).shift();
|
|
@@ -3415,22 +3959,9 @@
|
|
|
3415
3959
|
return _b = {}, _b[fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue), _b;
|
|
3416
3960
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
3417
3961
|
return;
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
_c[fieldValue.columnName || fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
3422
|
-
_c) : {
|
|
3423
|
-
operation: fieldValue.columnName || fieldName,
|
|
3424
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
3425
|
-
variables: (_d = {},
|
|
3426
|
-
_d[fieldValue.columnName + "_where"] = {
|
|
3427
|
-
name: 'where',
|
|
3428
|
-
type: fieldValue.filters.filterType,
|
|
3429
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
3430
|
-
required: true,
|
|
3431
|
-
},
|
|
3432
|
-
_d),
|
|
3433
|
-
};
|
|
3962
|
+
var isNestedField = !!fieldValue.fields;
|
|
3963
|
+
if (isNestedField)
|
|
3964
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
3434
3965
|
return fieldValue.columnName;
|
|
3435
3966
|
}).filter(function (field) { return !!field; });
|
|
3436
3967
|
};
|
|
@@ -3489,6 +4020,26 @@
|
|
|
3489
4020
|
return Object.assign(Object.assign({}, result), (_d = {}, _d[columnName] = data[attributeName], _d));
|
|
3490
4021
|
}, {});
|
|
3491
4022
|
};
|
|
4023
|
+
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = function (fieldName, fieldValue) {
|
|
4024
|
+
var _b, _c;
|
|
4025
|
+
var hasCustomFilters = !!fieldValue.filters;
|
|
4026
|
+
if (hasCustomFilters)
|
|
4027
|
+
return {
|
|
4028
|
+
operation: fieldValue.columnName || fieldName,
|
|
4029
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
4030
|
+
variables: (_b = {},
|
|
4031
|
+
_b[fieldValue.columnName + "_where"] = {
|
|
4032
|
+
name: 'where',
|
|
4033
|
+
type: fieldValue.filters.filterType,
|
|
4034
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
4035
|
+
required: true,
|
|
4036
|
+
},
|
|
4037
|
+
_b),
|
|
4038
|
+
};
|
|
4039
|
+
return _c = {},
|
|
4040
|
+
_c[fieldValue.columnName || fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
4041
|
+
_c;
|
|
4042
|
+
};
|
|
3492
4043
|
|
|
3493
4044
|
var withCreateHasuraGraphQL = function (MixinBase) {
|
|
3494
4045
|
return /** @class */ (function (_super) {
|
|
@@ -3502,6 +4053,7 @@
|
|
|
3502
4053
|
var options = params === null || params === void 0 ? void 0 : params[0];
|
|
3503
4054
|
_this = _super.apply(this, __spreadArray([], __read(params))) || this;
|
|
3504
4055
|
_this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || "insert_" + _this.tableName + "_one";
|
|
4056
|
+
_this.insertAllGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertAllGraphQLOperation) || "insert_" + _this.tableName;
|
|
3505
4057
|
_this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || _this.tableName + "_insert_input";
|
|
3506
4058
|
return _this;
|
|
3507
4059
|
}
|
|
@@ -3510,7 +4062,9 @@
|
|
|
3510
4062
|
var newData;
|
|
3511
4063
|
return __generator(this, function (_b) {
|
|
3512
4064
|
switch (_b.label) {
|
|
3513
|
-
case 0:
|
|
4065
|
+
case 0:
|
|
4066
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
4067
|
+
return [4 /*yield*/, this.save(this.model.toInstance(data))];
|
|
3514
4068
|
case 1:
|
|
3515
4069
|
newData = _b.sent();
|
|
3516
4070
|
return [2 /*return*/, this.model.toInstance(newData)];
|
|
@@ -3518,6 +4072,29 @@
|
|
|
3518
4072
|
});
|
|
3519
4073
|
});
|
|
3520
4074
|
};
|
|
4075
|
+
CreateHasuraGraphQLMixin.prototype.createAll = function (data) {
|
|
4076
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4077
|
+
var result;
|
|
4078
|
+
var _this = this;
|
|
4079
|
+
return __generator(this, function (_b) {
|
|
4080
|
+
switch (_b.label) {
|
|
4081
|
+
case 0:
|
|
4082
|
+
this.logger = DebugHelper.from(this, 'createAll');
|
|
4083
|
+
return [4 /*yield*/, this.mutation(this.insertAllGraphQLOperation, [{ returning: this.model.identifiersFields }], {
|
|
4084
|
+
objects: {
|
|
4085
|
+
type: this.insertGraphQLObjectType,
|
|
4086
|
+
required: true,
|
|
4087
|
+
list: true,
|
|
4088
|
+
value: data.map(function (item) { return _this.convertDataToHasura(item); }),
|
|
4089
|
+
},
|
|
4090
|
+
})];
|
|
4091
|
+
case 1:
|
|
4092
|
+
result = _b.sent();
|
|
4093
|
+
return [2 /*return*/, result[this.insertAllGraphQLOperation].returning.map(function (item, index) { return _this.model.toInstance(Object.assign(Object.assign({}, data[index]), item)); })];
|
|
4094
|
+
}
|
|
4095
|
+
});
|
|
4096
|
+
});
|
|
4097
|
+
};
|
|
3521
4098
|
CreateHasuraGraphQLMixin.prototype.save = function (data) {
|
|
3522
4099
|
return __awaiter(this, void 0, void 0, function () {
|
|
3523
4100
|
var primaryKeyColumns, foreignKeyColumns, result;
|
|
@@ -3535,8 +4112,7 @@
|
|
|
3535
4112
|
(_b = {},
|
|
3536
4113
|
_b[columnOptions.columnName] = Object.keys(columnOptions.foreignKeyColumn).map(function (foreignKeyField) {
|
|
3537
4114
|
var _a;
|
|
3538
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
3539
|
-
foreignKeyField;
|
|
4115
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
|
|
3540
4116
|
}),
|
|
3541
4117
|
_b),
|
|
3542
4118
|
]));
|
|
@@ -3578,10 +4154,12 @@
|
|
|
3578
4154
|
return __generator(this, function (_a) {
|
|
3579
4155
|
switch (_a.label) {
|
|
3580
4156
|
case 0:
|
|
4157
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
3581
4158
|
instance = this.model.toInstance(identifiers);
|
|
3582
4159
|
return [4 /*yield*/, this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
3583
4160
|
var _a;
|
|
3584
|
-
|
|
4161
|
+
var identifierBinded = identifier;
|
|
4162
|
+
if (lodash.isNil(instance[identifierBinded]))
|
|
3585
4163
|
return ids;
|
|
3586
4164
|
var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
|
|
3587
4165
|
var value = columnOption.to(identifiers[identifier.toString()], instance);
|
|
@@ -3618,6 +4196,7 @@
|
|
|
3618
4196
|
_this.authOptions = options.authOptions;
|
|
3619
4197
|
_this.model = options.model;
|
|
3620
4198
|
_this.fields = options.fields || _this.model.identifiersFields;
|
|
4199
|
+
_this.logger = DebugHelper.from(_this);
|
|
3621
4200
|
return _this;
|
|
3622
4201
|
}
|
|
3623
4202
|
Object.defineProperty(HasuraGraphQLMixin.prototype, "headers", {
|
|
@@ -3667,6 +4246,7 @@
|
|
|
3667
4246
|
return __generator(this, function (_a) {
|
|
3668
4247
|
switch (_a.label) {
|
|
3669
4248
|
case 0:
|
|
4249
|
+
this.logger.with('params').log(params);
|
|
3670
4250
|
headers = this.headers;
|
|
3671
4251
|
return [4 /*yield*/, axios__default["default"]({
|
|
3672
4252
|
url: "" + this.endpoint,
|
|
@@ -3678,6 +4258,7 @@
|
|
|
3678
4258
|
result = (_a.sent()).data;
|
|
3679
4259
|
if (!lodash.isNil(result.errors))
|
|
3680
4260
|
throw new Error(JSON.stringify(result.errors));
|
|
4261
|
+
this.logger.with('returns').log(result);
|
|
3681
4262
|
return [2 /*return*/, result.data];
|
|
3682
4263
|
}
|
|
3683
4264
|
});
|
|
@@ -3706,8 +4287,8 @@
|
|
|
3706
4287
|
return value;
|
|
3707
4288
|
return date;
|
|
3708
4289
|
};
|
|
3709
|
-
HasuraGraphQLMixin.prototype.convertDataFromHasura = function (data) {
|
|
3710
|
-
var plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
4290
|
+
HasuraGraphQLMixin.prototype.convertDataFromHasura = function (data, fields) {
|
|
4291
|
+
var plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
3711
4292
|
return this.model.toInstance(plain);
|
|
3712
4293
|
};
|
|
3713
4294
|
HasuraGraphQLMixin.prototype.convertDataToHasura = function (instance, update) {
|
|
@@ -3750,6 +4331,7 @@
|
|
|
3750
4331
|
return __generator(this, function (_b) {
|
|
3751
4332
|
switch (_b.label) {
|
|
3752
4333
|
case 0:
|
|
4334
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
3753
4335
|
plainData = this.paramsToPlain(data);
|
|
3754
4336
|
return [4 /*yield*/, this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), {
|
|
3755
4337
|
_set: {
|
|
@@ -3781,10 +4363,11 @@
|
|
|
3781
4363
|
return this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
3782
4364
|
var _b;
|
|
3783
4365
|
var _a;
|
|
3784
|
-
|
|
4366
|
+
var identifierBinded = identifier;
|
|
4367
|
+
if (lodash.isNil(instance[identifierBinded]))
|
|
3785
4368
|
return ids;
|
|
3786
|
-
var columnOption = AttributeOptionHelper.FindByAttribute(
|
|
3787
|
-
var value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[
|
|
4369
|
+
var columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, _this.fields);
|
|
4370
|
+
var value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifierBinded], instance)) || data[columnOption.attributeName];
|
|
3788
4371
|
return Object.assign(Object.assign({}, ids), (_b = {}, _b[columnOption.columnName] = value, _b));
|
|
3789
4372
|
}, {});
|
|
3790
4373
|
};
|
|
@@ -3813,11 +4396,13 @@
|
|
|
3813
4396
|
return __generator(this, function (_b) {
|
|
3814
4397
|
switch (_b.label) {
|
|
3815
4398
|
case 0:
|
|
4399
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
3816
4400
|
instance = this.model.toInstance(identifiers);
|
|
3817
4401
|
return [4 /*yield*/, this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
3818
4402
|
var _b;
|
|
3819
4403
|
var _a;
|
|
3820
|
-
|
|
4404
|
+
var identifierBinded = identifier;
|
|
4405
|
+
if (lodash.isNil(instance[identifierBinded]))
|
|
3821
4406
|
return ids;
|
|
3822
4407
|
var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
|
|
3823
4408
|
var value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
|
|
@@ -3845,7 +4430,13 @@
|
|
|
3845
4430
|
return /** @class */ (function (_super) {
|
|
3846
4431
|
__extends(FindHasuraGraphQLMixin, _super);
|
|
3847
4432
|
function FindHasuraGraphQLMixin() {
|
|
3848
|
-
|
|
4433
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
4434
|
+
_this.bindOrderByAttributes = function (orderBy, fields) { return Object.keys(orderBy).reduce(function (acc, current) {
|
|
4435
|
+
var _b;
|
|
4436
|
+
return (Object.assign(Object.assign({}, acc), (_b = {}, _b[AttributeOptionHelper.FindByAttribute(current, fields)
|
|
4437
|
+
.columnName] = orderBy[current], _b)));
|
|
4438
|
+
}, {}); };
|
|
4439
|
+
return _this;
|
|
3849
4440
|
}
|
|
3850
4441
|
FindHasuraGraphQLMixin.prototype.find = function (params) {
|
|
3851
4442
|
var _a;
|
|
@@ -3855,9 +4446,18 @@
|
|
|
3855
4446
|
return __generator(this, function (_c) {
|
|
3856
4447
|
switch (_c.label) {
|
|
3857
4448
|
case 0:
|
|
4449
|
+
this.logger = DebugHelper.from(this, 'find');
|
|
3858
4450
|
_b = params || {}, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy, options = _b.options;
|
|
3859
4451
|
enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
3860
|
-
variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy)
|
|
4452
|
+
variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy)
|
|
4453
|
+
? {}
|
|
4454
|
+
: {
|
|
4455
|
+
order_by: {
|
|
4456
|
+
type: this.tableName + "_order_by!",
|
|
4457
|
+
list: true,
|
|
4458
|
+
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
4459
|
+
},
|
|
4460
|
+
})), (lodash.isNil(filters)
|
|
3861
4461
|
? {}
|
|
3862
4462
|
: {
|
|
3863
4463
|
where: {
|
|
@@ -5745,8 +6345,12 @@
|
|
|
5745
6345
|
exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
|
|
5746
6346
|
exports.CheckoutSubscription = CheckoutSubscription;
|
|
5747
6347
|
exports.CheckoutSubscriptionFirestoreRepository = CheckoutSubscriptionFirestoreRepository;
|
|
6348
|
+
exports.ClassNameHelper = ClassNameHelper;
|
|
5748
6349
|
exports.Coupon = Coupon;
|
|
5749
6350
|
exports.CouponFirestoreRepository = CouponFirestoreRepository;
|
|
6351
|
+
exports.Debug = Debug;
|
|
6352
|
+
exports.DebugDecoratorHelper = DebugDecoratorHelper;
|
|
6353
|
+
exports.DebugHelper = DebugHelper;
|
|
5750
6354
|
exports.DuplicatedResultsError = DuplicatedResultsError;
|
|
5751
6355
|
exports.Edition = Edition;
|
|
5752
6356
|
exports.Filter = Filter;
|
|
@@ -5762,6 +6366,8 @@
|
|
|
5762
6366
|
exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
5763
6367
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
5764
6368
|
exports.LineItem = LineItem;
|
|
6369
|
+
exports.Log = Log;
|
|
6370
|
+
exports.Logger = Logger;
|
|
5765
6371
|
exports.NotFoundError = NotFoundError;
|
|
5766
6372
|
exports.Order = Order;
|
|
5767
6373
|
exports.OrderFirestoreRepository = OrderFirestoreRepository;
|
|
@@ -5774,6 +6380,7 @@
|
|
|
5774
6380
|
exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
|
|
5775
6381
|
exports.ProductsIndex = ProductsIndex;
|
|
5776
6382
|
exports.RecoveryPassword = RecoveryPassword;
|
|
6383
|
+
exports.ReflectHelper = ReflectHelper;
|
|
5777
6384
|
exports.Register = Register;
|
|
5778
6385
|
exports.RegisterFirebaseAuthService = RegisterFirebaseAuthService;
|
|
5779
6386
|
exports.RequiredArgumentError = RequiredArgumentError;
|
|
@@ -5792,6 +6399,7 @@
|
|
|
5792
6399
|
exports.SubscriptionPlan = SubscriptionPlan;
|
|
5793
6400
|
exports.SubscriptionPlanFirestoreRepository = SubscriptionPlanFirestoreRepository;
|
|
5794
6401
|
exports.SubscriptionProductFirestoreRepository = SubscriptionProductFirestoreRepository;
|
|
6402
|
+
exports.Trace = Trace;
|
|
5795
6403
|
exports.UnauthorizedError = UnauthorizedError;
|
|
5796
6404
|
exports.User = User;
|
|
5797
6405
|
exports.UserAddress = UserAddress;
|
|
@@ -5805,6 +6413,7 @@
|
|
|
5805
6413
|
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
5806
6414
|
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|
|
5807
6415
|
exports.WeakPasswordError = WeakPasswordError;
|
|
6416
|
+
exports.isDebuggable = isDebuggable;
|
|
5808
6417
|
exports.isUUID = isUUID;
|
|
5809
6418
|
exports.parseDateTime = parseDateTime;
|
|
5810
6419
|
exports.withCreateFirestore = withCreateFirestore;
|