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