@infrab4a/connect 4.0.0-beta.0 → 4.0.0-beta.11
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/domain/users/models/subscription/edition.mjs +1 -1
- package/esm2020/domain/users/models/subscription/payment.mjs +1 -1
- package/esm2020/domain/users/models/user-payment-method.mjs +1 -1
- 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/mixins/with-update-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/helpers/graphql-field.helper.mjs +2 -2
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +22 -18
- 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/esm2020/utils/get.mjs +3 -0
- package/esm2020/utils/index.mjs +4 -4
- package/fesm2015/infrab4a-connect.mjs +41 -32
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +40 -34
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +12 -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 +2 -2
- package/utils/get.d.ts +1 -0
- package/utils/index.d.ts +3 -43
|
@@ -3,14 +3,13 @@ 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
|
|
7
|
-
|
|
6
|
+
import { get as get$1, 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';
|
|
8
8
|
import { CustomError } from 'ts-custom-error';
|
|
9
9
|
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() {
|
|
@@ -467,11 +466,13 @@ class Address extends BaseModel {
|
|
|
467
466
|
}
|
|
468
467
|
}
|
|
469
468
|
|
|
469
|
+
const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
|
|
470
|
+
|
|
470
471
|
function is(value) {
|
|
471
472
|
return value;
|
|
472
473
|
}
|
|
473
474
|
|
|
474
|
-
const isUUID = (value) => isString
|
|
475
|
+
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
|
|
|
476
477
|
class Base {
|
|
477
478
|
constructor(...args) {
|
|
@@ -480,7 +481,7 @@ class Base {
|
|
|
480
481
|
}
|
|
481
482
|
|
|
482
483
|
const parseDateTime = (value) => {
|
|
483
|
-
if (!isString
|
|
484
|
+
if (!isString(value))
|
|
484
485
|
return value;
|
|
485
486
|
if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
|
|
486
487
|
!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
|
|
@@ -491,8 +492,6 @@ const parseDateTime = (value) => {
|
|
|
491
492
|
return date;
|
|
492
493
|
};
|
|
493
494
|
|
|
494
|
-
const { chunk, get, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
|
|
495
|
-
|
|
496
495
|
var CheckoutTypes;
|
|
497
496
|
(function (CheckoutTypes) {
|
|
498
497
|
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
@@ -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
|
}
|
|
@@ -2151,7 +2150,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2151
2150
|
}
|
|
2152
2151
|
if (!!from)
|
|
2153
2152
|
return { ...result, [attributeName]: from(data[columnName], data) };
|
|
2154
|
-
return { ...result, [attributeName]: parseDateTime(data[columnName]
|
|
2153
|
+
return { ...result, [attributeName]: parseDateTime(data[columnName]?.toString()) };
|
|
2155
2154
|
}, {});
|
|
2156
2155
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2157
2156
|
const data = instance.toPlain?.() || instance;
|
|
@@ -2297,27 +2296,18 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2297
2296
|
return this.fetch(resultQuery);
|
|
2298
2297
|
}
|
|
2299
2298
|
async query(operation, fields, variables) {
|
|
2300
|
-
const
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
})))
|
|
2306
|
-
: query$1({
|
|
2307
|
-
operation,
|
|
2308
|
-
variables,
|
|
2309
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2310
|
-
});
|
|
2311
|
-
return this.fetch(resultQuery);
|
|
2299
|
+
const builded = this.buildHasuraQueryFields({ operation, fields, variables });
|
|
2300
|
+
const interpected = (await this.interceptors?.request?.(builded)) || builded;
|
|
2301
|
+
const resultQuery = query$1(interpected);
|
|
2302
|
+
const result = await this.fetch(resultQuery);
|
|
2303
|
+
return (await this.interceptors?.response?.(result, interpected)) || result;
|
|
2312
2304
|
}
|
|
2313
2305
|
async fetch(params) {
|
|
2314
2306
|
const headers = this.headers;
|
|
2315
|
-
const response = await
|
|
2316
|
-
method: 'POST',
|
|
2317
|
-
body: JSON.stringify(params),
|
|
2307
|
+
const response = await axios.post(`${this.endpoint}`, params, {
|
|
2318
2308
|
headers,
|
|
2319
2309
|
});
|
|
2320
|
-
const result = await response.
|
|
2310
|
+
const result = await response.data;
|
|
2321
2311
|
if (!isNil(result.errors))
|
|
2322
2312
|
throw new Error(JSON.stringify(result.errors));
|
|
2323
2313
|
return result.data;
|
|
@@ -2352,6 +2342,19 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2352
2342
|
convertDataToHasura(instance, update = false) {
|
|
2353
2343
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2354
2344
|
}
|
|
2345
|
+
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
2346
|
+
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2347
|
+
? operation.map((option) => ({
|
|
2348
|
+
operation: option.operation,
|
|
2349
|
+
variables: option.variables,
|
|
2350
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2351
|
+
}))
|
|
2352
|
+
: {
|
|
2353
|
+
operation,
|
|
2354
|
+
variables,
|
|
2355
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2355
2358
|
};
|
|
2356
2359
|
};
|
|
2357
2360
|
|
|
@@ -2523,12 +2526,13 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2523
2526
|
}
|
|
2524
2527
|
|
|
2525
2528
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2526
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2529
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository) {
|
|
2527
2530
|
super({
|
|
2528
2531
|
tableName: 'category',
|
|
2529
2532
|
model: Category,
|
|
2530
2533
|
endpoint,
|
|
2531
2534
|
authOptions,
|
|
2535
|
+
interceptors,
|
|
2532
2536
|
fields: [
|
|
2533
2537
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2534
2538
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -2740,12 +2744,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2740
2744
|
}
|
|
2741
2745
|
|
|
2742
2746
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2743
|
-
constructor(endpoint, authOptions) {
|
|
2747
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2744
2748
|
super({
|
|
2745
2749
|
tableName: 'product',
|
|
2746
2750
|
model: ProductHasuraGraphQL,
|
|
2747
2751
|
endpoint,
|
|
2748
2752
|
authOptions,
|
|
2753
|
+
interceptors,
|
|
2749
2754
|
fields: [],
|
|
2750
2755
|
});
|
|
2751
2756
|
this.bindReviewToModel = (plain) => ({
|
|
@@ -3200,12 +3205,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3200
3205
|
}
|
|
3201
3206
|
|
|
3202
3207
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3203
|
-
constructor(endpoint, authOptions) {
|
|
3208
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3204
3209
|
super({
|
|
3205
3210
|
tableName: 'product',
|
|
3206
3211
|
model: VariantHasuraGraphQL,
|
|
3207
3212
|
endpoint,
|
|
3208
3213
|
authOptions,
|
|
3214
|
+
interceptors,
|
|
3209
3215
|
fields: [
|
|
3210
3216
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3211
3217
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3228,7 +3234,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3228
3234
|
subscriberPrice: data.subscriber_price,
|
|
3229
3235
|
}),
|
|
3230
3236
|
bindFindFilter: (sentence) => {
|
|
3231
|
-
const filters = Object.values(sentence).shift();
|
|
3237
|
+
const filters = Object.values(sentence || {}).shift();
|
|
3232
3238
|
return {
|
|
3233
3239
|
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
3234
3240
|
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
@@ -3241,12 +3247,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3241
3247
|
};
|
|
3242
3248
|
},
|
|
3243
3249
|
bindPersistData: (priceData) => ({
|
|
3244
|
-
...(priceData?.price >= 0 && { price: priceData.price }),
|
|
3245
|
-
...(priceData
|
|
3246
|
-
...(priceData
|
|
3250
|
+
...((priceData?.price || 0) >= 0 && { price: priceData.price }),
|
|
3251
|
+
...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
|
|
3252
|
+
...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
|
|
3247
3253
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3248
3254
|
}),
|
|
3249
|
-
...(priceData
|
|
3255
|
+
...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
3250
3256
|
}),
|
|
3251
3257
|
},
|
|
3252
3258
|
},
|
|
@@ -3309,5 +3315,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3309
3315
|
* Generated bundle index. Do not edit.
|
|
3310
3316
|
*/
|
|
3311
3317
|
|
|
3312
|
-
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, 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,
|
|
3318
|
+
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, 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, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
3313
3319
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|