@infrab4a/connect 4.0.0-beta.7 → 4.0.0-beta.9
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/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +2 -2
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +1 -1
- package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +4 -6
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +3 -2
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +3 -2
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +8 -7
- package/fesm2015/infrab4a-connect.mjs +13 -12
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +14 -14
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +5 -1
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +4 -4
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +3 -3
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
- package/package.json +1 -1
|
@@ -10,7 +10,6 @@ import axios from 'axios';
|
|
|
10
10
|
import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
|
|
11
11
|
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
12
12
|
import { mutation, query as query$1 } from 'gql-query-builder';
|
|
13
|
-
import fetch from 'node-fetch';
|
|
14
13
|
|
|
15
14
|
class BaseModel {
|
|
16
15
|
get identifier() {
|
|
@@ -1358,7 +1357,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1358
1357
|
const queries = [];
|
|
1359
1358
|
if (limits?.offset) {
|
|
1360
1359
|
if (this.model.isModel(limits.offset))
|
|
1361
|
-
queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
|
|
1360
|
+
queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[limits.offset.identifiersFields?.shift()]))));
|
|
1362
1361
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1363
1362
|
queries.push(startAt(limits.offset));
|
|
1364
1363
|
}
|
|
@@ -2312,12 +2311,10 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2312
2311
|
}
|
|
2313
2312
|
async fetch(params) {
|
|
2314
2313
|
const headers = this.headers;
|
|
2315
|
-
const response = await
|
|
2316
|
-
method: 'POST',
|
|
2317
|
-
body: JSON.stringify(params),
|
|
2314
|
+
const response = await axios.post(`${this.endpoint}`, params, {
|
|
2318
2315
|
headers,
|
|
2319
2316
|
});
|
|
2320
|
-
const result = await response.
|
|
2317
|
+
const result = await response.data;
|
|
2321
2318
|
if (!isNil(result.errors))
|
|
2322
2319
|
throw new Error(JSON.stringify(result.errors));
|
|
2323
2320
|
return result.data;
|
|
@@ -2523,12 +2520,13 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2523
2520
|
}
|
|
2524
2521
|
|
|
2525
2522
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2526
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2523
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository) {
|
|
2527
2524
|
super({
|
|
2528
2525
|
tableName: 'category',
|
|
2529
2526
|
model: Category,
|
|
2530
2527
|
endpoint,
|
|
2531
2528
|
authOptions,
|
|
2529
|
+
interceptors,
|
|
2532
2530
|
fields: [
|
|
2533
2531
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2534
2532
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -2740,12 +2738,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2740
2738
|
}
|
|
2741
2739
|
|
|
2742
2740
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2743
|
-
constructor(endpoint, authOptions) {
|
|
2741
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2744
2742
|
super({
|
|
2745
2743
|
tableName: 'product',
|
|
2746
2744
|
model: ProductHasuraGraphQL,
|
|
2747
2745
|
endpoint,
|
|
2748
2746
|
authOptions,
|
|
2747
|
+
interceptors,
|
|
2749
2748
|
fields: [],
|
|
2750
2749
|
});
|
|
2751
2750
|
this.bindReviewToModel = (plain) => ({
|
|
@@ -3200,12 +3199,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3200
3199
|
}
|
|
3201
3200
|
|
|
3202
3201
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3203
|
-
constructor(endpoint, authOptions) {
|
|
3202
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3204
3203
|
super({
|
|
3205
3204
|
tableName: 'product',
|
|
3206
3205
|
model: VariantHasuraGraphQL,
|
|
3207
3206
|
endpoint,
|
|
3208
3207
|
authOptions,
|
|
3208
|
+
interceptors,
|
|
3209
3209
|
fields: [
|
|
3210
3210
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3211
3211
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3228,7 +3228,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3228
3228
|
subscriberPrice: data.subscriber_price,
|
|
3229
3229
|
}),
|
|
3230
3230
|
bindFindFilter: (sentence) => {
|
|
3231
|
-
const filters = Object.values(sentence).shift();
|
|
3231
|
+
const filters = Object.values(sentence || {}).shift();
|
|
3232
3232
|
return {
|
|
3233
3233
|
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
3234
3234
|
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
@@ -3241,12 +3241,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3241
3241
|
};
|
|
3242
3242
|
},
|
|
3243
3243
|
bindPersistData: (priceData) => ({
|
|
3244
|
-
...(priceData?.price >= 0 && { price: priceData.price }),
|
|
3245
|
-
...(priceData
|
|
3246
|
-
...(priceData
|
|
3244
|
+
...((priceData?.price || 0) >= 0 && { price: priceData.price }),
|
|
3245
|
+
...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
|
|
3246
|
+
...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
|
|
3247
3247
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3248
3248
|
}),
|
|
3249
|
-
...(priceData
|
|
3249
|
+
...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
3250
3250
|
}),
|
|
3251
3251
|
},
|
|
3252
3252
|
},
|