@infrab4a/connect 3.3.3-beta.0 → 3.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +410 -265
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/filter-option.d.ts +10 -0
- package/domain/catalog/models/filter.d.ts +12 -0
- package/domain/catalog/models/index.d.ts +2 -0
- package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
- package/domain/catalog/repositories/filter.repository.d.ts +4 -0
- package/domain/catalog/repositories/index.d.ts +2 -0
- package/domain/generic/repository/find.repository.d.ts +0 -3
- package/domain/shopping/models/index.d.ts +4 -5
- package/domain/shopping/repositories/index.d.ts +2 -4
- package/esm2015/domain/catalog/models/filter-option.js +10 -0
- package/esm2015/domain/catalog/models/filter.js +10 -0
- package/esm2015/domain/catalog/models/index.js +3 -1
- package/esm2015/domain/catalog/repositories/filter-option.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/filter.repository.js +2 -0
- package/esm2015/domain/catalog/repositories/index.js +3 -1
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/shopping/models/index.js +5 -6
- package/esm2015/domain/shopping/repositories/index.js +3 -5
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +3 -5
- package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +4 -6
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +12 -17
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +5 -5
- package/esm2015/infra/hasura-graphql/models/filter-hasura-graphql.js +4 -0
- package/esm2015/infra/hasura-graphql/models/filter-option-hasura-graphql.js +4 -0
- package/esm2015/infra/hasura-graphql/models/index.js +3 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +9 -9
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +104 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +41 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +3 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +4 -7
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -2
- package/esm2015/utils/index.js +6 -6
- package/fesm2015/infrab4a-connect.js +238 -117
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +9 -4
- package/infra/hasura-graphql/models/filter-hasura-graphql.d.ts +3 -0
- package/infra/hasura-graphql/models/filter-option-hasura-graphql.d.ts +3 -0
- package/infra/hasura-graphql/models/index.d.ts +2 -0
- package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
- package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +15 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +2 -0
- package/package.json +2 -2
- package/utils/index.d.ts +5 -5
- package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
- package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
- package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
- package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
- package/esm2015/domain/shopping/models/campaign-dashboard.js +0 -7
- package/esm2015/domain/shopping/models/campaign-hashtag.js +0 -7
- package/esm2015/domain/shopping/repositories/campaign-dashboard.repository.js +0 -2
- package/esm2015/domain/shopping/repositories/campaign-hashtag.repository.js +0 -2
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.js +0 -12
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -9
- package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -9
|
@@ -4,11 +4,12 @@ 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
6
|
import { isString, isNil, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
|
|
7
|
-
export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
7
|
+
export { chunk, difference, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
|
|
8
8
|
import { CustomError } from 'ts-custom-error';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import firebase from 'firebase';
|
|
11
11
|
import { mutation, query } from 'gql-query-builder';
|
|
12
|
+
import fetch from 'node-fetch';
|
|
12
13
|
|
|
13
14
|
class BaseModel {
|
|
14
15
|
get identifier() {
|
|
@@ -465,14 +466,14 @@ class Address extends BaseModel {
|
|
|
465
466
|
}
|
|
466
467
|
}
|
|
467
468
|
|
|
469
|
+
const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
470
|
+
|
|
468
471
|
class Base {
|
|
469
472
|
constructor(...args) {
|
|
470
473
|
Object.assign(this, ...args);
|
|
471
474
|
}
|
|
472
475
|
}
|
|
473
476
|
|
|
474
|
-
const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
|
|
475
|
-
|
|
476
477
|
const parseDateTime = (value) => {
|
|
477
478
|
if (!isString(value))
|
|
478
479
|
return value;
|
|
@@ -774,6 +775,24 @@ var Shops;
|
|
|
774
775
|
Shops["ALL"] = "ALL";
|
|
775
776
|
})(Shops || (Shops = {}));
|
|
776
777
|
|
|
778
|
+
class Filter extends BaseModel {
|
|
779
|
+
identifierFields() {
|
|
780
|
+
return ['id'];
|
|
781
|
+
}
|
|
782
|
+
static get identifiersFields() {
|
|
783
|
+
return ['id'];
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
class FilterOption extends BaseModel {
|
|
788
|
+
identifierFields() {
|
|
789
|
+
return ['id'];
|
|
790
|
+
}
|
|
791
|
+
static get identifiersFields() {
|
|
792
|
+
return ['id'];
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
777
796
|
class Product extends BaseModel {
|
|
778
797
|
identifierFields() {
|
|
779
798
|
return ['id'];
|
|
@@ -810,27 +829,17 @@ class Variant extends BaseModel {
|
|
|
810
829
|
}
|
|
811
830
|
}
|
|
812
831
|
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
]
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
static get identifiersFields() {
|
|
825
|
-
return ['id'];
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
class CampaignHashtag extends BaseModel {
|
|
830
|
-
static get identifiersFields() {
|
|
831
|
-
return ['id'];
|
|
832
|
-
}
|
|
833
|
-
}
|
|
832
|
+
var OrderStatus;
|
|
833
|
+
(function (OrderStatus) {
|
|
834
|
+
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
835
|
+
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
836
|
+
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
837
|
+
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
838
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
839
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
840
|
+
OrderStatus["CANCELADO"] = "Cancelado";
|
|
841
|
+
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
842
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
834
843
|
|
|
835
844
|
class LineItem extends Product {
|
|
836
845
|
}
|
|
@@ -871,18 +880,6 @@ __decorate([
|
|
|
871
880
|
__metadata("design:type", Coupon)
|
|
872
881
|
], Checkout.prototype, "coupon", void 0);
|
|
873
882
|
|
|
874
|
-
var OrderStatus;
|
|
875
|
-
(function (OrderStatus) {
|
|
876
|
-
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
877
|
-
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
878
|
-
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
879
|
-
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
880
|
-
OrderStatus["ENVIADO"] = "Enviado";
|
|
881
|
-
OrderStatus["ENTREGUE"] = "Entregue";
|
|
882
|
-
OrderStatus["CANCELADO"] = "Cancelado";
|
|
883
|
-
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
884
|
-
})(OrderStatus || (OrderStatus = {}));
|
|
885
|
-
|
|
886
883
|
class Order extends Checkout {
|
|
887
884
|
}
|
|
888
885
|
__decorate([
|
|
@@ -912,6 +909,16 @@ __decorate([
|
|
|
912
909
|
__metadata("design:type", Coupon)
|
|
913
910
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
914
911
|
|
|
912
|
+
class Buy2Win extends BaseModel {
|
|
913
|
+
static get identifiersFields() {
|
|
914
|
+
return ['id'];
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
__decorate([
|
|
918
|
+
Type(() => Category),
|
|
919
|
+
__metadata("design:type", Array)
|
|
920
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
921
|
+
|
|
915
922
|
var FilterType;
|
|
916
923
|
(function (FilterType) {
|
|
917
924
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -1320,11 +1327,9 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1320
1327
|
return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
|
|
1321
1328
|
};
|
|
1322
1329
|
}
|
|
1323
|
-
find({ filters, limits, orderBy,
|
|
1324
|
-
var _a;
|
|
1330
|
+
find({ filters, limits, orderBy, } = {}) {
|
|
1325
1331
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1326
1332
|
const orderByKeys = Object.keys(orderBy || {});
|
|
1327
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
1328
1333
|
let query = this.collection(this.buildCollectionPathForFind(filters || {}));
|
|
1329
1334
|
query = this.makeFirestoreWhere(query, filters || {});
|
|
1330
1335
|
if (orderByKeys.length) {
|
|
@@ -1338,7 +1343,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1338
1343
|
const data = docs.docs.map((doc) => doc.data());
|
|
1339
1344
|
return {
|
|
1340
1345
|
data,
|
|
1341
|
-
count:
|
|
1346
|
+
count: this.calculateCount(data, limits),
|
|
1342
1347
|
};
|
|
1343
1348
|
});
|
|
1344
1349
|
}
|
|
@@ -1748,33 +1753,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
1748
1753
|
}
|
|
1749
1754
|
}
|
|
1750
1755
|
|
|
1751
|
-
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1752
|
-
constructor(firestore) {
|
|
1753
|
-
super();
|
|
1754
|
-
this.firestore = firestore;
|
|
1755
|
-
this.collectionName = 'buy2win';
|
|
1756
|
-
this.model = Buy2Win;
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1761
|
-
constructor(firestore) {
|
|
1762
|
-
super();
|
|
1763
|
-
this.firestore = firestore;
|
|
1764
|
-
this.collectionName = 'dashboardCampaignsAuto';
|
|
1765
|
-
this.model = CampaignDashboard;
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1770
|
-
constructor(firestore) {
|
|
1771
|
-
super();
|
|
1772
|
-
this.firestore = firestore;
|
|
1773
|
-
this.collectionName = 'hashtagCampaignsAuto';
|
|
1774
|
-
this.model = CampaignHashtag;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
1756
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1779
1757
|
constructor(firestore) {
|
|
1780
1758
|
super();
|
|
@@ -1784,15 +1762,6 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1784
1762
|
}
|
|
1785
1763
|
}
|
|
1786
1764
|
|
|
1787
|
-
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1788
|
-
constructor(firestore) {
|
|
1789
|
-
super();
|
|
1790
|
-
this.firestore = firestore;
|
|
1791
|
-
this.collectionName = 'checkoutsSubscription';
|
|
1792
|
-
this.model = CheckoutSubscription;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
1765
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1797
1766
|
constructor(firestore) {
|
|
1798
1767
|
super();
|
|
@@ -1855,20 +1824,21 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1855
1824
|
}
|
|
1856
1825
|
}
|
|
1857
1826
|
|
|
1858
|
-
class
|
|
1827
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1859
1828
|
constructor(firestore) {
|
|
1860
|
-
super(
|
|
1829
|
+
super();
|
|
1861
1830
|
this.firestore = firestore;
|
|
1862
|
-
this.collectionName = '
|
|
1831
|
+
this.collectionName = 'payments';
|
|
1832
|
+
this.model = Payment;
|
|
1863
1833
|
}
|
|
1864
1834
|
}
|
|
1865
1835
|
|
|
1866
|
-
class
|
|
1836
|
+
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1867
1837
|
constructor(firestore) {
|
|
1868
1838
|
super();
|
|
1869
1839
|
this.firestore = firestore;
|
|
1870
|
-
this.collectionName = '
|
|
1871
|
-
this.model =
|
|
1840
|
+
this.collectionName = 'checkoutsSubscription';
|
|
1841
|
+
this.model = CheckoutSubscription;
|
|
1872
1842
|
}
|
|
1873
1843
|
}
|
|
1874
1844
|
|
|
@@ -1881,6 +1851,23 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
1881
1851
|
}
|
|
1882
1852
|
}
|
|
1883
1853
|
|
|
1854
|
+
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1855
|
+
constructor(firestore) {
|
|
1856
|
+
super();
|
|
1857
|
+
this.firestore = firestore;
|
|
1858
|
+
this.collectionName = 'buy2win';
|
|
1859
|
+
this.model = Buy2Win;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1864
|
+
constructor(firestore) {
|
|
1865
|
+
super(firestore);
|
|
1866
|
+
this.firestore = firestore;
|
|
1867
|
+
this.collectionName = 'legacyOrders';
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1884
1871
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1885
1872
|
constructor(firestore) {
|
|
1886
1873
|
super();
|
|
@@ -2338,12 +2325,12 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2338
2325
|
fetch(params) {
|
|
2339
2326
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2340
2327
|
const headers = this.headers;
|
|
2341
|
-
const
|
|
2342
|
-
url: `${this.endpoint}`,
|
|
2328
|
+
const response = yield fetch(`${this.endpoint}`, {
|
|
2343
2329
|
method: 'POST',
|
|
2344
|
-
|
|
2330
|
+
body: JSON.stringify(params),
|
|
2345
2331
|
headers,
|
|
2346
2332
|
});
|
|
2333
|
+
const result = yield response.json();
|
|
2347
2334
|
if (!isNil(result.errors))
|
|
2348
2335
|
throw new Error(JSON.stringify(result.errors));
|
|
2349
2336
|
return result.data;
|
|
@@ -2467,11 +2454,9 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2467
2454
|
|
|
2468
2455
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2469
2456
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2470
|
-
find(
|
|
2471
|
-
var _a;
|
|
2457
|
+
find(options) {
|
|
2472
2458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2473
|
-
const { filters, limits, orderBy
|
|
2474
|
-
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2459
|
+
const { filters, limits, orderBy } = options || {};
|
|
2475
2460
|
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
2476
2461
|
? {}
|
|
2477
2462
|
: {
|
|
@@ -2485,8 +2470,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2485
2470
|
const result = yield this.query([
|
|
2486
2471
|
{
|
|
2487
2472
|
operation: this.tableName,
|
|
2488
|
-
fields:
|
|
2489
|
-
?
|
|
2473
|
+
fields: options.fields
|
|
2474
|
+
? options.fields
|
|
2490
2475
|
.map((fieldName) => {
|
|
2491
2476
|
var _a;
|
|
2492
2477
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2495,18 +2480,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2495
2480
|
: this.fields,
|
|
2496
2481
|
variables,
|
|
2497
2482
|
},
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
variables: variablesCount,
|
|
2504
|
-
},
|
|
2505
|
-
]
|
|
2506
|
-
: []),
|
|
2483
|
+
{
|
|
2484
|
+
operation: `${this.tableName}_aggregate`,
|
|
2485
|
+
fields: [{ aggregate: ['count'] }],
|
|
2486
|
+
variables: variablesCount,
|
|
2487
|
+
},
|
|
2507
2488
|
]);
|
|
2508
2489
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2509
|
-
|
|
2490
|
+
const count = result[`${this.tableName}_aggregate`].aggregate.count;
|
|
2491
|
+
return { count, data };
|
|
2510
2492
|
});
|
|
2511
2493
|
}
|
|
2512
2494
|
};
|
|
@@ -2520,6 +2502,12 @@ const withCrudHasuraGraphQL = (MixinBase) => {
|
|
|
2520
2502
|
class CategoryHasuraGraphQL extends Category {
|
|
2521
2503
|
}
|
|
2522
2504
|
|
|
2505
|
+
class FilterHasuraGraphQL extends Filter {
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
class FilterOptionHasuraGraphQL extends FilterOption {
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2523
2511
|
class ProductHasuraGraphQL extends Product {
|
|
2524
2512
|
}
|
|
2525
2513
|
__decorate([
|
|
@@ -2625,7 +2613,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2625
2613
|
var _a;
|
|
2626
2614
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2627
2615
|
return Number.isNaN(+identifiers.id)
|
|
2628
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
2616
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2629
2617
|
: _super.get.call(this, identifiers);
|
|
2630
2618
|
});
|
|
2631
2619
|
}
|
|
@@ -2647,11 +2635,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2647
2635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2648
2636
|
if (!slug)
|
|
2649
2637
|
return;
|
|
2650
|
-
const { data } = yield this.find({ filters: { slug, shop, published: true }
|
|
2651
|
-
if (
|
|
2652
|
-
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2653
|
-
if (data.length > 1)
|
|
2638
|
+
const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
|
|
2639
|
+
if (count > 1)
|
|
2654
2640
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2641
|
+
if (!count)
|
|
2642
|
+
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2655
2643
|
return data.shift();
|
|
2656
2644
|
});
|
|
2657
2645
|
}
|
|
@@ -2687,7 +2675,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2687
2675
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2688
2676
|
return [];
|
|
2689
2677
|
const products = [];
|
|
2690
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign(
|
|
2678
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2691
2679
|
'id',
|
|
2692
2680
|
'name',
|
|
2693
2681
|
'slug',
|
|
@@ -2711,7 +2699,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2711
2699
|
'tags',
|
|
2712
2700
|
'type',
|
|
2713
2701
|
'shoppingCount',
|
|
2714
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {}))
|
|
2702
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2715
2703
|
products.push(...productsData);
|
|
2716
2704
|
return products;
|
|
2717
2705
|
});
|
|
@@ -2721,7 +2709,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2721
2709
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2722
2710
|
if (!Number.isNaN(+id))
|
|
2723
2711
|
return id;
|
|
2724
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
2712
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2725
2713
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2726
2714
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2727
2715
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2781,6 +2769,142 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2781
2769
|
}
|
|
2782
2770
|
}
|
|
2783
2771
|
|
|
2772
|
+
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2773
|
+
constructor(endpoint, authOptions, filterOptionRepository) {
|
|
2774
|
+
super({
|
|
2775
|
+
tableName: 'filter',
|
|
2776
|
+
model: FilterHasuraGraphQL,
|
|
2777
|
+
endpoint,
|
|
2778
|
+
authOptions,
|
|
2779
|
+
fields: [
|
|
2780
|
+
'id',
|
|
2781
|
+
'description',
|
|
2782
|
+
'enabled',
|
|
2783
|
+
'createdAt',
|
|
2784
|
+
'updatedAt',
|
|
2785
|
+
{
|
|
2786
|
+
options: {
|
|
2787
|
+
columnName: 'options',
|
|
2788
|
+
foreignKeyColumn: { filterId: 'id' },
|
|
2789
|
+
fields: [
|
|
2790
|
+
'id',
|
|
2791
|
+
{ filterId: { columnName: 'filter_id' } },
|
|
2792
|
+
'description',
|
|
2793
|
+
'createdAt',
|
|
2794
|
+
'updatedAt'
|
|
2795
|
+
],
|
|
2796
|
+
},
|
|
2797
|
+
}
|
|
2798
|
+
],
|
|
2799
|
+
});
|
|
2800
|
+
this.filterOptionRepository = filterOptionRepository;
|
|
2801
|
+
}
|
|
2802
|
+
get(identifiers) {
|
|
2803
|
+
const _super = Object.create(null, {
|
|
2804
|
+
get: { get: () => super.get }
|
|
2805
|
+
});
|
|
2806
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2807
|
+
const filter = yield _super.get.call(this, identifiers);
|
|
2808
|
+
if (!filter)
|
|
2809
|
+
throw new NotFoundError('Filter not found');
|
|
2810
|
+
return filter;
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
find(options) {
|
|
2814
|
+
const _super = Object.create(null, {
|
|
2815
|
+
find: { get: () => super.find }
|
|
2816
|
+
});
|
|
2817
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2818
|
+
const filter = yield _super.find.call(this, options);
|
|
2819
|
+
return filter;
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
create(params) {
|
|
2823
|
+
const _super = Object.create(null, {
|
|
2824
|
+
create: { get: () => super.create }
|
|
2825
|
+
});
|
|
2826
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2827
|
+
const filter = yield _super.create.call(this, params);
|
|
2828
|
+
return filter;
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
update(params) {
|
|
2832
|
+
const _super = Object.create(null, {
|
|
2833
|
+
update: { get: () => super.update }
|
|
2834
|
+
});
|
|
2835
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2836
|
+
const { options } = params, data = __rest(params, ["options"]);
|
|
2837
|
+
const filter = yield _super.update.call(this, data);
|
|
2838
|
+
filter.options = yield this.updateOptions(+data.id, { options });
|
|
2839
|
+
return filter;
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
;
|
|
2843
|
+
updateOptions(filterId, { options }) {
|
|
2844
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2845
|
+
if (!options)
|
|
2846
|
+
return [];
|
|
2847
|
+
if ('action' in options && options.action === 'remove') {
|
|
2848
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
2849
|
+
yield this.filterOptionRepository.delete({ id: options.value[i].id });
|
|
2850
|
+
}
|
|
2851
|
+
return [];
|
|
2852
|
+
}
|
|
2853
|
+
if ('action' in options && options.action === 'update') {
|
|
2854
|
+
let filterOptions = [];
|
|
2855
|
+
for (let i = 0; i < options.value.length; i++) {
|
|
2856
|
+
const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
|
|
2857
|
+
if (!hasFilter) {
|
|
2858
|
+
const newOption = yield this.filterOptionRepository.create(options.value[i]);
|
|
2859
|
+
filterOptions.push(newOption);
|
|
2860
|
+
}
|
|
2861
|
+
else {
|
|
2862
|
+
filterOptions.push(hasFilter);
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
return filterOptions;
|
|
2866
|
+
}
|
|
2867
|
+
});
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
|
|
2871
|
+
class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2872
|
+
constructor(endpoint, authOptions) {
|
|
2873
|
+
super({
|
|
2874
|
+
tableName: 'filter-option',
|
|
2875
|
+
model: FilterOptionHasuraGraphQL,
|
|
2876
|
+
endpoint,
|
|
2877
|
+
authOptions,
|
|
2878
|
+
fields: [],
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
create(params) {
|
|
2882
|
+
return super.create(params);
|
|
2883
|
+
}
|
|
2884
|
+
find(options) {
|
|
2885
|
+
const _super = Object.create(null, {
|
|
2886
|
+
find: { get: () => super.find }
|
|
2887
|
+
});
|
|
2888
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2889
|
+
const filterOptions = yield _super.find.call(this, options);
|
|
2890
|
+
return filterOptions;
|
|
2891
|
+
});
|
|
2892
|
+
}
|
|
2893
|
+
delete(identifiers) {
|
|
2894
|
+
return super.delete(identifiers);
|
|
2895
|
+
}
|
|
2896
|
+
findByFilter(filterId) {
|
|
2897
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2898
|
+
const options = yield this.find({
|
|
2899
|
+
filters: {
|
|
2900
|
+
filterId,
|
|
2901
|
+
},
|
|
2902
|
+
});
|
|
2903
|
+
return options;
|
|
2904
|
+
});
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2784
2908
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2785
2909
|
constructor(endpoint, authOptions) {
|
|
2786
2910
|
super({
|
|
@@ -2985,7 +3109,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2985
3109
|
var _a;
|
|
2986
3110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2987
3111
|
const product = Number.isNaN(+identifiers.id)
|
|
2988
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }
|
|
3112
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2989
3113
|
: yield _super.get.call(this, identifiers);
|
|
2990
3114
|
if (product.productId)
|
|
2991
3115
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3013,12 +3137,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3013
3137
|
filters: {
|
|
3014
3138
|
slug,
|
|
3015
3139
|
},
|
|
3016
|
-
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3017
|
-
options: {
|
|
3018
|
-
enableCount: false,
|
|
3019
|
-
},
|
|
3020
3140
|
});
|
|
3021
3141
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3142
|
+
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
3022
3143
|
return product;
|
|
3023
3144
|
});
|
|
3024
3145
|
}
|
|
@@ -3181,7 +3302,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3181
3302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3182
3303
|
if (!Number.isNaN(+id))
|
|
3183
3304
|
return id;
|
|
3184
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3305
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3185
3306
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3186
3307
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3187
3308
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3340,7 +3461,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3340
3461
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3341
3462
|
if (!Number.isNaN(+id))
|
|
3342
3463
|
return id;
|
|
3343
|
-
const { data } = yield this.find({ filters: { firestoreId: id }
|
|
3464
|
+
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3344
3465
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3345
3466
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3346
3467
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3352,5 +3473,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3352
3473
|
* Generated bundle index. Do not edit.
|
|
3353
3474
|
*/
|
|
3354
3475
|
|
|
3355
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
3476
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQL, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQL, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, 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, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3356
3477
|
//# sourceMappingURL=infrab4a-connect.js.map
|