@infrab4a/connect 3.11.1-beta2 → 3.11.1-beta4
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 +1282 -344
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/helpers/index.d.ts +1 -0
- package/domain/catalog/helpers/round-product-price.helper.d.ts +4 -0
- package/domain/catalog/index.d.ts +1 -0
- package/domain/catalog/models/category-collection-children.d.ts +13 -0
- package/domain/catalog/models/category-filter.d.ts +5 -1
- package/domain/catalog/models/category.d.ts +5 -3
- package/domain/catalog/models/filter-option.d.ts +1 -2
- package/domain/catalog/models/filter.d.ts +1 -2
- package/domain/catalog/models/index.d.ts +1 -0
- package/domain/catalog/models/kit-product.d.ts +1 -1
- package/domain/catalog/models/product.d.ts +1 -2
- package/domain/catalog/models/types/category-product.d.ts +4 -0
- package/domain/catalog/models/types/index.d.ts +1 -0
- package/domain/catalog/models/types/shop-description.type.d.ts +1 -0
- package/domain/catalog/models/variant.d.ts +1 -2
- package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
- package/domain/catalog/repositories/category.repository.d.ts +3 -0
- package/domain/catalog/repositories/index.d.ts +1 -0
- package/domain/catalog/repositories/product.repository.d.ts +3 -1
- 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/find.repository.d.ts +3 -1
- 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-find-result.type.d.ts +8 -1
- 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 +5 -3
- package/domain/shopping/models/checkout.d.ts +5 -6
- package/domain/shopping/models/coupons/coupon.d.ts +34 -6
- package/domain/shopping/models/order.d.ts +1 -0
- package/domain/shopping/models/shipping-method.d.ts +1 -0
- package/domain/shopping/models/subscription/checkout.d.ts +3 -4
- package/domain/users/models/subscription/subscription-materialization.d.ts +4 -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 -0
- package/esm2015/domain/catalog/helpers/round-product-price.helper.js +15 -0
- package/esm2015/domain/catalog/index.js +2 -1
- package/esm2015/domain/catalog/models/category-collection-children.js +13 -0
- package/esm2015/domain/catalog/models/category-filter.js +14 -5
- package/esm2015/domain/catalog/models/category.js +6 -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/index.js +2 -1
- package/esm2015/domain/catalog/models/kit-product.js +2 -2
- package/esm2015/domain/catalog/models/product.js +1 -4
- package/esm2015/domain/catalog/models/types/category-product.js +2 -0
- package/esm2015/domain/catalog/models/types/index.js +2 -1
- package/esm2015/domain/catalog/models/types/shop-description.type.js +1 -1
- package/esm2015/domain/catalog/models/variant.js +1 -4
- package/esm2015/domain/catalog/repositories/category-collection-children.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/category.repository.js +1 -1
- package/esm2015/domain/catalog/repositories/index.js +2 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- 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/find.repository.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-find-result.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/coupons/coupon.js +16 -16
- package/esm2015/domain/shopping/models/order.js +1 -1
- package/esm2015/domain/shopping/models/shipping-method.js +1 -1
- package/esm2015/domain/shopping/models/subscription/checkout.js +6 -6
- package/esm2015/domain/users/models/subscription/subscription-materialization.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 +2 -2
- 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 +17 -2
- 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/catalog/category-firestore.repository.js +10 -1
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +5 -2
- 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 +2 -2
- package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +20 -15
- 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 +67 -8
- 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/models/product-hasura-graphql.js +1 -1
- package/esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js +1 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.js +38 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +75 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +46 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +2 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +27 -10
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -1
- 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 +9 -6
- package/esm2015/utils/log.utils.js +9 -0
- package/fesm2015/infrab4a-connect.js +911 -162
- 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 +4 -1
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +3 -2
- 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-materialization-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 +22 -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/models/product-hasura-graphql.d.ts +3 -0
- package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +1 -0
- package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +10 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +3 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -1
- 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 +2 -1
- 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 +8 -5
- package/utils/log.utils.d.ts +7 -0
|
@@ -3,8 +3,10 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
|
|
|
3
3
|
import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
|
|
4
4
|
import { parseISO } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
|
|
6
|
-
import { isString,
|
|
7
|
-
export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
6
|
+
import { isNil, isArray, first, last, flatten, compact, get, isString, each, unset, isObject, isNumber, isDate, set, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
|
|
7
|
+
export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, unset } from 'lodash';
|
|
8
|
+
import { Subject } from 'rxjs';
|
|
9
|
+
import { debug } from 'debug';
|
|
8
10
|
import { CustomError } from 'ts-custom-error';
|
|
9
11
|
import axios from 'axios';
|
|
10
12
|
import firebase from 'firebase';
|
|
@@ -13,7 +15,8 @@ import { mutation, query } from 'gql-query-builder';
|
|
|
13
15
|
class BaseModel {
|
|
14
16
|
get identifier() {
|
|
15
17
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
16
|
-
|
|
18
|
+
const data = this;
|
|
19
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
17
20
|
}
|
|
18
21
|
get identifiersFields() {
|
|
19
22
|
return this.constructor.identifiersFields;
|
|
@@ -459,20 +462,446 @@ __decorate([
|
|
|
459
462
|
__metadata("design:type", Payment)
|
|
460
463
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
461
464
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
+
var DebugNamespaces;
|
|
466
|
+
(function (DebugNamespaces) {
|
|
467
|
+
DebugNamespaces["ROOT"] = "connect";
|
|
468
|
+
DebugNamespaces["TRACE"] = "trace";
|
|
469
|
+
DebugNamespaces["ERROR"] = "error";
|
|
470
|
+
})(DebugNamespaces || (DebugNamespaces = {}));
|
|
471
|
+
const Logger = debug(DebugNamespaces.ROOT);
|
|
472
|
+
|
|
473
|
+
class ReflectHelper {
|
|
474
|
+
static get items() {
|
|
475
|
+
return this._items;
|
|
476
|
+
}
|
|
477
|
+
static get keys() {
|
|
478
|
+
return Object.keys(ReflectHelper.items);
|
|
479
|
+
}
|
|
480
|
+
static has(key, target, property) {
|
|
481
|
+
return (!isNil(key) &&
|
|
482
|
+
!isNil(ReflectHelper.items[key]) &&
|
|
483
|
+
(isNil(target) ||
|
|
484
|
+
(!isNil(ReflectHelper.items[key][target]) &&
|
|
485
|
+
(isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
|
|
486
|
+
}
|
|
487
|
+
static get({ key, target, property, own = true }) {
|
|
488
|
+
try {
|
|
489
|
+
if (own) {
|
|
490
|
+
return Reflect.getOwnMetadata(key, target, property) || null;
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
return Reflect.getMetadata(key, target, property) || null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
catch (_err) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
static first({ key, target, property, own = true }) {
|
|
501
|
+
const values = ReflectHelper.get({ key, target, property, own });
|
|
502
|
+
return isArray(values) ? first(values) : values;
|
|
503
|
+
}
|
|
504
|
+
static last({ key, target, property, own = true }) {
|
|
505
|
+
const values = ReflectHelper.get({ key, target, property, own });
|
|
506
|
+
return isArray(values) ? last(values) : values;
|
|
507
|
+
}
|
|
508
|
+
static set({ key, target, property, value, propertyDescriptor }) {
|
|
509
|
+
Reflect.defineMetadata(key, value, target, property);
|
|
510
|
+
ReflectHelper.put({ key, target, property, value, propertyDescriptor });
|
|
511
|
+
}
|
|
512
|
+
static add({ key, target, property, value, propertyDescriptor }) {
|
|
513
|
+
let values = ReflectHelper.get({ key, target, property }) || new Array();
|
|
514
|
+
if (!Array.isArray(values))
|
|
515
|
+
values = [values];
|
|
516
|
+
values.push(value);
|
|
517
|
+
ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
|
|
518
|
+
}
|
|
519
|
+
static all({ key }) {
|
|
520
|
+
const items = ReflectHelper.items[key] || {};
|
|
521
|
+
return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
|
|
522
|
+
}
|
|
523
|
+
static allFrom(key, target) {
|
|
524
|
+
return Object.keys(target)
|
|
525
|
+
.filter((property) => property !== 'object')
|
|
526
|
+
.map((property) => this.allValuesFrom(key, target, property));
|
|
527
|
+
}
|
|
528
|
+
static allValuesFrom(key, target, property) {
|
|
529
|
+
const values = target[property];
|
|
530
|
+
let value = values.value;
|
|
531
|
+
const propertyDescriptor = values.propertyDescriptor;
|
|
532
|
+
if (!isArray(value))
|
|
533
|
+
value = [value];
|
|
534
|
+
return flatten(value.map((val) => {
|
|
535
|
+
return {
|
|
536
|
+
key,
|
|
537
|
+
target: target.object,
|
|
538
|
+
property,
|
|
539
|
+
value: val,
|
|
540
|
+
propertyDescriptor,
|
|
541
|
+
};
|
|
542
|
+
}));
|
|
543
|
+
}
|
|
544
|
+
static delete({ key, target, property }) {
|
|
545
|
+
Reflect.deleteMetadata(key, target, property);
|
|
546
|
+
return ReflectHelper.remove(key, target, property);
|
|
547
|
+
}
|
|
548
|
+
static clear(key) {
|
|
549
|
+
if (!key) {
|
|
550
|
+
ReflectHelper.keys.forEach((storedKey) => {
|
|
551
|
+
ReflectHelper.clear(storedKey);
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
if (ReflectHelper.keys.includes(key)) {
|
|
556
|
+
Object.values(ReflectHelper.items[key]).forEach((target) => {
|
|
557
|
+
if (ReflectHelper.has(key, target)) {
|
|
558
|
+
Object.values(ReflectHelper.items[key][target]).forEach((property) => {
|
|
559
|
+
ReflectHelper.delete({
|
|
560
|
+
key,
|
|
561
|
+
target: target.object,
|
|
562
|
+
property: String(property),
|
|
563
|
+
});
|
|
564
|
+
ReflectHelper.remove(key, target, String(property));
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
ReflectHelper.delete({ key, target: target.object });
|
|
568
|
+
ReflectHelper.remove(key, target);
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
static getType({ target, propertyKey }) {
|
|
574
|
+
return Reflect.getMetadata('design:type', target, propertyKey);
|
|
575
|
+
}
|
|
576
|
+
static getReturntype({ target, propertyKey }) {
|
|
577
|
+
return Reflect.getMetadata('design:returntype', target, propertyKey);
|
|
578
|
+
}
|
|
579
|
+
static getAllMethods(target) {
|
|
580
|
+
const props = [];
|
|
581
|
+
let obj = target;
|
|
582
|
+
do {
|
|
583
|
+
props.push(...Object.getOwnPropertyNames(obj));
|
|
584
|
+
} while ((obj = Object.getPrototypeOf(obj)));
|
|
585
|
+
return props.sort().filter((e, i, arr) => {
|
|
586
|
+
if ([
|
|
587
|
+
'__defineGetter__',
|
|
588
|
+
'__defineSetter__',
|
|
589
|
+
'__lookupGetter__',
|
|
590
|
+
'__lookupSetter__',
|
|
591
|
+
'constructor',
|
|
592
|
+
'hasOwnProperty',
|
|
593
|
+
'isPrototypeOf',
|
|
594
|
+
'propertyIsEnumerable',
|
|
595
|
+
'toLocaleString',
|
|
596
|
+
'toString',
|
|
597
|
+
'valueOf',
|
|
598
|
+
].includes(e))
|
|
599
|
+
return false;
|
|
600
|
+
if (e != arr[i + 1] && typeof target[e] === 'function')
|
|
601
|
+
return true;
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
static put({ key, target, property, value, propertyDescriptor }) {
|
|
605
|
+
const index = target.constructor.name;
|
|
606
|
+
ReflectHelper.items[key] = ReflectHelper.items[key] || {};
|
|
607
|
+
ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
|
|
608
|
+
ReflectHelper.items[key][index].object = target;
|
|
609
|
+
if (isNil(property)) {
|
|
610
|
+
ReflectHelper.items[key][index].value = {
|
|
611
|
+
value,
|
|
612
|
+
propertyDescriptor,
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
else {
|
|
616
|
+
ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
|
|
617
|
+
ReflectHelper.items[key][index][String(property)] = {
|
|
618
|
+
value,
|
|
619
|
+
propertyDescriptor,
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
static remove(key, target, property) {
|
|
624
|
+
if (ReflectHelper.has(key, target, property))
|
|
625
|
+
return delete ReflectHelper.items[key][target][String(property)];
|
|
626
|
+
else if (ReflectHelper.has(key, target))
|
|
627
|
+
return delete ReflectHelper.items[key][target];
|
|
628
|
+
else if (ReflectHelper.has(key))
|
|
629
|
+
return delete ReflectHelper.items[key];
|
|
630
|
+
else
|
|
631
|
+
return false;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
ReflectHelper._items = {};
|
|
635
|
+
|
|
636
|
+
class DebugDecoratorHelper {
|
|
637
|
+
static set(target, options) {
|
|
638
|
+
ReflectHelper.add({
|
|
639
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
640
|
+
target,
|
|
641
|
+
value: options,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
static get(target) {
|
|
645
|
+
return ReflectHelper.first({
|
|
646
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
647
|
+
target,
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
652
|
+
|
|
653
|
+
class ClassNameHelper {
|
|
654
|
+
static get(clazz) {
|
|
655
|
+
if (!clazz)
|
|
656
|
+
return null;
|
|
657
|
+
const prototype = Object.getPrototypeOf(clazz);
|
|
658
|
+
const names = compact([
|
|
659
|
+
get(clazz, 'constructor.name'),
|
|
660
|
+
get(prototype, 'constructor.name'),
|
|
661
|
+
get(prototype, '__proto__.constructor.name'),
|
|
662
|
+
]);
|
|
663
|
+
return names.find((name) => name !== 'class_1');
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const isDebuggable = (object) => {
|
|
668
|
+
return 'debug' in object;
|
|
669
|
+
};
|
|
670
|
+
class DebugHelper {
|
|
671
|
+
constructor(...namespace) {
|
|
672
|
+
this.namespaces = new Set();
|
|
673
|
+
this.push(...namespace);
|
|
674
|
+
}
|
|
675
|
+
static namespacesFor(target) {
|
|
676
|
+
if (isNil(target))
|
|
677
|
+
return [];
|
|
678
|
+
const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
|
|
679
|
+
const namespaces = get(decorator, 'namespaces', []);
|
|
680
|
+
const name = get(decorator, 'name', ClassNameHelper.get(target));
|
|
681
|
+
return [...namespaces, name];
|
|
682
|
+
}
|
|
683
|
+
static as(...namespaces) {
|
|
684
|
+
return new DebugHelper(...namespaces);
|
|
685
|
+
}
|
|
686
|
+
static for(target, ...namespaces) {
|
|
687
|
+
const targetNamespaces = this.namespacesFor(target);
|
|
688
|
+
return new DebugHelper(...targetNamespaces, ...namespaces);
|
|
689
|
+
}
|
|
690
|
+
static from(target, ...namespaces) {
|
|
691
|
+
if (this.isDebuggable(target)) {
|
|
692
|
+
const debug = target.debug;
|
|
693
|
+
if (namespaces)
|
|
694
|
+
debug.push(...namespaces);
|
|
695
|
+
return debug;
|
|
696
|
+
}
|
|
697
|
+
return DebugHelper.for(target, ...namespaces);
|
|
698
|
+
}
|
|
699
|
+
static clonedFrom(target, ...namespaces) {
|
|
700
|
+
if (this.isDebuggable(target)) {
|
|
701
|
+
namespaces.push(...target.debug.entries);
|
|
702
|
+
}
|
|
703
|
+
else if (!isNil(target)) {
|
|
704
|
+
namespaces.push(...this.namespacesFor(target));
|
|
705
|
+
}
|
|
706
|
+
return DebugHelper.for(target, ...namespaces);
|
|
707
|
+
}
|
|
708
|
+
static clone(target, ...namespaces) {
|
|
709
|
+
let original;
|
|
710
|
+
if (this.isDebuggable(target)) {
|
|
711
|
+
original = target.debug;
|
|
712
|
+
namespaces.push(...original.entries);
|
|
713
|
+
}
|
|
714
|
+
return {
|
|
715
|
+
original,
|
|
716
|
+
debug: DebugHelper.for(target, ...namespaces),
|
|
717
|
+
};
|
|
465
718
|
}
|
|
719
|
+
static replace(target, attrs) {
|
|
720
|
+
if (this.isDebuggable(target))
|
|
721
|
+
target.debug = attrs.with;
|
|
722
|
+
}
|
|
723
|
+
static mock(target, ...namespaces) {
|
|
724
|
+
const { original, debug } = DebugHelper.clone(target, ...namespaces);
|
|
725
|
+
DebugHelper.replace(target, { with: debug });
|
|
726
|
+
return { original, debug };
|
|
727
|
+
}
|
|
728
|
+
get entries() {
|
|
729
|
+
return Array.from(get(this, 'namespaces', []));
|
|
730
|
+
}
|
|
731
|
+
get namespace() {
|
|
732
|
+
return compact(flatten(this.entries)).join(':');
|
|
733
|
+
}
|
|
734
|
+
log(message, ...args) {
|
|
735
|
+
this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
|
|
736
|
+
DebugHelper.logs$.next({ namespace: this.namespace, message, args });
|
|
737
|
+
return this;
|
|
738
|
+
}
|
|
739
|
+
trace(message, ...args) {
|
|
740
|
+
this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
|
|
741
|
+
DebugHelper.traces$.next({ namespace: this.namespace, message, args });
|
|
742
|
+
return this;
|
|
743
|
+
}
|
|
744
|
+
error(error, ...args) {
|
|
745
|
+
this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
|
|
746
|
+
DebugHelper.errors$.next({ namespace: this.namespace, error, args });
|
|
747
|
+
return this;
|
|
748
|
+
}
|
|
749
|
+
build() {
|
|
750
|
+
this.logger = Logger;
|
|
751
|
+
this.tracer = Logger;
|
|
752
|
+
this.err = Logger;
|
|
753
|
+
this.entries.forEach((namespace) => {
|
|
754
|
+
this.logger = this.logger.extend(namespace);
|
|
755
|
+
this.tracer = this.tracer.extend(namespace);
|
|
756
|
+
this.err = this.err.extend(namespace);
|
|
757
|
+
});
|
|
758
|
+
return this;
|
|
759
|
+
}
|
|
760
|
+
with(...namespace) {
|
|
761
|
+
return new DebugHelper(...this.entries, ...namespace);
|
|
762
|
+
}
|
|
763
|
+
push(...namespace) {
|
|
764
|
+
if (namespace) {
|
|
765
|
+
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
|
|
766
|
+
}
|
|
767
|
+
return this.build();
|
|
768
|
+
}
|
|
769
|
+
unshift(...namespace) {
|
|
770
|
+
if (namespace) {
|
|
771
|
+
return this.reset(...namespace, ...this.entries);
|
|
772
|
+
}
|
|
773
|
+
return this;
|
|
774
|
+
}
|
|
775
|
+
reset(...namespace) {
|
|
776
|
+
this.namespaces = new Set(flatten(compact(namespace)));
|
|
777
|
+
return this.build();
|
|
778
|
+
}
|
|
779
|
+
startWith(...namespace) {
|
|
780
|
+
const current = this.namespaces;
|
|
781
|
+
this.namespaces = new Set(flatten([compact(namespace), ...current]));
|
|
782
|
+
return this.build();
|
|
783
|
+
}
|
|
784
|
+
shift() {
|
|
785
|
+
const list = this.entries;
|
|
786
|
+
list.shift();
|
|
787
|
+
return this.reset(...list);
|
|
788
|
+
}
|
|
789
|
+
pop() {
|
|
790
|
+
const list = this.entries;
|
|
791
|
+
list.pop();
|
|
792
|
+
return this.reset(...list);
|
|
793
|
+
}
|
|
794
|
+
clear() {
|
|
795
|
+
return this.reset();
|
|
796
|
+
}
|
|
797
|
+
remove(...namespace) {
|
|
798
|
+
if (namespace) {
|
|
799
|
+
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
|
|
800
|
+
}
|
|
801
|
+
return this.build();
|
|
802
|
+
}
|
|
803
|
+
puts(...args) {
|
|
804
|
+
return [`[${this.namespace}]`, ...args].join(' ');
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
DebugHelper.logs$ = new Subject();
|
|
808
|
+
DebugHelper.traces$ = new Subject();
|
|
809
|
+
DebugHelper.errors$ = new Subject();
|
|
810
|
+
DebugHelper.isDebuggable = isDebuggable;
|
|
811
|
+
|
|
812
|
+
function Debug(opts) {
|
|
813
|
+
return function (target) {
|
|
814
|
+
DebugDecoratorHelper.set(target.prototype, opts);
|
|
815
|
+
};
|
|
466
816
|
}
|
|
467
817
|
|
|
818
|
+
const ASYNC_IDENTIFIER = 'async';
|
|
819
|
+
function Log(options = {}) {
|
|
820
|
+
return Trace(Object.assign({ level: 'log' }, options));
|
|
821
|
+
}
|
|
822
|
+
function Trace(options = {}) {
|
|
823
|
+
return function (target, propertyKey, propertyDescriptor) {
|
|
824
|
+
const method = propertyDescriptor.value;
|
|
825
|
+
const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
|
|
826
|
+
const args = {
|
|
827
|
+
options,
|
|
828
|
+
method,
|
|
829
|
+
target,
|
|
830
|
+
propertyKey,
|
|
831
|
+
propertyDescriptor,
|
|
832
|
+
};
|
|
833
|
+
propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
|
|
834
|
+
return propertyDescriptor;
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
const traceCall = ({ target, propertyKey, propertyDescriptor, args }) => {
|
|
838
|
+
if (!target.debug)
|
|
839
|
+
target.debug = DebugHelper.for(target, propertyKey);
|
|
840
|
+
return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
|
|
841
|
+
};
|
|
842
|
+
const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
|
|
843
|
+
return function (...args) {
|
|
844
|
+
return new Promise((resolve, reject) => {
|
|
845
|
+
const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
|
|
846
|
+
if (get(options, 'level', '') === 'log') {
|
|
847
|
+
debug.with('params').log(args);
|
|
848
|
+
}
|
|
849
|
+
return method
|
|
850
|
+
.apply(this, args)
|
|
851
|
+
.then((result) => {
|
|
852
|
+
if (options.callbackFn) {
|
|
853
|
+
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
854
|
+
}
|
|
855
|
+
if (get(options, 'level', '') === 'log') {
|
|
856
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
857
|
+
}
|
|
858
|
+
return resolve(result);
|
|
859
|
+
})
|
|
860
|
+
.catch((error) => {
|
|
861
|
+
debug.error(error, ...args);
|
|
862
|
+
debug.with('stack').error(error.stack).pop();
|
|
863
|
+
return reject(error);
|
|
864
|
+
})
|
|
865
|
+
.finally(() => {
|
|
866
|
+
return debug.trace('finally', { args }).pop();
|
|
867
|
+
});
|
|
868
|
+
});
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
|
|
872
|
+
return function (...args) {
|
|
873
|
+
const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
|
|
874
|
+
if (get(options, 'level', '') === 'log') {
|
|
875
|
+
debug.with('params').log(args);
|
|
876
|
+
}
|
|
877
|
+
let result;
|
|
878
|
+
try {
|
|
879
|
+
result = method.apply(this, args);
|
|
880
|
+
if (options.callbackFn)
|
|
881
|
+
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
882
|
+
if (get(options, 'level', '') === 'log') {
|
|
883
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
884
|
+
}
|
|
885
|
+
return result;
|
|
886
|
+
}
|
|
887
|
+
catch (error) {
|
|
888
|
+
debug.error(error, ...args).pop();
|
|
889
|
+
throw error;
|
|
890
|
+
}
|
|
891
|
+
finally {
|
|
892
|
+
debug.trace('finally', { args }).pop();
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
const isUUID = (value) => 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);
|
|
898
|
+
|
|
468
899
|
class Base {
|
|
469
900
|
constructor(...args) {
|
|
470
901
|
Object.assign(this, ...args);
|
|
471
902
|
}
|
|
472
903
|
}
|
|
473
904
|
|
|
474
|
-
const isUUID = (value) => 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);
|
|
475
|
-
|
|
476
905
|
const parseDateTime = (value) => {
|
|
477
906
|
if (!isString(value))
|
|
478
907
|
return value;
|
|
@@ -529,26 +958,28 @@ class Coupon extends BaseModel {
|
|
|
529
958
|
static createCoupon(userId) {
|
|
530
959
|
return this.toInstance({
|
|
531
960
|
nickname: `${Date.now()}`,
|
|
532
|
-
type: CouponTypes.ABSOLUTE,
|
|
533
961
|
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
534
|
-
discount:
|
|
962
|
+
discount: {
|
|
963
|
+
subscriber: {
|
|
964
|
+
type: CouponTypes.ABSOLUTE,
|
|
965
|
+
value: 10,
|
|
966
|
+
},
|
|
967
|
+
non_subscriber: {
|
|
968
|
+
type: CouponTypes.ABSOLUTE,
|
|
969
|
+
value: 10,
|
|
970
|
+
},
|
|
971
|
+
subscription: {
|
|
972
|
+
type: CouponTypes.ABSOLUTE,
|
|
973
|
+
value: 10,
|
|
974
|
+
},
|
|
975
|
+
},
|
|
535
976
|
user: userId,
|
|
536
|
-
useLimit: 1,
|
|
537
|
-
useLimitPerUser: true,
|
|
538
977
|
createdAt: new Date(Date.now()),
|
|
539
978
|
beginAt: new Date(Date.now()),
|
|
540
979
|
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
541
980
|
});
|
|
542
981
|
}
|
|
543
982
|
}
|
|
544
|
-
__decorate([
|
|
545
|
-
Expose({ name: 'checkout_type' }),
|
|
546
|
-
__metadata("design:type", Number)
|
|
547
|
-
], Coupon.prototype, "checkoutType", void 0);
|
|
548
|
-
__decorate([
|
|
549
|
-
Expose({ name: 'exclusivity_type' }),
|
|
550
|
-
__metadata("design:type", Number)
|
|
551
|
-
], Coupon.prototype, "exclusivityType", void 0);
|
|
552
983
|
|
|
553
984
|
class SubscriptionPlan extends BaseModel {
|
|
554
985
|
static get identifiersFields() {
|
|
@@ -588,6 +1019,18 @@ __decorate([
|
|
|
588
1019
|
__metadata("design:type", BeautyProfile)
|
|
589
1020
|
], User.prototype, "beautyProfile", void 0);
|
|
590
1021
|
|
|
1022
|
+
class Address extends BaseModel {
|
|
1023
|
+
static get identifiersFields() {
|
|
1024
|
+
return ['id'];
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
class UserAddress extends Address {
|
|
1029
|
+
static get identifiersFields() {
|
|
1030
|
+
return ['id', 'userId'];
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
591
1034
|
class Subscription extends BaseModel {
|
|
592
1035
|
static get identifiersFields() {
|
|
593
1036
|
return ['id'];
|
|
@@ -602,12 +1045,12 @@ __decorate([
|
|
|
602
1045
|
__metadata("design:type", SubscriptionPlan)
|
|
603
1046
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
604
1047
|
__decorate([
|
|
605
|
-
Type(() =>
|
|
606
|
-
__metadata("design:type",
|
|
1048
|
+
Type(() => UserAddress),
|
|
1049
|
+
__metadata("design:type", UserAddress)
|
|
607
1050
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
608
1051
|
__decorate([
|
|
609
|
-
Type(() =>
|
|
610
|
-
__metadata("design:type",
|
|
1052
|
+
Type(() => UserAddress),
|
|
1053
|
+
__metadata("design:type", UserAddress)
|
|
611
1054
|
], Subscription.prototype, "billingAddress", void 0);
|
|
612
1055
|
__decorate([
|
|
613
1056
|
Type(() => Coupon),
|
|
@@ -623,63 +1066,24 @@ __decorate([
|
|
|
623
1066
|
], Subscription.prototype, "payment", void 0);
|
|
624
1067
|
|
|
625
1068
|
class Filter extends BaseModel {
|
|
626
|
-
identifierFields() {
|
|
627
|
-
return ['id'];
|
|
628
|
-
}
|
|
629
1069
|
static get identifiersFields() {
|
|
630
1070
|
return ['id'];
|
|
631
1071
|
}
|
|
632
1072
|
}
|
|
633
1073
|
|
|
634
|
-
class
|
|
635
|
-
identifierFields() {
|
|
636
|
-
return ['id'];
|
|
637
|
-
}
|
|
1074
|
+
class KitProduct extends BaseModel {
|
|
638
1075
|
static get identifiersFields() {
|
|
639
|
-
return ['
|
|
1076
|
+
return ['productId', 'kitProductId'];
|
|
640
1077
|
}
|
|
641
1078
|
}
|
|
642
1079
|
__decorate([
|
|
643
|
-
Type(() =>
|
|
644
|
-
__metadata("design:type",
|
|
645
|
-
],
|
|
1080
|
+
Type(() => Product),
|
|
1081
|
+
__metadata("design:type", Product)
|
|
1082
|
+
], KitProduct.prototype, "kit", void 0);
|
|
646
1083
|
__decorate([
|
|
647
|
-
Type(() =>
|
|
648
|
-
__metadata("design:type",
|
|
649
|
-
],
|
|
650
|
-
|
|
651
|
-
class CategoryFilter extends BaseModel {
|
|
652
|
-
// identifierFields(): NonFunctionPropertyNames<CategoryFilter>[] {
|
|
653
|
-
// return ['id']
|
|
654
|
-
// }
|
|
655
|
-
static get identifiersFields() {
|
|
656
|
-
return ['id', 'filterId', 'categoryId'];
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
var GenderDestination;
|
|
661
|
-
(function (GenderDestination) {
|
|
662
|
-
GenderDestination["FEMALE"] = "female";
|
|
663
|
-
GenderDestination["MALE"] = "male";
|
|
664
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
665
|
-
})(GenderDestination || (GenderDestination = {}));
|
|
666
|
-
|
|
667
|
-
var Shops;
|
|
668
|
-
(function (Shops) {
|
|
669
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
670
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
671
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
672
|
-
Shops["ALL"] = "ALL";
|
|
673
|
-
})(Shops || (Shops = {}));
|
|
674
|
-
|
|
675
|
-
class FilterOption extends BaseModel {
|
|
676
|
-
identifierFields() {
|
|
677
|
-
return ['id'];
|
|
678
|
-
}
|
|
679
|
-
static get identifiersFields() {
|
|
680
|
-
return ['id'];
|
|
681
|
-
}
|
|
682
|
-
}
|
|
1084
|
+
Type(() => Product),
|
|
1085
|
+
__metadata("design:type", Product)
|
|
1086
|
+
], KitProduct.prototype, "product", void 0);
|
|
683
1087
|
|
|
684
1088
|
class Product extends BaseModel {
|
|
685
1089
|
get evaluation() {
|
|
@@ -700,9 +1104,6 @@ class Product extends BaseModel {
|
|
|
700
1104
|
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
701
1105
|
this.rate = evaluation.rating || this.rate;
|
|
702
1106
|
}
|
|
703
|
-
identifierFields() {
|
|
704
|
-
return ['id'];
|
|
705
|
-
}
|
|
706
1107
|
static get identifiersFields() {
|
|
707
1108
|
return ['id'];
|
|
708
1109
|
}
|
|
@@ -716,24 +1117,70 @@ __decorate([
|
|
|
716
1117
|
__metadata("design:type", Array)
|
|
717
1118
|
], Product.prototype, "kitProducts", void 0);
|
|
718
1119
|
|
|
719
|
-
class
|
|
1120
|
+
class Category extends BaseModel {
|
|
720
1121
|
static get identifiersFields() {
|
|
721
|
-
return ['
|
|
1122
|
+
return ['id'];
|
|
722
1123
|
}
|
|
723
1124
|
}
|
|
724
1125
|
__decorate([
|
|
725
|
-
Type(() =>
|
|
726
|
-
__metadata("design:type",
|
|
727
|
-
],
|
|
1126
|
+
Type(() => Category),
|
|
1127
|
+
__metadata("design:type", Category)
|
|
1128
|
+
], Category.prototype, "parent", void 0);
|
|
1129
|
+
__decorate([
|
|
1130
|
+
Type(() => Filter),
|
|
1131
|
+
__metadata("design:type", Array)
|
|
1132
|
+
], Category.prototype, "filters", void 0);
|
|
728
1133
|
__decorate([
|
|
729
1134
|
Type(() => Product),
|
|
730
|
-
__metadata("design:type",
|
|
731
|
-
],
|
|
1135
|
+
__metadata("design:type", Array)
|
|
1136
|
+
], Category.prototype, "childrenProducts", void 0);
|
|
732
1137
|
|
|
733
|
-
class
|
|
734
|
-
|
|
1138
|
+
class CategoryCollectionChildren extends BaseModel {
|
|
1139
|
+
static get identifiersFields() {
|
|
1140
|
+
return ['collectionId', 'categoryId'];
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
__decorate([
|
|
1144
|
+
Type(() => CategoryCollectionChildren),
|
|
1145
|
+
__metadata("design:type", CategoryCollectionChildren)
|
|
1146
|
+
], CategoryCollectionChildren.prototype, "parent", void 0);
|
|
1147
|
+
|
|
1148
|
+
class CategoryFilter extends BaseModel {
|
|
1149
|
+
static get identifiersFields() {
|
|
1150
|
+
return ['id'];
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
__decorate([
|
|
1154
|
+
Type(() => Filter),
|
|
1155
|
+
__metadata("design:type", Filter)
|
|
1156
|
+
], CategoryFilter.prototype, "filter", void 0);
|
|
1157
|
+
__decorate([
|
|
1158
|
+
Type(() => Category),
|
|
1159
|
+
__metadata("design:type", Category)
|
|
1160
|
+
], CategoryFilter.prototype, "category", void 0);
|
|
1161
|
+
|
|
1162
|
+
var GenderDestination;
|
|
1163
|
+
(function (GenderDestination) {
|
|
1164
|
+
GenderDestination["FEMALE"] = "female";
|
|
1165
|
+
GenderDestination["MALE"] = "male";
|
|
1166
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
1167
|
+
})(GenderDestination || (GenderDestination = {}));
|
|
1168
|
+
|
|
1169
|
+
var Shops;
|
|
1170
|
+
(function (Shops) {
|
|
1171
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
1172
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
1173
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
1174
|
+
Shops["ALL"] = "ALL";
|
|
1175
|
+
})(Shops || (Shops = {}));
|
|
1176
|
+
|
|
1177
|
+
class FilterOption extends BaseModel {
|
|
1178
|
+
static get identifiersFields() {
|
|
735
1179
|
return ['id'];
|
|
736
1180
|
}
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
class Variant extends BaseModel {
|
|
737
1184
|
static get identifiersFields() {
|
|
738
1185
|
return ['id', 'productId'];
|
|
739
1186
|
}
|
|
@@ -784,12 +1231,12 @@ __decorate([
|
|
|
784
1231
|
__metadata("design:type", User)
|
|
785
1232
|
], Checkout.prototype, "user", void 0);
|
|
786
1233
|
__decorate([
|
|
787
|
-
Type(() =>
|
|
788
|
-
__metadata("design:type",
|
|
1234
|
+
Type(() => UserAddress),
|
|
1235
|
+
__metadata("design:type", UserAddress)
|
|
789
1236
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
790
1237
|
__decorate([
|
|
791
|
-
Type(() =>
|
|
792
|
-
__metadata("design:type",
|
|
1238
|
+
Type(() => UserAddress),
|
|
1239
|
+
__metadata("design:type", UserAddress)
|
|
793
1240
|
], Checkout.prototype, "billingAddress", void 0);
|
|
794
1241
|
__decorate([
|
|
795
1242
|
Type(() => ShippingMethod),
|
|
@@ -825,12 +1272,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
825
1272
|
}
|
|
826
1273
|
}
|
|
827
1274
|
__decorate([
|
|
828
|
-
Type(() =>
|
|
829
|
-
__metadata("design:type",
|
|
1275
|
+
Type(() => UserAddress),
|
|
1276
|
+
__metadata("design:type", UserAddress)
|
|
830
1277
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
831
1278
|
__decorate([
|
|
832
|
-
Type(() =>
|
|
833
|
-
__metadata("design:type",
|
|
1279
|
+
Type(() => UserAddress),
|
|
1280
|
+
__metadata("design:type", UserAddress)
|
|
834
1281
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
835
1282
|
__decorate([
|
|
836
1283
|
Type(() => SubscriptionPlan),
|
|
@@ -855,12 +1302,12 @@ __decorate([
|
|
|
855
1302
|
__metadata("design:type", SubscriptionPlan)
|
|
856
1303
|
], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
|
|
857
1304
|
__decorate([
|
|
858
|
-
Type(() =>
|
|
859
|
-
__metadata("design:type",
|
|
1305
|
+
Type(() => UserAddress),
|
|
1306
|
+
__metadata("design:type", UserAddress)
|
|
860
1307
|
], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
|
|
861
1308
|
__decorate([
|
|
862
|
-
Type(() =>
|
|
863
|
-
__metadata("design:type",
|
|
1309
|
+
Type(() => UserAddress),
|
|
1310
|
+
__metadata("design:type", UserAddress)
|
|
864
1311
|
], SubscriptionMaterialization.prototype, "billingAddress", void 0);
|
|
865
1312
|
__decorate([
|
|
866
1313
|
Type(() => Coupon),
|
|
@@ -875,12 +1322,6 @@ __decorate([
|
|
|
875
1322
|
__metadata("design:type", SubscriptionPayment)
|
|
876
1323
|
], SubscriptionMaterialization.prototype, "payment", void 0);
|
|
877
1324
|
|
|
878
|
-
class UserAddress extends Address {
|
|
879
|
-
static get identifiersFields() {
|
|
880
|
-
return ['id', 'userId'];
|
|
881
|
-
}
|
|
882
|
-
}
|
|
883
|
-
|
|
884
1325
|
class UserPaymentMethod extends BaseModel {
|
|
885
1326
|
static get identifiersFields() {
|
|
886
1327
|
return ['id', 'userId'];
|
|
@@ -1003,6 +1444,20 @@ class RecoveryPassword {
|
|
|
1003
1444
|
}
|
|
1004
1445
|
}
|
|
1005
1446
|
|
|
1447
|
+
class RoundProductPricesHelper {
|
|
1448
|
+
static roundProductPrices(product) {
|
|
1449
|
+
product.price.price = Number(product.price.price.toFixed(2));
|
|
1450
|
+
product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
|
|
1451
|
+
if (product.price.subscriberPrice) {
|
|
1452
|
+
product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
|
|
1453
|
+
}
|
|
1454
|
+
if (product instanceof LineItem && product.pricePaid) {
|
|
1455
|
+
product.pricePaid = Number(product.pricePaid.toFixed(2));
|
|
1456
|
+
}
|
|
1457
|
+
return product;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1006
1461
|
var FilterType;
|
|
1007
1462
|
(function (FilterType) {
|
|
1008
1463
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1280,7 +1735,12 @@ class ProductsIndex {
|
|
|
1280
1735
|
},
|
|
1281
1736
|
},
|
|
1282
1737
|
});
|
|
1283
|
-
search.hits = search.hits
|
|
1738
|
+
search.hits = search.hits
|
|
1739
|
+
.filter((e) => e._source.name !== '')
|
|
1740
|
+
.map((hit) => {
|
|
1741
|
+
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
1742
|
+
return hit;
|
|
1743
|
+
});
|
|
1284
1744
|
return search;
|
|
1285
1745
|
});
|
|
1286
1746
|
}
|
|
@@ -1339,13 +1799,27 @@ const withFirestore = (MixinBase) => {
|
|
|
1339
1799
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1340
1800
|
: bindDate(data[key], key) })), {});
|
|
1341
1801
|
};
|
|
1802
|
+
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1803
|
+
each(value, (v, k) => {
|
|
1804
|
+
if (iteratee(v, k)) {
|
|
1805
|
+
unset(value, k);
|
|
1806
|
+
}
|
|
1807
|
+
else if (isObject(v)) {
|
|
1808
|
+
omitByRecursivelyInPlace(v, iteratee);
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
return value;
|
|
1812
|
+
};
|
|
1342
1813
|
return class extends MixinBase {
|
|
1343
1814
|
collection(path) {
|
|
1344
1815
|
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1345
1816
|
}
|
|
1346
1817
|
buildModelInstance() {
|
|
1347
1818
|
return {
|
|
1348
|
-
toFirestore: (data) =>
|
|
1819
|
+
toFirestore: (data) => {
|
|
1820
|
+
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1821
|
+
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1822
|
+
},
|
|
1349
1823
|
fromFirestore: (snap) => {
|
|
1350
1824
|
const data = snap.data();
|
|
1351
1825
|
let bindedData;
|
|
@@ -1517,9 +1991,9 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1517
1991
|
});
|
|
1518
1992
|
}
|
|
1519
1993
|
save(data) {
|
|
1520
|
-
var _a;
|
|
1994
|
+
var _a, _b;
|
|
1521
1995
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1522
|
-
const id = (_a = data
|
|
1996
|
+
const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
|
|
1523
1997
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1524
1998
|
if (isEmpty(id))
|
|
1525
1999
|
return this.collection(collectionPath).add(data);
|
|
@@ -1822,6 +2296,15 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1822
2296
|
return products;
|
|
1823
2297
|
});
|
|
1824
2298
|
}
|
|
2299
|
+
getCategoryByShop(shop) {
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
getChildren(parentId) {
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
isChild(id, parentId) {
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
1825
2308
|
}
|
|
1826
2309
|
|
|
1827
2310
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
@@ -1873,6 +2356,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1873
2356
|
cleanShoppingCountFromIds(ids) {
|
|
1874
2357
|
return;
|
|
1875
2358
|
}
|
|
2359
|
+
findCatalog(params) {
|
|
2360
|
+
return this.find(params);
|
|
2361
|
+
}
|
|
1876
2362
|
}
|
|
1877
2363
|
|
|
1878
2364
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
@@ -2185,7 +2671,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
|
2185
2671
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
2186
2672
|
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2187
2673
|
};
|
|
2188
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
2674
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.columnName);
|
|
2189
2675
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
2190
2676
|
if (fields.includes(columnName))
|
|
2191
2677
|
return { columnName, attributeName: columnName };
|
|
@@ -2263,22 +2749,23 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2263
2749
|
}, {});
|
|
2264
2750
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2265
2751
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2266
|
-
|
|
2752
|
+
const isNestedField = !Array.isArray(options) &&
|
|
2267
2753
|
isObject(options) &&
|
|
2268
2754
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2269
2755
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2270
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2756
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
|
|
2757
|
+
if (isNestedField)
|
|
2271
2758
|
return Object.keys(options).reduce((variables, key) => {
|
|
2272
2759
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2273
2760
|
const columnName = fieldOptions.columnName;
|
|
2274
2761
|
const columnFields = fieldOptions.fields;
|
|
2275
|
-
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key], columnFields ||
|
|
2762
|
+
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key], (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || columnFields || fields) });
|
|
2276
2763
|
}, {});
|
|
2277
2764
|
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
2278
2765
|
return {
|
|
2279
2766
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2280
2767
|
};
|
|
2281
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2768
|
+
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2282
2769
|
options = Object.values(options)[0];
|
|
2283
2770
|
return Array.isArray(options)
|
|
2284
2771
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2287,16 +2774,20 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2287
2774
|
BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
2288
2775
|
[BindFilterQueryHelper.GetHasuraOperator(options, fieldOption)]: FilterOptionHelper.GetValueFromFilter(options, fieldOption),
|
|
2289
2776
|
});
|
|
2290
|
-
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) =>
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2777
|
+
BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => {
|
|
2778
|
+
if (!FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2779
|
+
return HasuraGraphQLWhere.EQUALS;
|
|
2780
|
+
if (fieldOption.type === HasuraGraphQLColumnType.Jsonb)
|
|
2781
|
+
return BindFilterQueryHelper.GetHasuraJsonbOperator(options);
|
|
2782
|
+
return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
|
|
2783
|
+
};
|
|
2784
|
+
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => {
|
|
2785
|
+
if (options.operator === Where.IN)
|
|
2786
|
+
return '_contains';
|
|
2787
|
+
if (options.operator === Where.LIKE)
|
|
2788
|
+
return '_has_keys_any';
|
|
2789
|
+
return HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
|
|
2790
|
+
};
|
|
2300
2791
|
|
|
2301
2792
|
class GraphQLFieldHelper {
|
|
2302
2793
|
}
|
|
@@ -2311,23 +2802,9 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2311
2802
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2312
2803
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2313
2804
|
return;
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2318
|
-
}
|
|
2319
|
-
: {
|
|
2320
|
-
operation: fieldValue.columnName || fieldName,
|
|
2321
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2322
|
-
variables: {
|
|
2323
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2324
|
-
name: 'where',
|
|
2325
|
-
type: fieldValue.filters.filterType,
|
|
2326
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2327
|
-
required: true,
|
|
2328
|
-
},
|
|
2329
|
-
},
|
|
2330
|
-
};
|
|
2805
|
+
const isNestedField = !!fieldValue.fields;
|
|
2806
|
+
if (isNestedField)
|
|
2807
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
2331
2808
|
return fieldValue.columnName;
|
|
2332
2809
|
}).filter((field) => !!field);
|
|
2333
2810
|
};
|
|
@@ -2383,6 +2860,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2383
2860
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2384
2861
|
}, {});
|
|
2385
2862
|
};
|
|
2863
|
+
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2864
|
+
const hasCustomFilters = !!fieldValue.filters;
|
|
2865
|
+
if (hasCustomFilters)
|
|
2866
|
+
return {
|
|
2867
|
+
operation: fieldValue.columnName || fieldName,
|
|
2868
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2869
|
+
variables: {
|
|
2870
|
+
[`${fieldValue.columnName}_where`]: {
|
|
2871
|
+
name: 'where',
|
|
2872
|
+
type: fieldValue.filters.filterType,
|
|
2873
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2874
|
+
required: true,
|
|
2875
|
+
},
|
|
2876
|
+
},
|
|
2877
|
+
};
|
|
2878
|
+
return {
|
|
2879
|
+
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2880
|
+
};
|
|
2881
|
+
};
|
|
2386
2882
|
|
|
2387
2883
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2388
2884
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2390,14 +2886,30 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2390
2886
|
const options = params === null || params === void 0 ? void 0 : params[0];
|
|
2391
2887
|
super(...params);
|
|
2392
2888
|
this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || `insert_${this.tableName}_one`;
|
|
2889
|
+
this.insertAllGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertAllGraphQLOperation) || `insert_${this.tableName}`;
|
|
2393
2890
|
this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || `${this.tableName}_insert_input`;
|
|
2394
2891
|
}
|
|
2395
2892
|
create(data) {
|
|
2396
2893
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2894
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
2397
2895
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2398
2896
|
return this.model.toInstance(newData);
|
|
2399
2897
|
});
|
|
2400
2898
|
}
|
|
2899
|
+
createAll(data) {
|
|
2900
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2901
|
+
this.logger = DebugHelper.from(this, 'createAll');
|
|
2902
|
+
const result = yield this.mutation(this.insertAllGraphQLOperation, [{ returning: this.model.identifiersFields }], {
|
|
2903
|
+
objects: {
|
|
2904
|
+
type: this.insertGraphQLObjectType,
|
|
2905
|
+
required: true,
|
|
2906
|
+
list: true,
|
|
2907
|
+
value: data.map((item) => this.convertDataToHasura(item)),
|
|
2908
|
+
},
|
|
2909
|
+
});
|
|
2910
|
+
return result[this.insertAllGraphQLOperation].returning.map((item, index) => this.model.toInstance(Object.assign(Object.assign({}, data[index]), item)));
|
|
2911
|
+
});
|
|
2912
|
+
}
|
|
2401
2913
|
save(data) {
|
|
2402
2914
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2403
2915
|
const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
|
|
@@ -2410,8 +2922,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2410
2922
|
{
|
|
2411
2923
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2412
2924
|
var _a;
|
|
2413
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2414
|
-
foreignKeyField;
|
|
2925
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
|
|
2415
2926
|
}),
|
|
2416
2927
|
},
|
|
2417
2928
|
]);
|
|
@@ -2436,9 +2947,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2436
2947
|
}
|
|
2437
2948
|
delete(identifiers) {
|
|
2438
2949
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2950
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
2439
2951
|
const instance = this.model.toInstance(identifiers);
|
|
2440
2952
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2441
|
-
|
|
2953
|
+
const identifierBinded = identifier;
|
|
2954
|
+
if (isNil(instance[identifierBinded]))
|
|
2442
2955
|
return ids;
|
|
2443
2956
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2444
2957
|
const value = columnOption.to(identifiers[identifier.toString()], instance);
|
|
@@ -2463,6 +2976,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2463
2976
|
this.authOptions = options.authOptions;
|
|
2464
2977
|
this.model = options.model;
|
|
2465
2978
|
this.fields = options.fields || this.model.identifiersFields;
|
|
2979
|
+
this.logger = DebugHelper.from(this);
|
|
2466
2980
|
}
|
|
2467
2981
|
get headers() {
|
|
2468
2982
|
return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
|
|
@@ -2497,6 +3011,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2497
3011
|
}
|
|
2498
3012
|
fetch(params) {
|
|
2499
3013
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3014
|
+
this.logger.with('params').log(params);
|
|
2500
3015
|
const headers = this.headers;
|
|
2501
3016
|
const { data: result } = yield axios({
|
|
2502
3017
|
url: `${this.endpoint}`,
|
|
@@ -2506,6 +3021,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2506
3021
|
});
|
|
2507
3022
|
if (!isNil(result.errors))
|
|
2508
3023
|
throw new Error(JSON.stringify(result.errors));
|
|
3024
|
+
this.logger.with('returns').log(result);
|
|
2509
3025
|
return result.data;
|
|
2510
3026
|
});
|
|
2511
3027
|
}
|
|
@@ -2532,8 +3048,8 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2532
3048
|
return value;
|
|
2533
3049
|
return date;
|
|
2534
3050
|
}
|
|
2535
|
-
convertDataFromHasura(data) {
|
|
2536
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3051
|
+
convertDataFromHasura(data, fields) {
|
|
3052
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
2537
3053
|
return this.model.toInstance(plain);
|
|
2538
3054
|
}
|
|
2539
3055
|
convertDataToHasura(instance, update = false) {
|
|
@@ -2562,6 +3078,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2562
3078
|
}
|
|
2563
3079
|
update(data) {
|
|
2564
3080
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3081
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
2565
3082
|
const plainData = this.paramsToPlain(data);
|
|
2566
3083
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2567
3084
|
_set: {
|
|
@@ -2584,10 +3101,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2584
3101
|
const instance = this.model.toInstance(data);
|
|
2585
3102
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2586
3103
|
var _a;
|
|
2587
|
-
|
|
3104
|
+
const identifierBinded = identifier;
|
|
3105
|
+
if (isNil(instance[identifierBinded]))
|
|
2588
3106
|
return ids;
|
|
2589
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
2590
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[
|
|
3107
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
|
|
3108
|
+
const 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];
|
|
2591
3109
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2592
3110
|
}, {});
|
|
2593
3111
|
}
|
|
@@ -2603,10 +3121,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2603
3121
|
}
|
|
2604
3122
|
get(identifiers) {
|
|
2605
3123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3124
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
2606
3125
|
const instance = this.model.toInstance(identifiers);
|
|
2607
3126
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2608
3127
|
var _a;
|
|
2609
|
-
|
|
3128
|
+
const identifierBinded = identifier;
|
|
3129
|
+
if (isNil(instance[identifierBinded]))
|
|
2610
3130
|
return ids;
|
|
2611
3131
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2612
3132
|
const 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()];
|
|
@@ -2627,12 +3147,49 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2627
3147
|
|
|
2628
3148
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2629
3149
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
3150
|
+
constructor() {
|
|
3151
|
+
super(...arguments);
|
|
3152
|
+
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3153
|
+
.columnName]: orderBy[current] })), {});
|
|
3154
|
+
this.bindAggretageAttributes = (aggregates, fields) => {
|
|
3155
|
+
var _a, _b;
|
|
3156
|
+
return [
|
|
3157
|
+
...(((_a = aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal) === null || _a === void 0 ? void 0 : _a.length)
|
|
3158
|
+
? [
|
|
3159
|
+
{
|
|
3160
|
+
min: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal, fields),
|
|
3161
|
+
},
|
|
3162
|
+
]
|
|
3163
|
+
: []),
|
|
3164
|
+
...(((_b = aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum) === null || _b === void 0 ? void 0 : _b.length)
|
|
3165
|
+
? [
|
|
3166
|
+
{
|
|
3167
|
+
max: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum, fields),
|
|
3168
|
+
},
|
|
3169
|
+
]
|
|
3170
|
+
: []),
|
|
3171
|
+
];
|
|
3172
|
+
};
|
|
3173
|
+
this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => {
|
|
3174
|
+
var _a;
|
|
3175
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
2630
3178
|
find(params) {
|
|
2631
|
-
var _a;
|
|
3179
|
+
var _a, _b, _c;
|
|
2632
3180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3181
|
+
this.logger = DebugHelper.from(this, 'find');
|
|
2633
3182
|
const { filters, limits, orderBy, options } = params || {};
|
|
2634
3183
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2635
|
-
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3184
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3185
|
+
? {}
|
|
3186
|
+
: {
|
|
3187
|
+
order_by: {
|
|
3188
|
+
type: `${this.tableName}_order_by!`,
|
|
3189
|
+
list: true,
|
|
3190
|
+
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3191
|
+
},
|
|
3192
|
+
})), (isNil(filters)
|
|
2636
3193
|
? {}
|
|
2637
3194
|
: {
|
|
2638
3195
|
where: {
|
|
@@ -2642,6 +3199,10 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2642
3199
|
},
|
|
2643
3200
|
}));
|
|
2644
3201
|
const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
|
|
3202
|
+
const aggregateFields = [
|
|
3203
|
+
...(enableCount ? ['count'] : []),
|
|
3204
|
+
...this.bindAggretageAttributes(params.options, this.fields),
|
|
3205
|
+
];
|
|
2645
3206
|
const result = yield this.query([
|
|
2646
3207
|
{
|
|
2647
3208
|
operation: this.tableName,
|
|
@@ -2655,18 +3216,36 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2655
3216
|
: this.fields,
|
|
2656
3217
|
variables,
|
|
2657
3218
|
},
|
|
2658
|
-
...(
|
|
3219
|
+
...(aggregateFields.length > 0
|
|
2659
3220
|
? [
|
|
2660
3221
|
{
|
|
2661
3222
|
operation: `${this.tableName}_aggregate`,
|
|
2662
|
-
fields: [
|
|
3223
|
+
fields: [
|
|
3224
|
+
{
|
|
3225
|
+
aggregate: aggregateFields,
|
|
3226
|
+
},
|
|
3227
|
+
],
|
|
2663
3228
|
variables: variablesCount,
|
|
2664
3229
|
},
|
|
2665
3230
|
]
|
|
2666
3231
|
: []),
|
|
2667
3232
|
]);
|
|
2668
3233
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2669
|
-
return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }
|
|
3234
|
+
return Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_b = options === null || options === void 0 ? void 0 : options.minimal) === null || _b === void 0 ? void 0 : _b.length)
|
|
3235
|
+
? {
|
|
3236
|
+
minimal: options.minimal.reduce((minimals, current) => {
|
|
3237
|
+
var _a;
|
|
3238
|
+
return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3239
|
+
}, {}),
|
|
3240
|
+
}
|
|
3241
|
+
: {})), (((_c = options === null || options === void 0 ? void 0 : options.maximum) === null || _c === void 0 ? void 0 : _c.length)
|
|
3242
|
+
? {
|
|
3243
|
+
maximum: options.maximum.reduce((maximums, current) => {
|
|
3244
|
+
var _a;
|
|
3245
|
+
return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3246
|
+
}, {}),
|
|
3247
|
+
}
|
|
3248
|
+
: {}));
|
|
2670
3249
|
});
|
|
2671
3250
|
}
|
|
2672
3251
|
};
|
|
@@ -2706,6 +3285,41 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2706
3285
|
}
|
|
2707
3286
|
}
|
|
2708
3287
|
|
|
3288
|
+
class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3289
|
+
constructor(endpoint, authOptions) {
|
|
3290
|
+
super({
|
|
3291
|
+
tableName: 'category_collection_children',
|
|
3292
|
+
model: CategoryCollectionChildren,
|
|
3293
|
+
endpoint,
|
|
3294
|
+
authOptions,
|
|
3295
|
+
fields: [
|
|
3296
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3297
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3298
|
+
'name',
|
|
3299
|
+
'slug',
|
|
3300
|
+
'reference',
|
|
3301
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3302
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3303
|
+
{
|
|
3304
|
+
parent: {
|
|
3305
|
+
columnName: 'parent',
|
|
3306
|
+
foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
|
|
3307
|
+
fields: [
|
|
3308
|
+
{ collectionId: { columnName: 'collection_id' } },
|
|
3309
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3310
|
+
'name',
|
|
3311
|
+
'slug',
|
|
3312
|
+
'reference',
|
|
3313
|
+
{ parentCollectionId: { columnName: 'parent_collection_id' } },
|
|
3314
|
+
{ parentCategoryId: { columnName: 'parent_category_id' } },
|
|
3315
|
+
],
|
|
3316
|
+
},
|
|
3317
|
+
},
|
|
3318
|
+
],
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
|
|
2709
3323
|
class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2710
3324
|
constructor(endpoint, authOptions) {
|
|
2711
3325
|
super({
|
|
@@ -2713,7 +3327,80 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
2713
3327
|
model: CategoryFilter,
|
|
2714
3328
|
endpoint,
|
|
2715
3329
|
authOptions,
|
|
2716
|
-
fields: [
|
|
3330
|
+
fields: [
|
|
3331
|
+
'id',
|
|
3332
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3333
|
+
{ categoryId: { columnName: 'category_id' } },
|
|
3334
|
+
{
|
|
3335
|
+
filter: {
|
|
3336
|
+
columnName: 'filter',
|
|
3337
|
+
foreignKeyColumn: { id: 'filterId' },
|
|
3338
|
+
fields: [
|
|
3339
|
+
'id',
|
|
3340
|
+
'description',
|
|
3341
|
+
'slug',
|
|
3342
|
+
'enabled',
|
|
3343
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3344
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3345
|
+
{
|
|
3346
|
+
options: {
|
|
3347
|
+
columnName: 'options',
|
|
3348
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
3349
|
+
fields: [
|
|
3350
|
+
'id',
|
|
3351
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
3352
|
+
'description',
|
|
3353
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3354
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3355
|
+
],
|
|
3356
|
+
},
|
|
3357
|
+
},
|
|
3358
|
+
],
|
|
3359
|
+
},
|
|
3360
|
+
},
|
|
3361
|
+
{
|
|
3362
|
+
category: {
|
|
3363
|
+
columnName: 'category',
|
|
3364
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
3365
|
+
fields: [
|
|
3366
|
+
'id',
|
|
3367
|
+
'description',
|
|
3368
|
+
{
|
|
3369
|
+
products: {
|
|
3370
|
+
columnName: 'products',
|
|
3371
|
+
fields: ['product_id'],
|
|
3372
|
+
from: (value) => value.map((product) => product.product_id.toString()),
|
|
3373
|
+
to: (productIds) => productIds.map((productId) => ({
|
|
3374
|
+
product_id: +productId,
|
|
3375
|
+
})),
|
|
3376
|
+
},
|
|
3377
|
+
},
|
|
3378
|
+
{
|
|
3379
|
+
childrenProducts: {
|
|
3380
|
+
columnName: 'children_products',
|
|
3381
|
+
foreignKeyColumn: { category_id: 'id' },
|
|
3382
|
+
fields: [
|
|
3383
|
+
'id',
|
|
3384
|
+
'name',
|
|
3385
|
+
'slug',
|
|
3386
|
+
{
|
|
3387
|
+
categories: {
|
|
3388
|
+
columnName: 'categories',
|
|
3389
|
+
fields: ['category_id'],
|
|
3390
|
+
bindPersistData: (value) => ({
|
|
3391
|
+
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
3392
|
+
}),
|
|
3393
|
+
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
3394
|
+
from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
|
|
3395
|
+
},
|
|
3396
|
+
},
|
|
3397
|
+
],
|
|
3398
|
+
},
|
|
3399
|
+
},
|
|
3400
|
+
],
|
|
3401
|
+
},
|
|
3402
|
+
},
|
|
3403
|
+
],
|
|
2717
3404
|
});
|
|
2718
3405
|
}
|
|
2719
3406
|
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
@@ -2742,6 +3429,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2742
3429
|
'image',
|
|
2743
3430
|
'published',
|
|
2744
3431
|
'shop',
|
|
3432
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2745
3433
|
'slug',
|
|
2746
3434
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
2747
3435
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
@@ -2850,7 +3538,16 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2850
3538
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2851
3539
|
if (!slug)
|
|
2852
3540
|
return;
|
|
2853
|
-
const { data } = yield this.find({
|
|
3541
|
+
const { data } = yield this.find({
|
|
3542
|
+
filters: {
|
|
3543
|
+
slug,
|
|
3544
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
3545
|
+
published: { operator: Where.EQUALS, value: true },
|
|
3546
|
+
},
|
|
3547
|
+
options: {
|
|
3548
|
+
enableCount: false,
|
|
3549
|
+
},
|
|
3550
|
+
});
|
|
2854
3551
|
if (!data.length)
|
|
2855
3552
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2856
3553
|
if (data.length > 1)
|
|
@@ -2858,6 +3555,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2858
3555
|
return data.shift();
|
|
2859
3556
|
});
|
|
2860
3557
|
}
|
|
3558
|
+
getCategoryByShop(shop) {
|
|
3559
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3560
|
+
if (!shop)
|
|
3561
|
+
return;
|
|
3562
|
+
const { data } = yield this.find({
|
|
3563
|
+
filters: {
|
|
3564
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
3565
|
+
published: { operator: Where.EQUALS, value: true },
|
|
3566
|
+
},
|
|
3567
|
+
options: {
|
|
3568
|
+
enableCount: false,
|
|
3569
|
+
},
|
|
3570
|
+
});
|
|
3571
|
+
return data;
|
|
3572
|
+
});
|
|
3573
|
+
}
|
|
2861
3574
|
getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
2862
3575
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2863
3576
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
@@ -3052,6 +3765,24 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3052
3765
|
}
|
|
3053
3766
|
});
|
|
3054
3767
|
}
|
|
3768
|
+
getChildren(parentId) {
|
|
3769
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3770
|
+
const { category_tree } = yield this.query('category_tree', ['id', 'name', 'parent_id'], {
|
|
3771
|
+
args: {
|
|
3772
|
+
type: 'category_tree_args',
|
|
3773
|
+
value: { parentid: parentId },
|
|
3774
|
+
required: true,
|
|
3775
|
+
},
|
|
3776
|
+
});
|
|
3777
|
+
return category_tree.map((category) => Category.toInstance(category));
|
|
3778
|
+
});
|
|
3779
|
+
}
|
|
3780
|
+
isChild(id, parentId) {
|
|
3781
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3782
|
+
const categoryTree = yield this.getChildren(parentId);
|
|
3783
|
+
return categoryTree.some((c) => c.id == id.toString());
|
|
3784
|
+
});
|
|
3785
|
+
}
|
|
3055
3786
|
}
|
|
3056
3787
|
|
|
3057
3788
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -3220,26 +3951,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3220
3951
|
whoMustUse: data.who_must_use,
|
|
3221
3952
|
howToUse: data.how_to_use,
|
|
3222
3953
|
brand: data.brand_description,
|
|
3954
|
+
ingredients: data.ingredients,
|
|
3223
3955
|
}),
|
|
3224
|
-
bindFindFilter: (
|
|
3225
|
-
|
|
3226
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
|
|
3956
|
+
bindFindFilter: (filters) => {
|
|
3957
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
|
|
3227
3958
|
who_must_use: filters.whoMustUse,
|
|
3228
3959
|
})), (filters.howToUse && {
|
|
3229
3960
|
how_to_use: filters.howToUse,
|
|
3230
3961
|
})), (filters.brand && {
|
|
3231
3962
|
brand_description: filters.brand,
|
|
3963
|
+
})), (filters.ingredients && {
|
|
3964
|
+
ingredients: filters.ingredients,
|
|
3232
3965
|
}));
|
|
3233
3966
|
},
|
|
3234
|
-
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
|
|
3967
|
+
bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
|
|
3235
3968
|
who_must_use: descriptionData.whoMustUse,
|
|
3236
|
-
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))),
|
|
3969
|
+
})), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand })), (descriptionData.ingredients && { ingredients: descriptionData.ingredients }))),
|
|
3237
3970
|
},
|
|
3238
3971
|
},
|
|
3239
3972
|
{ differentials: { columnName: 'differentials' } },
|
|
3240
3973
|
{ whoMustUse: { columnName: 'who_must_use' } },
|
|
3241
3974
|
{ howToUse: { columnName: 'how_to_use' } },
|
|
3242
3975
|
{ brandDescription: { columnName: 'brand_description' } },
|
|
3976
|
+
{ ingredients: { columnName: 'ingredients' } },
|
|
3243
3977
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
3244
3978
|
{
|
|
3245
3979
|
images: {
|
|
@@ -3263,8 +3997,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3263
3997
|
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
3264
3998
|
subscriberPrice: data.subscriber_price,
|
|
3265
3999
|
}),
|
|
3266
|
-
bindFindFilter: (
|
|
3267
|
-
const filters = Object.values(sentence).shift();
|
|
4000
|
+
bindFindFilter: (filters) => {
|
|
3268
4001
|
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) && {
|
|
3269
4002
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
3270
4003
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
@@ -3288,11 +4021,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3288
4021
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
3289
4022
|
},
|
|
3290
4023
|
},
|
|
4024
|
+
{ hasStock: { columnName: 'has_stock' } },
|
|
3291
4025
|
'slug',
|
|
3292
4026
|
'type',
|
|
3293
4027
|
'video',
|
|
3294
4028
|
'weight',
|
|
3295
4029
|
'gender',
|
|
4030
|
+
{ intGender: { columnName: 'int_gender' } },
|
|
3296
4031
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3297
4032
|
{ filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3298
4033
|
{ isKit: { columnName: 'is_kit' } },
|
|
@@ -3407,12 +4142,19 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3407
4142
|
const _super = Object.create(null, {
|
|
3408
4143
|
find: { get: () => super.find }
|
|
3409
4144
|
});
|
|
4145
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3410
4146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3411
|
-
const
|
|
4147
|
+
const _o = params || {}, { filters, fields } = _o, options = __rest(_o, ["filters", "fields"]);
|
|
3412
4148
|
const bindFields = fields ||
|
|
3413
4149
|
this.fields
|
|
3414
4150
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
3415
4151
|
.filter((field) => field !== 'reviews');
|
|
4152
|
+
if ((_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.minimal) === null || _b === void 0 ? void 0 : _b.includes('price'))
|
|
4153
|
+
(_c = options.options) === null || _c === void 0 ? void 0 : _c.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
4154
|
+
if ((_e = (_d = options.options) === null || _d === void 0 ? void 0 : _d.maximum) === null || _e === void 0 ? void 0 : _e.includes('price'))
|
|
4155
|
+
(_f = options.options) === null || _f === void 0 ? void 0 : _f.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
4156
|
+
(_h = (_g = options.options) === null || _g === void 0 ? void 0 : _g.minimal) === null || _h === void 0 ? void 0 : _h.splice((_j = options.options) === null || _j === void 0 ? void 0 : _j.minimal.indexOf('price'), 1);
|
|
4157
|
+
(_l = (_k = options.options) === null || _k === void 0 ? void 0 : _k.maximum) === null || _l === void 0 ? void 0 : _l.splice((_m = options.options) === null || _m === void 0 ? void 0 : _m.maximum.indexOf('price'), 1);
|
|
3416
4158
|
return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: [
|
|
3417
4159
|
...bindFields,
|
|
3418
4160
|
...(bindFields.includes('price')
|
|
@@ -3438,6 +4180,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3438
4180
|
},
|
|
3439
4181
|
});
|
|
3440
4182
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
4183
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
3441
4184
|
return product;
|
|
3442
4185
|
});
|
|
3443
4186
|
}
|
|
@@ -3477,6 +4220,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3477
4220
|
], []);
|
|
3478
4221
|
});
|
|
3479
4222
|
}
|
|
4223
|
+
findCatalog(params, mainGender) {
|
|
4224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4225
|
+
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign({ hasStock: 'desc', intGender: mainGender === 'female' ? 'desc' : 'asc' }, omit(params.orderBy, ['hasStock', 'intGender'])) }));
|
|
4226
|
+
});
|
|
4227
|
+
}
|
|
3480
4228
|
updateCategories(productId, { categories }) {
|
|
3481
4229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3482
4230
|
if ('action' in categories && categories.action === 'remove') {
|
|
@@ -3719,6 +4467,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3719
4467
|
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
3720
4468
|
},
|
|
3721
4469
|
},
|
|
4470
|
+
{ hasStock: { columnName: 'has_stock' } },
|
|
3722
4471
|
'weight',
|
|
3723
4472
|
{ name: { to: () => '', from: () => undefined } },
|
|
3724
4473
|
{ hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
|
|
@@ -3786,5 +4535,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3786
4535
|
* Generated bundle index. Do not edit.
|
|
3787
4536
|
*/
|
|
3788
4537
|
|
|
3789
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
4538
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3790
4539
|
//# sourceMappingURL=infrab4a-connect.js.map
|