@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, __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
|
-
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";
|
|
@@ -1360,11 +1359,12 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1360
1359
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1361
1360
|
}
|
|
1362
1361
|
defineLimits(filters, limits) {
|
|
1362
|
+
var _a;
|
|
1363
1363
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1364
1364
|
const queries = [];
|
|
1365
1365
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1366
1366
|
if (this.model.isModel(limits.offset))
|
|
1367
|
-
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
|
|
1367
|
+
queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[(_a = limits.offset.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]))));
|
|
1368
1368
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1369
1369
|
queries.push(startAt(limits.offset));
|
|
1370
1370
|
}
|
|
@@ -2168,6 +2168,7 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
2168
2168
|
}).filter((field) => !!field);
|
|
2169
2169
|
};
|
|
2170
2170
|
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
2171
|
+
var _a;
|
|
2171
2172
|
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
2172
2173
|
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
2173
2174
|
if (Array.isArray(data[columnName]))
|
|
@@ -2181,7 +2182,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
2181
2182
|
}
|
|
2182
2183
|
if (!!from)
|
|
2183
2184
|
return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
|
|
2184
|
-
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
|
|
2185
|
+
return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime((_a = data[columnName]) === null || _a === void 0 ? void 0 : _a.toString()) });
|
|
2185
2186
|
}, {});
|
|
2186
2187
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
2187
2188
|
var _a;
|
|
@@ -2322,30 +2323,22 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2322
2323
|
});
|
|
2323
2324
|
}
|
|
2324
2325
|
query(operation, fields, variables) {
|
|
2326
|
+
var _a, _b, _c, _d;
|
|
2325
2327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2326
|
-
const
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
})))
|
|
2332
|
-
: query$1({
|
|
2333
|
-
operation,
|
|
2334
|
-
variables,
|
|
2335
|
-
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2336
|
-
});
|
|
2337
|
-
return this.fetch(resultQuery);
|
|
2328
|
+
const builded = this.buildHasuraQueryFields({ operation, fields, variables });
|
|
2329
|
+
const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
|
|
2330
|
+
const resultQuery = query$1(interpected);
|
|
2331
|
+
const result = yield this.fetch(resultQuery);
|
|
2332
|
+
return (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, result, interpected))) || result;
|
|
2338
2333
|
});
|
|
2339
2334
|
}
|
|
2340
2335
|
fetch(params) {
|
|
2341
2336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2342
2337
|
const headers = this.headers;
|
|
2343
|
-
const response = yield
|
|
2344
|
-
method: 'POST',
|
|
2345
|
-
body: JSON.stringify(params),
|
|
2338
|
+
const response = yield axios.post(`${this.endpoint}`, params, {
|
|
2346
2339
|
headers,
|
|
2347
2340
|
});
|
|
2348
|
-
const result = yield response.
|
|
2341
|
+
const result = yield response.data;
|
|
2349
2342
|
if (!isNil(result.errors))
|
|
2350
2343
|
throw new Error(JSON.stringify(result.errors));
|
|
2351
2344
|
return result.data;
|
|
@@ -2381,6 +2374,19 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2381
2374
|
convertDataToHasura(instance, update = false) {
|
|
2382
2375
|
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
2383
2376
|
}
|
|
2377
|
+
buildHasuraQueryFields({ operation, fields, variables, }) {
|
|
2378
|
+
return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2379
|
+
? operation.map((option) => ({
|
|
2380
|
+
operation: option.operation,
|
|
2381
|
+
variables: option.variables,
|
|
2382
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2383
|
+
}))
|
|
2384
|
+
: {
|
|
2385
|
+
operation,
|
|
2386
|
+
variables,
|
|
2387
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2384
2390
|
};
|
|
2385
2391
|
};
|
|
2386
2392
|
|
|
@@ -2547,12 +2553,13 @@ class VariantHasuraGraphQL extends Variant {
|
|
|
2547
2553
|
}
|
|
2548
2554
|
|
|
2549
2555
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2550
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2556
|
+
constructor({ endpoint, authOptions, interceptors, }, productRepository) {
|
|
2551
2557
|
super({
|
|
2552
2558
|
tableName: 'category',
|
|
2553
2559
|
model: Category,
|
|
2554
2560
|
endpoint,
|
|
2555
2561
|
authOptions,
|
|
2562
|
+
interceptors,
|
|
2556
2563
|
fields: [
|
|
2557
2564
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2558
2565
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -2785,12 +2792,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2785
2792
|
}
|
|
2786
2793
|
|
|
2787
2794
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2788
|
-
constructor(endpoint, authOptions) {
|
|
2795
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
2789
2796
|
super({
|
|
2790
2797
|
tableName: 'product',
|
|
2791
2798
|
model: ProductHasuraGraphQL,
|
|
2792
2799
|
endpoint,
|
|
2793
2800
|
authOptions,
|
|
2801
|
+
interceptors,
|
|
2794
2802
|
fields: [],
|
|
2795
2803
|
});
|
|
2796
2804
|
this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id']))), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
|
|
@@ -3240,12 +3248,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3240
3248
|
}
|
|
3241
3249
|
|
|
3242
3250
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
3243
|
-
constructor(endpoint, authOptions) {
|
|
3251
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
3244
3252
|
super({
|
|
3245
3253
|
tableName: 'product',
|
|
3246
3254
|
model: VariantHasuraGraphQL,
|
|
3247
3255
|
endpoint,
|
|
3248
3256
|
authOptions,
|
|
3257
|
+
interceptors,
|
|
3249
3258
|
fields: [
|
|
3250
3259
|
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
3251
3260
|
{ firestoreId: { columnName: 'firestore_id' } },
|
|
@@ -3268,16 +3277,16 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3268
3277
|
subscriberPrice: data.subscriber_price,
|
|
3269
3278
|
}),
|
|
3270
3279
|
bindFindFilter: (sentence) => {
|
|
3271
|
-
const filters = Object.values(sentence).shift();
|
|
3280
|
+
const filters = Object.values(sentence || {}).shift();
|
|
3272
3281
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
3273
3282
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
3274
3283
|
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
3275
3284
|
subscriber_price: filters.subscriberPrice,
|
|
3276
3285
|
}));
|
|
3277
3286
|
},
|
|
3278
|
-
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
3287
|
+
bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (((priceData === null || priceData === void 0 ? void 0 : priceData.price) || 0) >= 0 && { price: priceData.price })), (((priceData === null || priceData === void 0 ? void 0 : priceData.fullPrice) || 0) >= 0 && { full_price: priceData.fullPrice })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberDiscountPercentage) || 0) >= 0 && {
|
|
3279
3288
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3280
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3289
|
+
})), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
|
|
3281
3290
|
},
|
|
3282
3291
|
},
|
|
3283
3292
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -3358,5 +3367,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3358
3367
|
* Generated bundle index. Do not edit.
|
|
3359
3368
|
*/
|
|
3360
3369
|
|
|
3361
|
-
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,
|
|
3370
|
+
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 };
|
|
3362
3371
|
//# sourceMappingURL=infrab4a-connect.mjs.map
|