@infrab4a/connect 3.5.0-beta.1 → 3.5.0-beta.3
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 +161 -78
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/generic/repository/find.repository.d.ts +3 -0
- package/domain/shopping/models/enums/order-status.enum.d.ts +2 -2
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/shopping/models/campaign-hashtag.js +1 -1
- package/esm2015/domain/shopping/models/enums/order-status.enum.js +3 -3
- package/esm2015/infra/firebase/firestore/enums/firestore-field-type.enum.js +10 -0
- package/esm2015/infra/firebase/firestore/enums/index.js +2 -0
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +11 -5
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +34 -7
- package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.js +2 -2
- package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +7 -2
- package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +17 -12
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +28 -17
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +7 -4
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -2
- package/fesm2015/infrab4a-connect.js +108 -43
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/enums/firestore-field-type.enum.d.ts +8 -0
- package/infra/firebase/firestore/enums/index.d.ts +1 -0
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +2 -2
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +3 -1
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +4 -9
- package/package.json +2 -2
|
@@ -878,8 +878,8 @@ var OrderStatus;
|
|
|
878
878
|
OrderStatus["EM_PREPARO"] = "Preparando pedido";
|
|
879
879
|
OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
|
|
880
880
|
OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
|
|
881
|
-
OrderStatus["ENVIADO"] = "
|
|
882
|
-
OrderStatus["ENTREGUE"] = "
|
|
881
|
+
OrderStatus["ENVIADO"] = "Enviado";
|
|
882
|
+
OrderStatus["ENTREGUE"] = "Entregue";
|
|
883
883
|
OrderStatus["CANCELADO"] = "Cancelado";
|
|
884
884
|
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
885
885
|
})(OrderStatus || (OrderStatus = {}));
|
|
@@ -1186,6 +1186,27 @@ class ProductsIndex {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
|
|
1188
1188
|
const withFirestore = (MixinBase) => {
|
|
1189
|
+
const isObjectsAndNoDate = (data) => data &&
|
|
1190
|
+
!Array.isArray(data) &&
|
|
1191
|
+
typeof data === 'object' &&
|
|
1192
|
+
(data === null || data === void 0 ? void 0 : data.constructor.name) !== 'Timestamp' &&
|
|
1193
|
+
!('seconds' in data);
|
|
1194
|
+
const bindDate = (data, keyName) => {
|
|
1195
|
+
if ((data === null || data === void 0 ? void 0 : data.constructor.name) === 'Timestamp')
|
|
1196
|
+
return data.toDate();
|
|
1197
|
+
if (data && typeof data === 'object' && 'seconds' in data)
|
|
1198
|
+
return new Date(data.seconds * 1000);
|
|
1199
|
+
if (typeof data === 'number' && ['createdAt', 'updatedAt'].includes(keyName))
|
|
1200
|
+
return new Date(data);
|
|
1201
|
+
return data;
|
|
1202
|
+
};
|
|
1203
|
+
const bindAllDateFromObject = (data) => {
|
|
1204
|
+
return Object.keys(data).reduce((object, key) => (Object.assign(Object.assign({}, object), { [key]: isObjectsAndNoDate(data[key])
|
|
1205
|
+
? bindAllDateFromObject(data[key])
|
|
1206
|
+
: Array.isArray(data[key])
|
|
1207
|
+
? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
|
|
1208
|
+
: bindDate(data[key], key) })), {});
|
|
1209
|
+
};
|
|
1189
1210
|
return class extends MixinBase {
|
|
1190
1211
|
collection(path) {
|
|
1191
1212
|
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
@@ -1195,12 +1216,18 @@ const withFirestore = (MixinBase) => {
|
|
|
1195
1216
|
toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
1196
1217
|
fromFirestore: (snap) => {
|
|
1197
1218
|
const data = snap.data();
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1219
|
+
let bindedData;
|
|
1220
|
+
try {
|
|
1221
|
+
const ids = { id: snap.id };
|
|
1222
|
+
bindedData = bindAllDateFromObject(data);
|
|
1223
|
+
return this.model.toInstance(Object.assign(Object.assign({}, bindedData), ids));
|
|
1224
|
+
}
|
|
1225
|
+
catch (error) {
|
|
1226
|
+
console.info('id', snap.id);
|
|
1227
|
+
console.info('data', JSON.stringify(bindedData));
|
|
1228
|
+
console.error(error);
|
|
1229
|
+
throw error;
|
|
1230
|
+
}
|
|
1204
1231
|
},
|
|
1205
1232
|
};
|
|
1206
1233
|
}
|
|
@@ -1244,6 +1271,16 @@ const withGetFirestore = (MixinBase) => {
|
|
|
1244
1271
|
};
|
|
1245
1272
|
};
|
|
1246
1273
|
|
|
1274
|
+
var FirestoreFieldType;
|
|
1275
|
+
(function (FirestoreFieldType) {
|
|
1276
|
+
FirestoreFieldType["String"] = "string";
|
|
1277
|
+
FirestoreFieldType["Number"] = "number";
|
|
1278
|
+
FirestoreFieldType["Boolean"] = "boolean";
|
|
1279
|
+
FirestoreFieldType["Timestamp"] = "timestamp";
|
|
1280
|
+
FirestoreFieldType["Array"] = "array";
|
|
1281
|
+
FirestoreFieldType["Map"] = "map";
|
|
1282
|
+
})(FirestoreFieldType || (FirestoreFieldType = {}));
|
|
1283
|
+
|
|
1247
1284
|
const withFindFirestore = (MixinBase) => {
|
|
1248
1285
|
const checkIfIsFilterOption = (filter) => !isNil(filter === null || filter === void 0 ? void 0 : filter.operator);
|
|
1249
1286
|
const getValueFromFilter = (filter) => {
|
|
@@ -1267,13 +1304,16 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1267
1304
|
? fieldName.toString()
|
|
1268
1305
|
: Object.keys(plainInstance).find((key) => plainInstance[key]);
|
|
1269
1306
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
|
|
1270
|
-
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value)
|
|
1307
|
+
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
|
|
1308
|
+
(this.fields[firestoreFieldName] === FirestoreFieldType.Array || !this.fields[firestoreFieldName]))
|
|
1271
1309
|
return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
|
|
1272
1310
|
queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
|
|
1273
1311
|
queryReference = queryReference.where(firestoreFieldName, '<=', `${options.value}~`);
|
|
1274
1312
|
return queryReference;
|
|
1275
1313
|
}
|
|
1276
|
-
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN &&
|
|
1314
|
+
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN &&
|
|
1315
|
+
Array.isArray(options === null || options === void 0 ? void 0 : options.value) &&
|
|
1316
|
+
(this.fields[firestoreFieldName] === FirestoreFieldType.Array || !this.fields[firestoreFieldName]))
|
|
1277
1317
|
return queryReference.where(firestoreFieldName, 'array-contains', options.value);
|
|
1278
1318
|
if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1279
1319
|
return Object.keys(options).reduce((queryReferenceWithWhere, key) => this.buildWhereSentence(queryReferenceWithWhere, `${fieldName.toString()}.${key}`, options[key]), queryReference);
|
|
@@ -1281,9 +1321,11 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1281
1321
|
return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
|
|
1282
1322
|
};
|
|
1283
1323
|
}
|
|
1284
|
-
find({ filters, limits, orderBy, } = {}) {
|
|
1324
|
+
find({ filters, limits, orderBy, options } = {}) {
|
|
1325
|
+
var _a;
|
|
1285
1326
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1286
1327
|
const orderByKeys = Object.keys(orderBy || {});
|
|
1328
|
+
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
1287
1329
|
let query = this.collection(this.buildCollectionPathForFind(filters || {}));
|
|
1288
1330
|
query = this.makeFirestoreWhere(query, filters || {});
|
|
1289
1331
|
if (orderByKeys.length) {
|
|
@@ -1297,7 +1339,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1297
1339
|
const data = docs.docs.map((doc) => doc.data());
|
|
1298
1340
|
return {
|
|
1299
1341
|
data,
|
|
1300
|
-
count: this.calculateCount(data, limits),
|
|
1342
|
+
count: enableCount ? this.calculateCount(data, limits) : Infinity,
|
|
1301
1343
|
};
|
|
1302
1344
|
});
|
|
1303
1345
|
}
|
|
@@ -1786,7 +1828,8 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1786
1828
|
var _a;
|
|
1787
1829
|
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1788
1830
|
order.lineItems = order.lineItems.map((lineItem) => {
|
|
1789
|
-
|
|
1831
|
+
var _a;
|
|
1832
|
+
if (!!((_a = lineItem.price) === null || _a === void 0 ? void 0 : _a[order.shop])) {
|
|
1790
1833
|
const shopPrice = lineItem['price'][order.shop];
|
|
1791
1834
|
lineItem['price'] = shopPrice;
|
|
1792
1835
|
}
|
|
@@ -1797,6 +1840,9 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1797
1840
|
};
|
|
1798
1841
|
this.collectionName = 'orders';
|
|
1799
1842
|
this.model = Order;
|
|
1843
|
+
this.fields = {
|
|
1844
|
+
status: FirestoreFieldType.String,
|
|
1845
|
+
};
|
|
1800
1846
|
}
|
|
1801
1847
|
buildModelInstance() {
|
|
1802
1848
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -2422,9 +2468,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2422
2468
|
|
|
2423
2469
|
const withFindHasuraGraphQL = (MixinBase) => {
|
|
2424
2470
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
2425
|
-
find(
|
|
2471
|
+
find(params) {
|
|
2472
|
+
var _a;
|
|
2426
2473
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2427
|
-
const { filters, limits, orderBy } =
|
|
2474
|
+
const { filters, limits, orderBy, options } = params || {};
|
|
2475
|
+
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
2428
2476
|
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
|
|
2429
2477
|
? {}
|
|
2430
2478
|
: {
|
|
@@ -2438,8 +2486,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2438
2486
|
const result = yield this.query([
|
|
2439
2487
|
{
|
|
2440
2488
|
operation: this.tableName,
|
|
2441
|
-
fields:
|
|
2442
|
-
?
|
|
2489
|
+
fields: params.fields
|
|
2490
|
+
? params.fields
|
|
2443
2491
|
.map((fieldName) => {
|
|
2444
2492
|
var _a;
|
|
2445
2493
|
return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
@@ -2448,15 +2496,18 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2448
2496
|
: this.fields,
|
|
2449
2497
|
variables,
|
|
2450
2498
|
},
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2499
|
+
...(enableCount
|
|
2500
|
+
? [
|
|
2501
|
+
{
|
|
2502
|
+
operation: `${this.tableName}_aggregate`,
|
|
2503
|
+
fields: [{ aggregate: ['count'] }],
|
|
2504
|
+
variables: variablesCount,
|
|
2505
|
+
},
|
|
2506
|
+
]
|
|
2507
|
+
: []),
|
|
2456
2508
|
]);
|
|
2457
2509
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2458
|
-
|
|
2459
|
-
return { count, data };
|
|
2510
|
+
return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
|
|
2460
2511
|
});
|
|
2461
2512
|
}
|
|
2462
2513
|
};
|
|
@@ -2575,7 +2626,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2575
2626
|
var _a;
|
|
2576
2627
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2577
2628
|
return Number.isNaN(+identifiers.id)
|
|
2578
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2629
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2579
2630
|
: _super.get.call(this, identifiers);
|
|
2580
2631
|
});
|
|
2581
2632
|
}
|
|
@@ -2597,21 +2648,31 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2597
2648
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2598
2649
|
if (!slug)
|
|
2599
2650
|
return;
|
|
2600
|
-
const { data
|
|
2601
|
-
if (
|
|
2602
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2603
|
-
if (!count)
|
|
2651
|
+
const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
|
|
2652
|
+
if (!data.length)
|
|
2604
2653
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2654
|
+
if (data.length > 1)
|
|
2655
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2605
2656
|
return data.shift();
|
|
2606
2657
|
});
|
|
2607
2658
|
}
|
|
2608
2659
|
getCategoriesForHome(categoryIds, limit = 4) {
|
|
2609
2660
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2661
|
+
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
2662
|
+
return [];
|
|
2663
|
+
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
2664
|
+
const categoriesHasura = categoryIds.filter((categoryId) => +categoryId > 0);
|
|
2665
|
+
const categories = [];
|
|
2666
|
+
if (categoriesFirestore.length)
|
|
2667
|
+
categories.push(...(yield this.find({
|
|
2668
|
+
filters: { firestoreId: { operator: Where.IN, value: categoriesFirestore.filter(Boolean) }, published: true },
|
|
2669
|
+
}).then(({ data }) => data)));
|
|
2670
|
+
if (categoriesHasura.length)
|
|
2671
|
+
categories.push(...(yield this.find({
|
|
2672
|
+
filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
|
|
2673
|
+
}).then(({ data }) => data)));
|
|
2674
|
+
if (!categories.length)
|
|
2675
|
+
return [];
|
|
2615
2676
|
const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
|
|
2616
2677
|
return ({
|
|
2617
2678
|
category,
|
|
@@ -2622,11 +2683,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2622
2683
|
});
|
|
2623
2684
|
}
|
|
2624
2685
|
mountCategory(category, options) {
|
|
2686
|
+
var _a;
|
|
2625
2687
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2626
|
-
if (!category.products)
|
|
2627
|
-
|
|
2688
|
+
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2689
|
+
return [];
|
|
2628
2690
|
const products = [];
|
|
2629
|
-
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
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign(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: [
|
|
2630
2692
|
'id',
|
|
2631
2693
|
'name',
|
|
2632
2694
|
'slug',
|
|
@@ -2650,7 +2712,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2650
2712
|
'tags',
|
|
2651
2713
|
'type',
|
|
2652
2714
|
'shoppingCount',
|
|
2653
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2715
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2654
2716
|
products.push(...productsData);
|
|
2655
2717
|
return products;
|
|
2656
2718
|
});
|
|
@@ -2660,7 +2722,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2660
2722
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2661
2723
|
if (!Number.isNaN(+id))
|
|
2662
2724
|
return id;
|
|
2663
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2725
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2664
2726
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2665
2727
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2666
2728
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2924,7 +2986,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2924
2986
|
var _a;
|
|
2925
2987
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2926
2988
|
const product = Number.isNaN(+identifiers.id)
|
|
2927
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2989
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2928
2990
|
: yield _super.get.call(this, identifiers);
|
|
2929
2991
|
if (product.productId)
|
|
2930
2992
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -2952,9 +3014,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2952
3014
|
filters: {
|
|
2953
3015
|
slug,
|
|
2954
3016
|
},
|
|
3017
|
+
fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
|
|
3018
|
+
options: {
|
|
3019
|
+
enableCount: false,
|
|
3020
|
+
},
|
|
2955
3021
|
});
|
|
2956
3022
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
2957
|
-
product.reviews = yield this.findReviewsByProduct(+product.id);
|
|
2958
3023
|
return product;
|
|
2959
3024
|
});
|
|
2960
3025
|
}
|
|
@@ -3117,7 +3182,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3117
3182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3118
3183
|
if (!Number.isNaN(+id))
|
|
3119
3184
|
return id;
|
|
3120
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3185
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3121
3186
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3122
3187
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3123
3188
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3276,7 +3341,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3276
3341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3277
3342
|
if (!Number.isNaN(+id))
|
|
3278
3343
|
return id;
|
|
3279
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3344
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3280
3345
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3281
3346
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3282
3347
|
throw new NotFoundError(`Product with id ${id} not found`);
|