@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 } 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, [field]: data[field] }), {});
|
|
18
21
|
}
|
|
19
22
|
get identifiersFields() {
|
|
20
23
|
return this.constructor.identifiersFields;
|
|
@@ -460,11 +463,437 @@ __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
|
+
});
|
|
466
650
|
}
|
|
467
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');
|
|
665
|
+
}
|
|
666
|
+
}
|
|
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({ 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
|
+
};
|
|
468
897
|
|
|
469
898
|
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
470
899
|
|
|
@@ -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'];
|
|
@@ -666,7 +1101,7 @@ class Authentication {
|
|
|
666
1101
|
async signIn({ email, password }, signInMethod) {
|
|
667
1102
|
const method = this.getServiceByMethod(signInMethod);
|
|
668
1103
|
const userAuth = await this.authService[method]({ email, password });
|
|
669
|
-
const user = this.userRepository.get(userAuth);
|
|
1104
|
+
const user = this.userRepository.get({ id: userAuth.id });
|
|
670
1105
|
if (!isNil(user))
|
|
671
1106
|
return user;
|
|
672
1107
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
@@ -760,18 +1195,12 @@ class RecoveryPassword {
|
|
|
760
1195
|
}
|
|
761
1196
|
|
|
762
1197
|
class Filter extends BaseModel {
|
|
763
|
-
identifierFields() {
|
|
764
|
-
return ['id'];
|
|
765
|
-
}
|
|
766
1198
|
static get identifiersFields() {
|
|
767
1199
|
return ['id'];
|
|
768
1200
|
}
|
|
769
1201
|
}
|
|
770
1202
|
|
|
771
1203
|
class Category extends BaseModel {
|
|
772
|
-
identifierFields() {
|
|
773
|
-
return ['id'];
|
|
774
|
-
}
|
|
775
1204
|
static get identifiersFields() {
|
|
776
1205
|
return ['id'];
|
|
777
1206
|
}
|
|
@@ -786,9 +1215,6 @@ __decorate([
|
|
|
786
1215
|
], Category.prototype, "filters", void 0);
|
|
787
1216
|
|
|
788
1217
|
class CategoryCollectionChildren extends BaseModel {
|
|
789
|
-
identifierFields() {
|
|
790
|
-
return ['collectionId', 'categoryId'];
|
|
791
|
-
}
|
|
792
1218
|
static get identifiersFields() {
|
|
793
1219
|
return ['collectionId', 'categoryId'];
|
|
794
1220
|
}
|
|
@@ -824,9 +1250,6 @@ var Shops;
|
|
|
824
1250
|
})(Shops || (Shops = {}));
|
|
825
1251
|
|
|
826
1252
|
class FilterOption extends BaseModel {
|
|
827
|
-
identifierFields() {
|
|
828
|
-
return ['id'];
|
|
829
|
-
}
|
|
830
1253
|
static get identifiersFields() {
|
|
831
1254
|
return ['id'];
|
|
832
1255
|
}
|
|
@@ -851,9 +1274,6 @@ class Product extends BaseModel {
|
|
|
851
1274
|
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
852
1275
|
this.rate = evaluation.rating || this.rate;
|
|
853
1276
|
}
|
|
854
|
-
identifierFields() {
|
|
855
|
-
return ['id'];
|
|
856
|
-
}
|
|
857
1277
|
static get identifiersFields() {
|
|
858
1278
|
return ['id'];
|
|
859
1279
|
}
|
|
@@ -869,7 +1289,7 @@ __decorate([
|
|
|
869
1289
|
|
|
870
1290
|
class KitProduct extends BaseModel {
|
|
871
1291
|
static get identifiersFields() {
|
|
872
|
-
return ['productId', '
|
|
1292
|
+
return ['productId', 'kitProductId'];
|
|
873
1293
|
}
|
|
874
1294
|
}
|
|
875
1295
|
__decorate([
|
|
@@ -882,9 +1302,6 @@ __decorate([
|
|
|
882
1302
|
], KitProduct.prototype, "product", void 0);
|
|
883
1303
|
|
|
884
1304
|
class Variant extends BaseModel {
|
|
885
|
-
identifierFields() {
|
|
886
|
-
return ['id'];
|
|
887
|
-
}
|
|
888
1305
|
static get identifiersFields() {
|
|
889
1306
|
return ['id', 'productId'];
|
|
890
1307
|
}
|
|
@@ -935,12 +1352,12 @@ __decorate([
|
|
|
935
1352
|
__metadata("design:type", User)
|
|
936
1353
|
], Checkout.prototype, "user", void 0);
|
|
937
1354
|
__decorate([
|
|
938
|
-
Type(() =>
|
|
939
|
-
__metadata("design:type",
|
|
1355
|
+
Type(() => UserAddress),
|
|
1356
|
+
__metadata("design:type", UserAddress)
|
|
940
1357
|
], Checkout.prototype, "shippingAddress", void 0);
|
|
941
1358
|
__decorate([
|
|
942
|
-
Type(() =>
|
|
943
|
-
__metadata("design:type",
|
|
1359
|
+
Type(() => UserAddress),
|
|
1360
|
+
__metadata("design:type", UserAddress)
|
|
944
1361
|
], Checkout.prototype, "billingAddress", void 0);
|
|
945
1362
|
__decorate([
|
|
946
1363
|
Type(() => ShippingMethod),
|
|
@@ -976,12 +1393,12 @@ class CheckoutSubscription extends BaseModel {
|
|
|
976
1393
|
}
|
|
977
1394
|
}
|
|
978
1395
|
__decorate([
|
|
979
|
-
Type(() =>
|
|
980
|
-
__metadata("design:type",
|
|
1396
|
+
Type(() => UserAddress),
|
|
1397
|
+
__metadata("design:type", UserAddress)
|
|
981
1398
|
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
982
1399
|
__decorate([
|
|
983
|
-
Type(() =>
|
|
984
|
-
__metadata("design:type",
|
|
1400
|
+
Type(() => UserAddress),
|
|
1401
|
+
__metadata("design:type", UserAddress)
|
|
985
1402
|
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
986
1403
|
__decorate([
|
|
987
1404
|
Type(() => SubscriptionPlan),
|
|
@@ -1325,6 +1742,17 @@ const withFirestore = (MixinBase) => {
|
|
|
1325
1742
|
: bindDate(data[key], key),
|
|
1326
1743
|
}), {});
|
|
1327
1744
|
};
|
|
1745
|
+
const omitByRecursivelyInPlace = (value, iteratee) => {
|
|
1746
|
+
each(value, (v, k) => {
|
|
1747
|
+
if (iteratee(v, k)) {
|
|
1748
|
+
unset(value, k);
|
|
1749
|
+
}
|
|
1750
|
+
else if (isObject(v)) {
|
|
1751
|
+
omitByRecursivelyInPlace(v, iteratee);
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
return value;
|
|
1755
|
+
};
|
|
1328
1756
|
return class extends MixinBase {
|
|
1329
1757
|
constructor(...params) {
|
|
1330
1758
|
const options = params[0];
|
|
@@ -1343,7 +1771,10 @@ const withFirestore = (MixinBase) => {
|
|
|
1343
1771
|
}
|
|
1344
1772
|
buildModelInstance() {
|
|
1345
1773
|
return {
|
|
1346
|
-
toFirestore: (data) =>
|
|
1774
|
+
toFirestore: (data) => {
|
|
1775
|
+
const plain = data?.toPlain ? data.toPlain() : data;
|
|
1776
|
+
return omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
1777
|
+
},
|
|
1347
1778
|
fromFirestore: (snap) => {
|
|
1348
1779
|
const data = snap.data();
|
|
1349
1780
|
let bindedData = null;
|
|
@@ -1498,7 +1929,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1498
1929
|
const queries = [];
|
|
1499
1930
|
if (limits?.offset) {
|
|
1500
1931
|
if (this.model.isModel(limits.offset))
|
|
1501
|
-
queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier
|
|
1932
|
+
queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), Object.values(limits.offset.identifier).shift()?.toString()))));
|
|
1502
1933
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1503
1934
|
queries.push(startAt(limits.offset));
|
|
1504
1935
|
}
|
|
@@ -1528,7 +1959,7 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1528
1959
|
return docBuilded;
|
|
1529
1960
|
}
|
|
1530
1961
|
async save(data) {
|
|
1531
|
-
const id = data.identifier
|
|
1962
|
+
const id = Object.values(data.identifier)?.shift()?.toString();
|
|
1532
1963
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1533
1964
|
const collection = this.collection(collectionPath);
|
|
1534
1965
|
if (isEmpty(id))
|
|
@@ -2293,11 +2724,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
|
|
|
2293
2724
|
}, {});
|
|
2294
2725
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
2295
2726
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
2296
|
-
|
|
2727
|
+
const isNestedField = !Array.isArray(options) &&
|
|
2297
2728
|
isObject(options) &&
|
|
2298
2729
|
isNil(options?.operator) &&
|
|
2299
2730
|
isNil(options?.value) &&
|
|
2300
|
-
isNil(fieldSentenceOptions?.to)
|
|
2731
|
+
isNil(fieldSentenceOptions?.to);
|
|
2732
|
+
if (isNestedField)
|
|
2301
2733
|
return Object.keys(options).reduce((variables, key) => {
|
|
2302
2734
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fieldSentenceOptions?.fields || fields);
|
|
2303
2735
|
const columnName = fieldOptions.columnName;
|
|
@@ -2311,7 +2743,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2311
2743
|
return {
|
|
2312
2744
|
[fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
|
|
2313
2745
|
};
|
|
2314
|
-
if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2746
|
+
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
2315
2747
|
options = Object.values(options)[0];
|
|
2316
2748
|
return Array.isArray(options)
|
|
2317
2749
|
? options.reduce((whereSentence, option) => ({
|
|
@@ -2347,28 +2779,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2347
2779
|
if (field === 'affected_rows')
|
|
2348
2780
|
return field;
|
|
2349
2781
|
const fieldName = Object.keys(field).shift();
|
|
2350
|
-
const fieldValue = field[fieldName];
|
|
2782
|
+
const fieldValue = is(field[fieldName]);
|
|
2351
2783
|
if (Array.isArray(fieldValue))
|
|
2352
2784
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
2353
2785
|
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2354
|
-
return
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2359
|
-
}
|
|
2360
|
-
: {
|
|
2361
|
-
operation: fieldValue.columnName || fieldName,
|
|
2362
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2363
|
-
variables: {
|
|
2364
|
-
[`${fieldValue.columnName}_where`]: {
|
|
2365
|
-
name: 'where',
|
|
2366
|
-
type: fieldValue.filters.filterType,
|
|
2367
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2368
|
-
required: true,
|
|
2369
|
-
},
|
|
2370
|
-
},
|
|
2371
|
-
};
|
|
2786
|
+
return;
|
|
2787
|
+
const isNestedField = !!fieldValue.fields;
|
|
2788
|
+
if (isNestedField)
|
|
2789
|
+
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
2372
2790
|
return fieldValue.columnName;
|
|
2373
2791
|
})
|
|
2374
2792
|
.filter((field) => !!field);
|
|
@@ -2451,6 +2869,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
2451
2869
|
return { ...result, [columnName]: data[attributeName] };
|
|
2452
2870
|
}, {});
|
|
2453
2871
|
};
|
|
2872
|
+
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
2873
|
+
const hasCustomFilters = !!fieldValue.filters;
|
|
2874
|
+
if (hasCustomFilters)
|
|
2875
|
+
return {
|
|
2876
|
+
operation: fieldValue.columnName || fieldName,
|
|
2877
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2878
|
+
variables: {
|
|
2879
|
+
[`${fieldValue.columnName}_where`]: {
|
|
2880
|
+
name: 'where',
|
|
2881
|
+
type: fieldValue.filters.filterType,
|
|
2882
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
|
|
2883
|
+
required: true,
|
|
2884
|
+
},
|
|
2885
|
+
},
|
|
2886
|
+
};
|
|
2887
|
+
return {
|
|
2888
|
+
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2889
|
+
};
|
|
2890
|
+
};
|
|
2454
2891
|
|
|
2455
2892
|
const withCreateHasuraGraphQL = (MixinBase) => {
|
|
2456
2893
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
@@ -2461,6 +2898,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2461
2898
|
this.insertGraphQLObjectType = options?.insertGraphQLObjectType || `${this.tableName}_insert_input`;
|
|
2462
2899
|
}
|
|
2463
2900
|
async create(data) {
|
|
2901
|
+
this.logger = DebugHelper.from(this, 'create');
|
|
2464
2902
|
const newData = await this.save(this.model.toInstance(data));
|
|
2465
2903
|
return this.model.toInstance(newData);
|
|
2466
2904
|
}
|
|
@@ -2473,8 +2911,8 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
2473
2911
|
columnOptions.foreignKeyColumn && [
|
|
2474
2912
|
...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)?.columnName),
|
|
2475
2913
|
{
|
|
2476
|
-
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)
|
|
2477
|
-
foreignKeyField),
|
|
2914
|
+
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)
|
|
2915
|
+
?.columnName || foreignKeyField),
|
|
2478
2916
|
},
|
|
2479
2917
|
]);
|
|
2480
2918
|
})
|
|
@@ -2496,9 +2934,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
|
|
|
2496
2934
|
this.deleteGraphQLOperation = options?.deleteGraphQLOperation || `delete_${this.tableName}_by_pk`;
|
|
2497
2935
|
}
|
|
2498
2936
|
async delete(identifiers) {
|
|
2937
|
+
this.logger = DebugHelper.from(this, 'delete');
|
|
2499
2938
|
const instance = this.model.toInstance(identifiers);
|
|
2500
2939
|
await this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2501
|
-
|
|
2940
|
+
const identifierBinded = identifier;
|
|
2941
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2502
2942
|
return ids;
|
|
2503
2943
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2504
2944
|
const value = columnOption.to(identifiers[identifier], instance);
|
|
@@ -2525,6 +2965,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2525
2965
|
this.authOptions = options.authOptions;
|
|
2526
2966
|
this.model = options.model;
|
|
2527
2967
|
this.fields = options.fields || this.model.identifiersFields;
|
|
2968
|
+
this.logger = DebugHelper.from(this);
|
|
2528
2969
|
}
|
|
2529
2970
|
get headers() {
|
|
2530
2971
|
return {
|
|
@@ -2548,13 +2989,18 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2548
2989
|
return this.fetch(resultQuery);
|
|
2549
2990
|
}
|
|
2550
2991
|
async query(operation, fields, variables) {
|
|
2551
|
-
const builded = this.buildHasuraQueryFields({
|
|
2992
|
+
const builded = this.buildHasuraQueryFields({
|
|
2993
|
+
operation,
|
|
2994
|
+
fields: fields,
|
|
2995
|
+
variables,
|
|
2996
|
+
});
|
|
2552
2997
|
const interpected = (await this.interceptors?.request?.(builded)) || builded;
|
|
2553
2998
|
const resultQuery = query$1(interpected);
|
|
2554
2999
|
const result = await this.fetch(resultQuery);
|
|
2555
3000
|
return (await this.interceptors?.response?.(result, interpected)) || result;
|
|
2556
3001
|
}
|
|
2557
3002
|
async fetch(params) {
|
|
3003
|
+
this.logger.with('params').log(params);
|
|
2558
3004
|
const headers = this.headers;
|
|
2559
3005
|
const { data: result } = await axios({
|
|
2560
3006
|
url: `${this.endpoint}`,
|
|
@@ -2564,6 +3010,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2564
3010
|
});
|
|
2565
3011
|
if (!isNil(result.errors))
|
|
2566
3012
|
throw new Error(JSON.stringify(result.errors));
|
|
3013
|
+
this.logger.with('returns').log(result);
|
|
2567
3014
|
return result.data;
|
|
2568
3015
|
}
|
|
2569
3016
|
getAttributeGraphQLTypeOf(value) {
|
|
@@ -2589,8 +3036,8 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2589
3036
|
return value;
|
|
2590
3037
|
return date;
|
|
2591
3038
|
}
|
|
2592
|
-
convertDataFromHasura(data) {
|
|
2593
|
-
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3039
|
+
convertDataFromHasura(data, fields) {
|
|
3040
|
+
const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
|
|
2594
3041
|
return this.model.toInstance(plain);
|
|
2595
3042
|
}
|
|
2596
3043
|
convertDataToHasura(instance, update = false) {
|
|
@@ -2631,6 +3078,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2631
3078
|
this.updateGraphQLPKType = options?.updateGraphQLPKType || `${this.tableName}_pk_columns_input`;
|
|
2632
3079
|
}
|
|
2633
3080
|
async update(data) {
|
|
3081
|
+
this.logger = DebugHelper.from(this, 'update');
|
|
2634
3082
|
const plainData = this.paramsToPlain(data);
|
|
2635
3083
|
await this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
|
|
2636
3084
|
_set: {
|
|
@@ -2656,10 +3104,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2656
3104
|
getUpdateModelKeys(data) {
|
|
2657
3105
|
const instance = this.model.toInstance(data);
|
|
2658
3106
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2659
|
-
|
|
3107
|
+
const identifierBinded = identifier;
|
|
3108
|
+
if (isNil(instance.identifier[identifierBinded]))
|
|
2660
3109
|
return ids;
|
|
2661
|
-
const columnOption = AttributeOptionHelper.FindByAttribute(
|
|
2662
|
-
const value = columnOption?.to?.(data[
|
|
3110
|
+
const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
|
|
3111
|
+
const value = columnOption?.to?.(data[identifierBinded], instance) || data[columnOption.attributeName];
|
|
2663
3112
|
return {
|
|
2664
3113
|
...ids,
|
|
2665
3114
|
[columnOption.columnName]: value,
|
|
@@ -2677,9 +3126,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2677
3126
|
this.getGraphQLOperation = options?.getGraphQLOperation || `${this.tableName}_by_pk`;
|
|
2678
3127
|
}
|
|
2679
3128
|
async get(identifiers) {
|
|
3129
|
+
this.logger = DebugHelper.from(this, 'get');
|
|
2680
3130
|
const instance = this.model.toInstance(identifiers);
|
|
2681
3131
|
const result = await this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2682
|
-
|
|
3132
|
+
const identifierBinded = identifier;
|
|
3133
|
+
if (isNil(instance[identifierBinded]))
|
|
2683
3134
|
return ids;
|
|
2684
3135
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2685
3136
|
const value = columnOption?.to?.(identifiers[identifier], instance) ||
|
|
@@ -2703,11 +3154,28 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2703
3154
|
|
|
2704
3155
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2705
3156
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
3157
|
+
constructor() {
|
|
3158
|
+
super(...arguments);
|
|
3159
|
+
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => ({
|
|
3160
|
+
...acc,
|
|
3161
|
+
[AttributeOptionHelper.FindByAttribute(current, fields)
|
|
3162
|
+
.columnName]: orderBy[current],
|
|
3163
|
+
}), {});
|
|
3164
|
+
}
|
|
2706
3165
|
async find(params) {
|
|
3166
|
+
this.logger = DebugHelper.from(this, 'find');
|
|
2707
3167
|
const { filters, limits, orderBy, options } = params || {};
|
|
2708
3168
|
const enableCount = options?.enableCount ?? true;
|
|
2709
3169
|
const variablesCount = {
|
|
2710
|
-
...(isNil(orderBy)
|
|
3170
|
+
...(isNil(orderBy)
|
|
3171
|
+
? {}
|
|
3172
|
+
: {
|
|
3173
|
+
order_by: {
|
|
3174
|
+
type: `${this.tableName}_order_by!`,
|
|
3175
|
+
list: true,
|
|
3176
|
+
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3177
|
+
},
|
|
3178
|
+
}),
|
|
2711
3179
|
...(isNil(filters)
|
|
2712
3180
|
? {}
|
|
2713
3181
|
: {
|
|
@@ -3925,5 +4393,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3925
4393
|
* Generated bundle index. Do not edit.
|
|
3926
4394
|
*/
|
|
3927
4395
|
|
|
3928
|
-
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 };
|
|
4396
|
+
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 };
|
|
3929
4397
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|