@infrab4a/connect 4.0.0-beta.26 → 4.0.0-beta.28
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/domain/catalog/models/category-collection-children.d.ts +1 -2
- package/domain/catalog/models/category-filter.d.ts +1 -1
- package/domain/catalog/models/category.d.ts +1 -2
- package/domain/catalog/models/filter-option.d.ts +1 -2
- package/domain/catalog/models/filter.d.ts +1 -2
- package/domain/catalog/models/kit-product.d.ts +1 -1
- package/domain/catalog/models/product.d.ts +1 -2
- package/domain/catalog/models/variant.d.ts +1 -2
- package/domain/generic/model/base.model.d.ts +9 -5
- package/domain/generic/model/types/base-model-builder.type.d.ts +4 -2
- package/domain/generic/model/types/identifier-model.type.d.ts +6 -5
- package/domain/generic/model/types/model-base-structure.type.d.ts +9 -3
- package/domain/generic/model/types/non-function-property-name.type.d.ts +12 -3
- package/domain/generic/repository/get.repository.d.ts +2 -2
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
- package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
- package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
- package/domain/location/models/address.d.ts +4 -3
- package/domain/shopping/models/checkout.d.ts +5 -6
- package/domain/shopping/models/subscription/checkout.d.ts +3 -4
- package/domain/users/models/subscription/subscription.d.ts +3 -3
- package/domain/users/models/user-address.d.ts +1 -2
- package/domain/users/models/user.d.ts +2 -3
- package/esm2020/domain/catalog/models/category-collection-children.mjs +1 -4
- package/esm2020/domain/catalog/models/category-filter.mjs +1 -1
- package/esm2020/domain/catalog/models/category.mjs +1 -4
- package/esm2020/domain/catalog/models/filter-option.mjs +1 -4
- package/esm2020/domain/catalog/models/filter.mjs +1 -4
- package/esm2020/domain/catalog/models/kit-product.mjs +2 -2
- package/esm2020/domain/catalog/models/product.mjs +1 -4
- package/esm2020/domain/catalog/models/variant.mjs +1 -4
- package/esm2020/domain/generic/model/base.model.mjs +3 -2
- package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +1 -1
- package/esm2020/domain/generic/model/types/identifier-model.type.mjs +1 -1
- package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +1 -1
- package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +1 -1
- package/esm2020/domain/generic/repository/get.repository.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs +1 -1
- package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +1 -1
- package/esm2020/domain/location/models/address.mjs +2 -2
- package/esm2020/domain/shopping/models/checkout.mjs +6 -7
- package/esm2020/domain/shopping/models/order.mjs +1 -1
- package/esm2020/domain/shopping/models/subscription/checkout.mjs +6 -6
- package/esm2020/domain/users/models/subscription/subscription.mjs +6 -6
- package/esm2020/domain/users/models/user-address.mjs +1 -1
- package/esm2020/domain/users/models/user.mjs +3 -3
- package/esm2020/domain/users/use-cases/authentication.mjs +2 -2
- package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +2 -2
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +3 -3
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +17 -2
- package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +5 -4
- package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +25 -20
- package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +5 -3
- package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +5 -3
- package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +21 -4
- package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +5 -3
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +12 -5
- package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +7 -5
- package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +1 -1
- package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
- package/esm2020/utils/decorators/debug.class.decorator.mjs +7 -0
- package/esm2020/utils/decorators/index.mjs +3 -0
- package/esm2020/utils/decorators/trace.method.decorator.mjs +81 -0
- package/esm2020/utils/helpers/class-name.helper.mjs +15 -0
- package/esm2020/utils/helpers/debug-decorator.helper.mjs +18 -0
- package/esm2020/utils/helpers/debug.helper.mjs +150 -0
- package/esm2020/utils/helpers/index.mjs +5 -0
- package/esm2020/utils/helpers/reflect.helper.mjs +165 -0
- package/esm2020/utils/index.mjs +6 -3
- package/esm2020/utils/log.utils.mjs +9 -0
- package/fesm2015/infrab4a-connect.mjs +546 -82
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +550 -82
- package/fesm2020/infrab4a-connect.mjs.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 +1 -1
- package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
- 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 +9 -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 +8 -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 +1 -1
- package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +1 -1
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +11 -9
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +7 -6
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +7 -5
- 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 +5 -2
- 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 { get as get$1, 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 as get$1, isString, each, unset, isObject, isNumber, isDate, set, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
|
|
7
|
+
export { chunk, each, 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 { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
|
|
@@ -14,7 +16,8 @@ import { mutation, query as query$1 } from 'gql-query-builder';
|
|
|
14
16
|
class BaseModel {
|
|
15
17
|
get identifier() {
|
|
16
18
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
17
|
-
|
|
19
|
+
const data = this;
|
|
20
|
+
return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
|
|
18
21
|
}
|
|
19
22
|
get identifiersFields() {
|
|
20
23
|
return this.constructor.identifiersFields;
|
|
@@ -460,12 +463,438 @@ __decorate([
|
|
|
460
463
|
__metadata("design:type", Payment)
|
|
461
464
|
], SubscriptionPayment.prototype, "payment", void 0);
|
|
462
465
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
+
var DebugNamespaces;
|
|
467
|
+
(function (DebugNamespaces) {
|
|
468
|
+
DebugNamespaces["ROOT"] = "connect";
|
|
469
|
+
DebugNamespaces["TRACE"] = "trace";
|
|
470
|
+
DebugNamespaces["ERROR"] = "error";
|
|
471
|
+
})(DebugNamespaces || (DebugNamespaces = {}));
|
|
472
|
+
const Logger = debug(DebugNamespaces.ROOT);
|
|
473
|
+
|
|
474
|
+
class ReflectHelper {
|
|
475
|
+
static get items() {
|
|
476
|
+
return this._items;
|
|
477
|
+
}
|
|
478
|
+
static get keys() {
|
|
479
|
+
return Object.keys(ReflectHelper.items);
|
|
480
|
+
}
|
|
481
|
+
static has(key, target, property) {
|
|
482
|
+
return (!isNil(key) &&
|
|
483
|
+
!isNil(ReflectHelper.items[key]) &&
|
|
484
|
+
(isNil(target) ||
|
|
485
|
+
(!isNil(ReflectHelper.items[key][target]) &&
|
|
486
|
+
(isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
|
|
487
|
+
}
|
|
488
|
+
static get({ key, target, property, own = true }) {
|
|
489
|
+
try {
|
|
490
|
+
if (own) {
|
|
491
|
+
return Reflect.getOwnMetadata(key, target, property) || null;
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
return Reflect.getMetadata(key, target, property) || null;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
catch (_err) {
|
|
498
|
+
return null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
static first({ key, target, property, own = true }) {
|
|
502
|
+
const values = ReflectHelper.get({ key, target, property, own });
|
|
503
|
+
return isArray(values) ? first(values) : values;
|
|
504
|
+
}
|
|
505
|
+
static last({ key, target, property, own = true }) {
|
|
506
|
+
const values = ReflectHelper.get({ key, target, property, own });
|
|
507
|
+
return isArray(values) ? last(values) : values;
|
|
508
|
+
}
|
|
509
|
+
static set({ key, target, property, value, propertyDescriptor }) {
|
|
510
|
+
Reflect.defineMetadata(key, value, target, property);
|
|
511
|
+
ReflectHelper.put({ key, target, property, value, propertyDescriptor });
|
|
512
|
+
}
|
|
513
|
+
static add({ key, target, property, value, propertyDescriptor }) {
|
|
514
|
+
let values = ReflectHelper.get({ key, target, property }) || new Array();
|
|
515
|
+
if (!Array.isArray(values))
|
|
516
|
+
values = [values];
|
|
517
|
+
values.push(value);
|
|
518
|
+
ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
|
|
519
|
+
}
|
|
520
|
+
static all({ key }) {
|
|
521
|
+
const items = ReflectHelper.items[key] || {};
|
|
522
|
+
return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
|
|
523
|
+
}
|
|
524
|
+
static allFrom(key, target) {
|
|
525
|
+
return Object.keys(target)
|
|
526
|
+
.filter((property) => property !== 'object')
|
|
527
|
+
.map((property) => this.allValuesFrom(key, target, property));
|
|
528
|
+
}
|
|
529
|
+
static allValuesFrom(key, target, property) {
|
|
530
|
+
const values = target[property];
|
|
531
|
+
let value = values.value;
|
|
532
|
+
const propertyDescriptor = values.propertyDescriptor;
|
|
533
|
+
if (!isArray(value))
|
|
534
|
+
value = [value];
|
|
535
|
+
return flatten(value.map((val) => {
|
|
536
|
+
return {
|
|
537
|
+
key,
|
|
538
|
+
target: target.object,
|
|
539
|
+
property,
|
|
540
|
+
value: val,
|
|
541
|
+
propertyDescriptor,
|
|
542
|
+
};
|
|
543
|
+
}));
|
|
544
|
+
}
|
|
545
|
+
static delete({ key, target, property }) {
|
|
546
|
+
Reflect.deleteMetadata(key, target, property);
|
|
547
|
+
return ReflectHelper.remove(key, target, property);
|
|
548
|
+
}
|
|
549
|
+
static clear(key) {
|
|
550
|
+
if (!key) {
|
|
551
|
+
ReflectHelper.keys.forEach((storedKey) => {
|
|
552
|
+
ReflectHelper.clear(storedKey);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
if (ReflectHelper.keys.includes(key)) {
|
|
557
|
+
Object.values(ReflectHelper.items[key]).forEach((target) => {
|
|
558
|
+
if (ReflectHelper.has(key, target)) {
|
|
559
|
+
Object.values(ReflectHelper.items[key][target.toString()]).forEach((property) => {
|
|
560
|
+
ReflectHelper.delete({
|
|
561
|
+
key,
|
|
562
|
+
target: target.object,
|
|
563
|
+
property: String(property),
|
|
564
|
+
});
|
|
565
|
+
ReflectHelper.remove(key, target, String(property));
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
ReflectHelper.delete({ key, target: target.object });
|
|
569
|
+
ReflectHelper.remove(key, target);
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
static getType({ target, propertyKey }) {
|
|
575
|
+
return Reflect.getMetadata('design:type', target, propertyKey);
|
|
576
|
+
}
|
|
577
|
+
static getReturntype({ target, propertyKey }) {
|
|
578
|
+
return Reflect.getMetadata('design:returntype', target, propertyKey);
|
|
579
|
+
}
|
|
580
|
+
static getAllMethods(target) {
|
|
581
|
+
const props = [];
|
|
582
|
+
let obj = target;
|
|
583
|
+
do {
|
|
584
|
+
props.push(...Object.getOwnPropertyNames(obj));
|
|
585
|
+
} while ((obj = Object.getPrototypeOf(obj)));
|
|
586
|
+
return props.sort().filter((e, i, arr) => {
|
|
587
|
+
if ([
|
|
588
|
+
'__defineGetter__',
|
|
589
|
+
'__defineSetter__',
|
|
590
|
+
'__lookupGetter__',
|
|
591
|
+
'__lookupSetter__',
|
|
592
|
+
'constructor',
|
|
593
|
+
'hasOwnProperty',
|
|
594
|
+
'isPrototypeOf',
|
|
595
|
+
'propertyIsEnumerable',
|
|
596
|
+
'toLocaleString',
|
|
597
|
+
'toString',
|
|
598
|
+
'valueOf',
|
|
599
|
+
].includes(e))
|
|
600
|
+
return false;
|
|
601
|
+
if (e != arr[i + 1] && typeof target[e] === 'function')
|
|
602
|
+
return true;
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
static put({ key, target, property, value, propertyDescriptor }) {
|
|
606
|
+
const index = target.constructor.name;
|
|
607
|
+
ReflectHelper.items[key] = ReflectHelper.items[key] || {};
|
|
608
|
+
ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
|
|
609
|
+
ReflectHelper.items[key][index].object = target;
|
|
610
|
+
if (isNil(property)) {
|
|
611
|
+
ReflectHelper.items[key][index].value = {
|
|
612
|
+
value,
|
|
613
|
+
propertyDescriptor,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
|
|
618
|
+
ReflectHelper.items[key][index][String(property)] = {
|
|
619
|
+
value,
|
|
620
|
+
propertyDescriptor,
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
static remove(key, target, property) {
|
|
625
|
+
if (ReflectHelper.has(key, target, property))
|
|
626
|
+
return delete ReflectHelper.items[key][target][String(property)];
|
|
627
|
+
else if (ReflectHelper.has(key, target))
|
|
628
|
+
return delete ReflectHelper.items[key][target];
|
|
629
|
+
else if (ReflectHelper.has(key))
|
|
630
|
+
return delete ReflectHelper.items[key];
|
|
631
|
+
else
|
|
632
|
+
return false;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
ReflectHelper._items = {};
|
|
636
|
+
|
|
637
|
+
class DebugDecoratorHelper {
|
|
638
|
+
static set(target, options) {
|
|
639
|
+
ReflectHelper.add({
|
|
640
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
641
|
+
target,
|
|
642
|
+
value: options,
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
static get(target) {
|
|
646
|
+
return ReflectHelper.first({
|
|
647
|
+
key: DebugDecoratorHelper.DebugNamingMetadataKey,
|
|
648
|
+
target,
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
|
|
653
|
+
|
|
654
|
+
class ClassNameHelper {
|
|
655
|
+
static get(clazz) {
|
|
656
|
+
if (!clazz)
|
|
657
|
+
return null;
|
|
658
|
+
const prototype = Object.getPrototypeOf(clazz);
|
|
659
|
+
const names = compact([
|
|
660
|
+
get$1(clazz, 'constructor.name'),
|
|
661
|
+
get$1(prototype, 'constructor.name'),
|
|
662
|
+
get$1(prototype, '__proto__.constructor.name'),
|
|
663
|
+
]);
|
|
664
|
+
return names.find((name) => name !== 'class_1');
|
|
466
665
|
}
|
|
467
666
|
}
|
|
468
667
|
|
|
668
|
+
const isDebuggable = (object) => {
|
|
669
|
+
return 'debug' in object;
|
|
670
|
+
};
|
|
671
|
+
class DebugHelper {
|
|
672
|
+
constructor(...namespace) {
|
|
673
|
+
this.namespaces = new Set();
|
|
674
|
+
this.push(...namespace);
|
|
675
|
+
}
|
|
676
|
+
static namespacesFor(target) {
|
|
677
|
+
if (isNil(target))
|
|
678
|
+
return [];
|
|
679
|
+
const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
|
|
680
|
+
const namespaces = get$1(decorator, 'namespaces', []);
|
|
681
|
+
const name = get$1(decorator, 'name', ClassNameHelper.get(target));
|
|
682
|
+
return [...namespaces, name];
|
|
683
|
+
}
|
|
684
|
+
static as(...namespaces) {
|
|
685
|
+
return new DebugHelper(...namespaces);
|
|
686
|
+
}
|
|
687
|
+
static for(target, ...namespaces) {
|
|
688
|
+
const targetNamespaces = this.namespacesFor(target);
|
|
689
|
+
return new DebugHelper(...targetNamespaces, ...namespaces);
|
|
690
|
+
}
|
|
691
|
+
static from(target, ...namespaces) {
|
|
692
|
+
if (this.isDebuggable(target)) {
|
|
693
|
+
const debug = target.debug;
|
|
694
|
+
if (namespaces)
|
|
695
|
+
debug.push(...namespaces);
|
|
696
|
+
return debug;
|
|
697
|
+
}
|
|
698
|
+
return DebugHelper.for(target, ...namespaces);
|
|
699
|
+
}
|
|
700
|
+
static clonedFrom(target, ...namespaces) {
|
|
701
|
+
if (this.isDebuggable(target)) {
|
|
702
|
+
namespaces.push(...target.debug.entries);
|
|
703
|
+
}
|
|
704
|
+
else if (!isNil(target)) {
|
|
705
|
+
namespaces.push(...this.namespacesFor(target));
|
|
706
|
+
}
|
|
707
|
+
return DebugHelper.for(target, ...namespaces);
|
|
708
|
+
}
|
|
709
|
+
static clone(target, ...namespaces) {
|
|
710
|
+
let original;
|
|
711
|
+
if (this.isDebuggable(target)) {
|
|
712
|
+
original = target.debug;
|
|
713
|
+
namespaces.push(...original.entries);
|
|
714
|
+
}
|
|
715
|
+
return {
|
|
716
|
+
original,
|
|
717
|
+
debug: DebugHelper.for(target, ...namespaces),
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
static replace(target, attrs) {
|
|
721
|
+
if (this.isDebuggable(target))
|
|
722
|
+
target.debug = attrs.with;
|
|
723
|
+
}
|
|
724
|
+
static mock(target, ...namespaces) {
|
|
725
|
+
const { original, debug } = DebugHelper.clone(target, ...namespaces);
|
|
726
|
+
DebugHelper.replace(target, { with: debug });
|
|
727
|
+
return { original, debug };
|
|
728
|
+
}
|
|
729
|
+
get entries() {
|
|
730
|
+
return Array.from(get$1(this, 'namespaces', []));
|
|
731
|
+
}
|
|
732
|
+
get namespace() {
|
|
733
|
+
return compact(flatten(this.entries)).join(':');
|
|
734
|
+
}
|
|
735
|
+
log(message, ...args) {
|
|
736
|
+
this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
|
|
737
|
+
DebugHelper.logs$.next({ namespace: this.namespace, message, args });
|
|
738
|
+
return this;
|
|
739
|
+
}
|
|
740
|
+
trace(message, ...args) {
|
|
741
|
+
this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
|
|
742
|
+
DebugHelper.traces$.next({ namespace: this.namespace, message, args });
|
|
743
|
+
return this;
|
|
744
|
+
}
|
|
745
|
+
error(error, ...args) {
|
|
746
|
+
this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
|
|
747
|
+
DebugHelper.errors$.next({ namespace: this.namespace, error, args });
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
build() {
|
|
751
|
+
this.logger = Logger;
|
|
752
|
+
this.tracer = Logger;
|
|
753
|
+
this.err = Logger;
|
|
754
|
+
this.entries.forEach((namespace) => {
|
|
755
|
+
this.logger = this.logger.extend(namespace);
|
|
756
|
+
this.tracer = this.tracer.extend(namespace);
|
|
757
|
+
this.err = this.err.extend(namespace);
|
|
758
|
+
});
|
|
759
|
+
return this;
|
|
760
|
+
}
|
|
761
|
+
with(...namespace) {
|
|
762
|
+
return new DebugHelper(...this.entries, ...namespace);
|
|
763
|
+
}
|
|
764
|
+
push(...namespace) {
|
|
765
|
+
if (namespace) {
|
|
766
|
+
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
|
|
767
|
+
}
|
|
768
|
+
return this.build();
|
|
769
|
+
}
|
|
770
|
+
unshift(...namespace) {
|
|
771
|
+
if (namespace) {
|
|
772
|
+
return this.reset(...namespace, ...this.entries);
|
|
773
|
+
}
|
|
774
|
+
return this;
|
|
775
|
+
}
|
|
776
|
+
reset(...namespace) {
|
|
777
|
+
this.namespaces = new Set(flatten(compact(namespace)));
|
|
778
|
+
return this.build();
|
|
779
|
+
}
|
|
780
|
+
startWith(...namespace) {
|
|
781
|
+
const current = this.namespaces;
|
|
782
|
+
this.namespaces = new Set(flatten([compact(namespace), ...current]));
|
|
783
|
+
return this.build();
|
|
784
|
+
}
|
|
785
|
+
shift() {
|
|
786
|
+
const list = this.entries;
|
|
787
|
+
list.shift();
|
|
788
|
+
return this.reset(...list);
|
|
789
|
+
}
|
|
790
|
+
pop() {
|
|
791
|
+
const list = this.entries;
|
|
792
|
+
list.pop();
|
|
793
|
+
return this.reset(...list);
|
|
794
|
+
}
|
|
795
|
+
clear() {
|
|
796
|
+
return this.reset();
|
|
797
|
+
}
|
|
798
|
+
remove(...namespace) {
|
|
799
|
+
if (namespace) {
|
|
800
|
+
namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
|
|
801
|
+
}
|
|
802
|
+
return this.build();
|
|
803
|
+
}
|
|
804
|
+
puts(...args) {
|
|
805
|
+
return [`[${this.namespace}]`, ...args].join(' ');
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
DebugHelper.logs$ = new Subject();
|
|
809
|
+
DebugHelper.traces$ = new Subject();
|
|
810
|
+
DebugHelper.errors$ = new Subject();
|
|
811
|
+
DebugHelper.isDebuggable = isDebuggable;
|
|
812
|
+
|
|
813
|
+
function Debug(opts) {
|
|
814
|
+
return function (target) {
|
|
815
|
+
DebugDecoratorHelper.set(target.prototype, opts);
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
const ASYNC_IDENTIFIER = 'async';
|
|
820
|
+
function Log(options = {}) {
|
|
821
|
+
return Trace(Object.assign({ level: 'log' }, options));
|
|
822
|
+
}
|
|
823
|
+
function Trace(options = {}) {
|
|
824
|
+
return function (target, propertyKey, propertyDescriptor) {
|
|
825
|
+
const method = propertyDescriptor.value;
|
|
826
|
+
const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
|
|
827
|
+
const args = {
|
|
828
|
+
options,
|
|
829
|
+
method,
|
|
830
|
+
target,
|
|
831
|
+
propertyKey,
|
|
832
|
+
propertyDescriptor,
|
|
833
|
+
};
|
|
834
|
+
propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
|
|
835
|
+
return propertyDescriptor;
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
const traceCall = function ({ target, propertyKey, propertyDescriptor, args }) {
|
|
839
|
+
if (!target.debug)
|
|
840
|
+
target.debug = DebugHelper.for(target, propertyKey);
|
|
841
|
+
return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
|
|
842
|
+
};
|
|
843
|
+
const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
|
|
844
|
+
return function (...args) {
|
|
845
|
+
return new Promise((resolve, reject) => {
|
|
846
|
+
const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
|
|
847
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
848
|
+
debug.with('params').log(args);
|
|
849
|
+
}
|
|
850
|
+
return method
|
|
851
|
+
.apply(this, args)
|
|
852
|
+
.then((result) => {
|
|
853
|
+
if (options.callbackFn) {
|
|
854
|
+
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
855
|
+
}
|
|
856
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
857
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
858
|
+
}
|
|
859
|
+
return resolve(result);
|
|
860
|
+
})
|
|
861
|
+
.catch((error) => {
|
|
862
|
+
debug.error(error, ...args);
|
|
863
|
+
debug.with('stack').error(error.stack).pop();
|
|
864
|
+
return reject(error);
|
|
865
|
+
})
|
|
866
|
+
.finally(() => {
|
|
867
|
+
return debug.trace('finally', { args }).pop();
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
|
|
873
|
+
return function (...args) {
|
|
874
|
+
const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
|
|
875
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
876
|
+
debug.with('params').log(args);
|
|
877
|
+
}
|
|
878
|
+
let result;
|
|
879
|
+
try {
|
|
880
|
+
result = method.apply(this, args);
|
|
881
|
+
if (options.callbackFn)
|
|
882
|
+
options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
|
|
883
|
+
if (get$1(options, 'level', '') === 'log') {
|
|
884
|
+
debug.with('returns').log(result === undefined ? 'void' : result);
|
|
885
|
+
}
|
|
886
|
+
return result;
|
|
887
|
+
}
|
|
888
|
+
catch (error) {
|
|
889
|
+
debug.error(error, ...args).pop();
|
|
890
|
+
throw error;
|
|
891
|
+
}
|
|
892
|
+
finally {
|
|
893
|
+
debug.trace('finally', { args }).pop();
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
};
|
|
897
|
+
|
|
469
898
|
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
470
899
|
|
|
471
900
|
function is(value) {
|
|
@@ -579,7 +1008,7 @@ class User extends BaseModel {
|
|
|
579
1008
|
const instance = super.toInstance(data);
|
|
580
1009
|
if (!isNil(data.firstName))
|
|
581
1010
|
instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
|
|
582
|
-
return
|
|
1011
|
+
return;
|
|
583
1012
|
}
|
|
584
1013
|
toPlain() {
|
|
585
1014
|
const plain = super.toPlain();
|
|
@@ -595,6 +1024,18 @@ __decorate([
|
|
|
595
1024
|
__metadata("design:type", BeautyProfile)
|
|
596
1025
|
], User.prototype, "beautyProfile", void 0);
|
|
597
1026
|
|
|
1027
|
+
class Address extends BaseModel {
|
|
1028
|
+
static get identifiersFields() {
|
|
1029
|
+
return ['id'];
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
class UserAddress extends Address {
|
|
1034
|
+
static get identifiersFields() {
|
|
1035
|
+
return ['id', 'userId'];
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
598
1039
|
class Subscription extends BaseModel {
|
|
599
1040
|
static get identifiersFields() {
|
|
600
1041
|
return ['id'];
|
|
@@ -609,12 +1050,12 @@ __decorate([
|
|
|
609
1050
|
__metadata("design:type", SubscriptionPlan)
|
|
610
1051
|
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
611
1052
|
__decorate([
|
|
612
|
-
Type(() =>
|
|
613
|
-
__metadata("design:type",
|
|
1053
|
+
Type(() => UserAddress),
|
|
1054
|
+
__metadata("design:type", UserAddress)
|
|
614
1055
|
], Subscription.prototype, "shippingAddress", void 0);
|
|
615
1056
|
__decorate([
|
|
616
|
-
Type(() =>
|
|
617
|
-
__metadata("design:type",
|
|
1057
|
+
Type(() => UserAddress),
|
|
1058
|
+
__metadata("design:type", UserAddress)
|
|
618
1059
|
], Subscription.prototype, "billingAddress", void 0);
|
|
619
1060
|
__decorate([
|
|
620
1061
|
Type(() => Coupon),
|
|
@@ -629,12 +1070,6 @@ __decorate([
|
|
|
629
1070
|
__metadata("design:type", Array)
|
|
630
1071
|
], Subscription.prototype, "payment", void 0);
|
|
631
1072
|
|
|
632
|
-
class UserAddress extends Address {
|
|
633
|
-
static get identifiersFields() {
|
|
634
|
-
return ['id', 'userId'];
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
1073
|
class UserPaymentMethod extends BaseModel {
|
|
639
1074
|
static get identifiersFields() {
|
|
640
1075
|
return ['id', 'userId'];
|
|
@@ -667,7 +1102,7 @@ class Authentication {
|
|
|
667
1102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
668
1103
|
const method = this.getServiceByMethod(signInMethod);
|
|
669
1104
|
const userAuth = yield this.authService[method]({ email, password });
|
|
670
|
-
const user = this.userRepository.get(userAuth);
|
|
1105
|
+
const user = this.userRepository.get({ id: userAuth.id });
|
|
671
1106
|
if (!isNil(user))
|
|
672
1107
|
return user;
|
|
673
1108
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
@@ -755,18 +1190,12 @@ class RecoveryPassword {
|
|
|
755
1190
|
}
|
|
756
1191
|
|
|
757
1192
|
class Filter extends BaseModel {
|
|
758
|
-
identifierFields() {
|
|
759
|
-
return ['id'];
|
|
760
|
-
}
|
|
761
1193
|
static get identifiersFields() {
|
|
762
1194
|
return ['id'];
|
|
763
1195
|
}
|
|
764
1196
|
}
|
|
765
1197
|
|
|
766
1198
|
class Category extends BaseModel {
|
|
767
|
-
identifierFields() {
|
|
768
|
-
return ['id'];
|
|
769
|
-
}
|
|
770
1199
|
static get identifiersFields() {
|
|
771
1200
|
return ['id'];
|
|
772
1201
|
}
|
|
@@ -781,9 +1210,6 @@ __decorate([
|
|
|
781
1210
|
], Category.prototype, "filters", void 0);
|
|
782
1211
|
|
|
783
1212
|
class CategoryCollectionChildren extends BaseModel {
|
|
784
|
-
identifierFields() {
|
|
785
|
-
return ['collectionId', 'categoryId'];
|
|
786
|
-
}
|
|
787
1213
|
static get identifiersFields() {
|
|
788
1214
|
return ['collectionId', 'categoryId'];
|
|
789
1215
|
}
|
|
@@ -819,9 +1245,6 @@ var Shops;
|
|
|
819
1245
|
})(Shops || (Shops = {}));
|
|
820
1246
|
|
|
821
1247
|
class FilterOption extends BaseModel {
|
|
822
|
-
identifierFields() {
|
|
823
|
-
return ['id'];
|
|
824
|
-
}
|
|
825
1248
|
static get identifiersFields() {
|
|
826
1249
|
return ['id'];
|
|
827
1250
|
}
|
|
@@ -846,9 +1269,6 @@ class Product extends BaseModel {
|
|
|
846
1269
|
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
847
1270
|
this.rate = evaluation.rating || this.rate;
|
|
848
1271
|
}
|
|
849
|
-
identifierFields() {
|
|
850
|
-
return ['id'];
|
|
851
|
-
}
|
|
852
1272
|
static get identifiersFields() {
|
|
853
1273
|
return ['id'];
|
|
854
1274
|
}
|
|
@@ -864,7 +1284,7 @@ __decorate([
|
|
|
864
1284
|
|
|
865
1285
|
class KitProduct extends BaseModel {
|
|
866
1286
|
static get identifiersFields() {
|
|
867
|
-
return ['productId', '
|
|
1287
|
+
return ['productId', 'kitProductId'];
|
|
868
1288
|
}
|
|
869
1289
|
}
|
|
870
1290
|
__decorate([
|
|
@@ -877,9 +1297,6 @@ __decorate([
|
|
|
877
1297
|
], KitProduct.prototype, "product", void 0);
|
|
878
1298
|
|
|
879
1299
|
class Variant extends BaseModel {
|
|
880
|
-
identifierFields() {
|
|
881
|
-
return ['id'];
|
|
882
|
-
}
|
|
883
1300
|
static get identifiersFields() {
|
|
884
1301
|
return ['id', 'productId'];
|
|
885
1302
|
}
|
|
@@ -930,12 +1347,12 @@ __decorate([
|
|
|
930
1347
|
__metadata("design:type", User)
|
|
931
1348
|
], Checkout.prototype, "user", void 0);
|
|
932
1349
|
__decorate([
|
|
933
|
-
Type(() =>
|
|
934
|
-
__metadata("design:type",
|
|
1350
|
+
Type(() => UserAddress),
|
|
1351
|
+
__metadata("design:type", UserAddress)
|
|
935
1352
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
936
1353
|
__decorate([
|
|
937
|
-
Type(() =>
|
|
938
|
-
__metadata("design:type",
|
|
1354
|
+
Type(() => UserAddress),
|
|
1355
|
+
__metadata("design:type", UserAddress)
|
|
939
1356
|
], Checkout.prototype, "billingAddress", void 0);
|
|
940
1357
|
__decorate([
|
|
941
1358
|
Type(() => ShippingMethod),
|
|
@@ -971,12 +1388,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
971
1388
|
}
|
|
972
1389
|
}
|
|
973
1390
|
__decorate([
|
|
974
|
-
Type(() =>
|
|
975
|
-
__metadata("design:type",
|
|
1391
|
+
Type(() => UserAddress),
|
|
1392
|
+
__metadata("design:type", UserAddress)
|
|
976
1393
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
977
1394
|
__decorate([
|
|
978
|
-
Type(() =>
|
|
979
|
-
__metadata("design:type",
|
|
1395
|
+
Type(() => UserAddress),
|
|
1396
|
+
__metadata("design:type", UserAddress)
|
|
980
1397
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
981
1398
|
__decorate([
|
|
982
1399
|
Type(() => SubscriptionPlan),
|
|
@@ -1337,6 +1754,17 @@ const withFirestore = (MixinBase) => {
|
|
|
1337
1754
|
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1338
1755
|
: bindDate(data[key], key) })), {});
|
|
1339
1756
|
};
|
|
1757
|
+
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1758
|
+
each(value, (v, k) => {
|
|
1759
|
+
if (iteratee(v, k)) {
|
|
1760
|
+
unset(value, k);
|
|
1761
|
+
}
|
|
1762
|
+
else if (isObject(v)) {
|
|
1763
|
+
omitByRecursivelyInPlace(v, iteratee);
|
|
1764
|
+
}
|
|
1765
|
+
});
|
|
1766
|
+
return value;
|
|
1767
|
+
};
|
|
1340
1768
|
return class extends MixinBase {
|
|
1341
1769
|
constructor(...params) {
|
|
1342
1770
|
const options = params[0];
|
|
@@ -1355,7 +1783,10 @@ const withFirestore = (MixinBase) => {
|
|
|
1355
1783
|
}
|
|
1356
1784
|
buildModelInstance() {
|
|
1357
1785
|
return {
|
|
1358
|
-
toFirestore: (data) =>
|
|
1786
|
+
toFirestore: (data) => {
|
|
1787
|
+
const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
|
|
1788
|
+
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1789
|
+
},
|
|
1359
1790
|
fromFirestore: (snap) => {
|
|
1360
1791
|
const data = snap.data();
|
|
1361
1792
|
let bindedData = null;
|
|
@@ -1515,7 +1946,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1515
1946
|
const queries = [];
|
|
1516
1947
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1517
1948
|
if (this.model.isModel(limits.offset))
|
|
1518
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)),
|
|
1949
|
+
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), (_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString()))));
|
|
1519
1950
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1520
1951
|
queries.push(startAt(limits.offset));
|
|
1521
1952
|
}
|
|
@@ -1551,7 +1982,7 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1551
1982
|
save(data) {
|
|
1552
1983
|
var _a, _b;
|
|
1553
1984
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1554
|
-
const id = (_b =
|
|
1985
|
+
const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
|
|
1555
1986
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1556
1987
|
const collection = this.collection(collectionPath);
|
|
1557
1988
|
if (isEmpty(id))
|
|
@@ -2355,11 +2786,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2355
2786
|
}, {});
|
|
2356
2787
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2357
2788
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2358
|
-
|
|
2789
|
+
const isNestedField = !Array.isArray(options) &&
|
|
2359
2790
|
isObject(options) &&
|
|
2360
2791
|
isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
2361
2792
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2362
|
-
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to)
|
|
2793
|
+
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
|
|
2794
|
+
if (isNestedField)
|
|
2363
2795
|
return Object.keys(options).reduce((variables, key) => {
|
|
2364
2796
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2365
2797
|
const columnName = fieldOptions.columnName;
|
|
@@ -2370,7 +2802,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2370
2802
|
return {
|
|
2371
2803
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2372
2804
|
};
|
|
2373
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2805
|
+
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2374
2806
|
options = Object.values(options)[0];
|
|
2375
2807
|
return Array.isArray(options)
|
|
2376
2808
|
? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
|
|
@@ -2402,28 +2834,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2402
2834
|
if (field === 'affected_rows')
|
|
2403
2835
|
return field;
|
|
2404
2836
|
const fieldName = Object.keys(field).shift();
|
|
2405
|
-
const fieldValue = field[fieldName];
|
|
2837
|
+
const fieldValue = is(field[fieldName]);
|
|
2406
2838
|
if (Array.isArray(fieldValue))
|
|
2407
2839
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2408
2840
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2409
|
-
return
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2414
|
-
}
|
|
2415
|
-
: {
|
|
2416
|
-
operation: fieldValue.columnName || fieldName,
|
|
2417
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2418
|
-
variables: {
|
|
2419
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2420
|
-
name: 'where',
|
|
2421
|
-
type: fieldValue.filters.filterType,
|
|
2422
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2423
|
-
required: true,
|
|
2424
|
-
},
|
|
2425
|
-
},
|
|
2426
|
-
};
|
|
2841
|
+
return;
|
|
2842
|
+
const isNestedField = !!fieldValue.fields;
|
|
2843
|
+
if (isNestedField)
|
|
2844
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
2427
2845
|
return fieldValue.columnName;
|
|
2428
2846
|
}).filter((field) => !!field);
|
|
2429
2847
|
};
|
|
@@ -2486,6 +2904,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2486
2904
|
return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
|
|
2487
2905
|
}, {});
|
|
2488
2906
|
};
|
|
2907
|
+
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2908
|
+
const hasCustomFilters = !!fieldValue.filters;
|
|
2909
|
+
if (hasCustomFilters)
|
|
2910
|
+
return {
|
|
2911
|
+
operation: fieldValue.columnName || fieldName,
|
|
2912
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2913
|
+
variables: {
|
|
2914
|
+
[`${fieldValue.columnName}_where`]: {
|
|
2915
|
+
name: 'where',
|
|
2916
|
+
type: fieldValue.filters.filterType,
|
|
2917
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2918
|
+
required: true,
|
|
2919
|
+
},
|
|
2920
|
+
},
|
|
2921
|
+
};
|
|
2922
|
+
return {
|
|
2923
|
+
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2924
|
+
};
|
|
2925
|
+
};
|
|
2489
2926
|
|
|
2490
2927
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2491
2928
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2497,6 +2934,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2497
2934
|
}
|
|
2498
2935
|
create(data) {
|
|
2499
2936
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2937
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
2500
2938
|
const newData = yield this.save(this.model.toInstance(data));
|
|
2501
2939
|
return this.model.toInstance(newData);
|
|
2502
2940
|
});
|
|
@@ -2513,8 +2951,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2513
2951
|
{
|
|
2514
2952
|
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
|
|
2515
2953
|
var _a;
|
|
2516
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
2517
|
-
foreignKeyField;
|
|
2954
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
|
|
2518
2955
|
}),
|
|
2519
2956
|
},
|
|
2520
2957
|
]);
|
|
@@ -2539,9 +2976,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2539
2976
|
}
|
|
2540
2977
|
delete(identifiers) {
|
|
2541
2978
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2979
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
2542
2980
|
const instance = this.model.toInstance(identifiers);
|
|
2543
2981
|
yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2544
|
-
|
|
2982
|
+
const identifierBinded = identifier;
|
|
2983
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2545
2984
|
return ids;
|
|
2546
2985
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2547
2986
|
const value = columnOption.to(identifiers[identifier], instance);
|
|
@@ -2566,6 +3005,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2566
3005
|
this.authOptions = options.authOptions;
|
|
2567
3006
|
this.model = options.model;
|
|
2568
3007
|
this.fields = options.fields || this.model.identifiersFields;
|
|
3008
|
+
this.logger = DebugHelper.from(this);
|
|
2569
3009
|
}
|
|
2570
3010
|
get headers() {
|
|
2571
3011
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -2589,7 +3029,11 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2589
3029
|
query(operation, fields, variables) {
|
|
2590
3030
|
var _a, _b, _c, _d;
|
|
2591
3031
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2592
|
-
const builded = this.buildHasuraQueryFields({
|
|
3032
|
+
const builded = this.buildHasuraQueryFields({
|
|
3033
|
+
operation,
|
|
3034
|
+
fields: fields,
|
|
3035
|
+
variables,
|
|
3036
|
+
});
|
|
2593
3037
|
const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
|
|
2594
3038
|
const resultQuery = query$1(interpected);
|
|
2595
3039
|
const result = yield this.fetch(resultQuery);
|
|
@@ -2598,6 +3042,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2598
3042
|
}
|
|
2599
3043
|
fetch(params) {
|
|
2600
3044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3045
|
+
this.logger.with('params').log(params);
|
|
2601
3046
|
const headers = this.headers;
|
|
2602
3047
|
const { data: result } = yield axios({
|
|
2603
3048
|
url: `${this.endpoint}`,
|
|
@@ -2607,6 +3052,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2607
3052
|
});
|
|
2608
3053
|
if (!isNil(result.errors))
|
|
2609
3054
|
throw new Error(JSON.stringify(result.errors));
|
|
3055
|
+
this.logger.with('returns').log(result);
|
|
2610
3056
|
return result.data;
|
|
2611
3057
|
});
|
|
2612
3058
|
}
|
|
@@ -2633,8 +3079,8 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2633
3079
|
return value;
|
|
2634
3080
|
return date;
|
|
2635
3081
|
}
|
|
2636
|
-
convertDataFromHasura(data) {
|
|
2637
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3082
|
+
convertDataFromHasura(data, fields) {
|
|
3083
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
2638
3084
|
return this.model.toInstance(plain);
|
|
2639
3085
|
}
|
|
2640
3086
|
convertDataToHasura(instance, update = false) {
|
|
@@ -2676,6 +3122,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2676
3122
|
}
|
|
2677
3123
|
update(data) {
|
|
2678
3124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3125
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
2679
3126
|
const plainData = this.paramsToPlain(data);
|
|
2680
3127
|
yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2681
3128
|
_set: {
|
|
@@ -2700,10 +3147,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2700
3147
|
const instance = this.model.toInstance(data);
|
|
2701
3148
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2702
3149
|
var _a;
|
|
2703
|
-
|
|
3150
|
+
const identifierBinded = identifier;
|
|
3151
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2704
3152
|
return ids;
|
|
2705
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
2706
|
-
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[
|
|
3153
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
|
|
3154
|
+
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];
|
|
2707
3155
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2708
3156
|
}, {});
|
|
2709
3157
|
}
|
|
@@ -2719,10 +3167,12 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2719
3167
|
}
|
|
2720
3168
|
get(identifiers) {
|
|
2721
3169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3170
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
2722
3171
|
const instance = this.model.toInstance(identifiers);
|
|
2723
3172
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2724
3173
|
var _a;
|
|
2725
|
-
|
|
3174
|
+
const identifierBinded = identifier;
|
|
3175
|
+
if (isNil(instance[identifierBinded]))
|
|
2726
3176
|
return ids;
|
|
2727
3177
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2728
3178
|
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
|
|
@@ -2744,12 +3194,26 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2744
3194
|
|
|
2745
3195
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2746
3196
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
3197
|
+
constructor() {
|
|
3198
|
+
super(...arguments);
|
|
3199
|
+
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => (Object.assign(Object.assign({}, acc), { [AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3200
|
+
.columnName]: orderBy[current] })), {});
|
|
3201
|
+
}
|
|
2747
3202
|
find(params) {
|
|
2748
3203
|
var _a;
|
|
2749
3204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3205
|
+
this.logger = DebugHelper.from(this, 'find');
|
|
2750
3206
|
const { filters, limits, orderBy, options } = params || {};
|
|
2751
3207
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2752
|
-
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3208
|
+
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3209
|
+
? {}
|
|
3210
|
+
: {
|
|
3211
|
+
order_by: {
|
|
3212
|
+
type: `${this.tableName}_order_by!`,
|
|
3213
|
+
list: true,
|
|
3214
|
+
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3215
|
+
},
|
|
3216
|
+
})), (isNil(filters)
|
|
2753
3217
|
? {}
|
|
2754
3218
|
: {
|
|
2755
3219
|
where: {
|
|
@@ -4008,5 +4472,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4008
4472
|
* Generated bundle index. Do not edit.
|
|
4009
4473
|
*/
|
|
4010
4474
|
|
|
4011
|
-
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, 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, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
4475
|
+
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, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, get, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
4012
4476
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|