@infrab4a/connect 1.0.0-beta.17 → 1.0.0-beta.19
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 +76 -115
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +2 -2
- package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +1 -1
- package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +4 -6
- package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +16 -2
- package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +4 -3
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +3 -3
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +4 -3
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +10 -8
- package/esm2015/infra/index.js +1 -2
- package/fesm2015/infrab4a-connect.js +36 -58
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +1 -1
- package/infra/firebase/auth/register-firebase-auth.service.d.ts +1 -1
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +2 -2
- package/infra/index.d.ts +0 -1
- package/package.json +1 -1
- package/esm2015/infra/millenium/index.js +0 -2
- package/esm2015/infra/millenium/millenium.js +0 -42
- package/infra/millenium/index.d.ts +0 -1
- package/infra/millenium/millenium.d.ts +0 -25
|
@@ -8,7 +8,6 @@ export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, i
|
|
|
8
8
|
import { Md5 } from 'ts-md5';
|
|
9
9
|
import axios from 'axios';
|
|
10
10
|
import firebase from 'firebase';
|
|
11
|
-
import firebase$1 from 'firebase/app';
|
|
12
11
|
import { mutation, query } from 'gql-query-builder';
|
|
13
12
|
import fetch from 'node-fetch';
|
|
14
13
|
|
|
@@ -1776,7 +1775,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1776
1775
|
}
|
|
1777
1776
|
signInWithGoogle() {
|
|
1778
1777
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1779
|
-
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase
|
|
1778
|
+
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
|
|
1780
1779
|
const user = credentials.user;
|
|
1781
1780
|
return {
|
|
1782
1781
|
id: user.uid,
|
|
@@ -1898,9 +1897,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
|
|
|
1898
1897
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
1899
1898
|
var _a;
|
|
1900
1899
|
const data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
|
|
1901
|
-
return Object.keys(data)
|
|
1902
|
-
.filter((key) => !isNil(data[key]))
|
|
1903
|
-
.reduce((result, attributeName) => {
|
|
1900
|
+
return Object.keys(data).reduce((result, attributeName) => {
|
|
1904
1901
|
const { columnName, fields: attributeFields, foreignKeyColumn, to, bindPersistData, } = AttributeOptionHelper.FindByAttribute(attributeName, fields);
|
|
1905
1902
|
if (bindPersistData)
|
|
1906
1903
|
return Object.assign(Object.assign({}, result), bindPersistData(data[attributeName], instance));
|
|
@@ -1908,8 +1905,8 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
1908
1905
|
return result;
|
|
1909
1906
|
if (!!foreignKeyColumn &&
|
|
1910
1907
|
!isEmpty(foreignKeyColumn) &&
|
|
1911
|
-
!Object.keys(foreignKeyColumn).filter((key) => !data[attributeName][key]).length)
|
|
1912
|
-
return Object.keys(foreignKeyColumn).reduce((object, current) => (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: data[attributeName][current] })), Object.assign({}, result));
|
|
1908
|
+
!Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
1909
|
+
return Object.keys(foreignKeyColumn).reduce((object, current) => { var _a; return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] })); }, Object.assign({}, result));
|
|
1913
1910
|
if (update && isObject(data[attributeName]) && !isNil(attributeFields) && !isDate(data[attributeName]))
|
|
1914
1911
|
return result;
|
|
1915
1912
|
if (!!columnName && Array.isArray(attributeFields) && isObject(data[attributeName])) {
|
|
@@ -1962,7 +1959,21 @@ const withCreateHasuraGraphQL = (MixinBase) => {
|
|
|
1962
1959
|
}
|
|
1963
1960
|
save(data) {
|
|
1964
1961
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1965
|
-
const
|
|
1962
|
+
const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
|
|
1963
|
+
const foreignKeyColumns = this.fields
|
|
1964
|
+
.map((field) => {
|
|
1965
|
+
const columnOptions = Object.values(field).shift();
|
|
1966
|
+
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
1967
|
+
columnOptions.foreignKeyColumn && [
|
|
1968
|
+
...Object.values(columnOptions.foreignKeyColumn),
|
|
1969
|
+
{
|
|
1970
|
+
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn),
|
|
1971
|
+
},
|
|
1972
|
+
]);
|
|
1973
|
+
})
|
|
1974
|
+
.filter(Boolean)
|
|
1975
|
+
.reduce((keys, current) => [...keys, ...current], []);
|
|
1976
|
+
const result = yield this.mutation(this.insertGraphQLOperation, [...primaryKeyColumns, ...foreignKeyColumns], {
|
|
1966
1977
|
object: { type: this.insertGraphQLObjectType, required: true, value: this.convertDataToHasura(data) },
|
|
1967
1978
|
});
|
|
1968
1979
|
return Object.assign(Object.assign({}, data.toPlain()), this.convertDataFromHasura(result[this.insertGraphQLOperation]).toPlain());
|
|
@@ -2092,7 +2103,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2092
2103
|
return options.toPlain();
|
|
2093
2104
|
if (isNil(options.action))
|
|
2094
2105
|
return options;
|
|
2095
|
-
if (
|
|
2106
|
+
if ([UpdateOptionActions.REMOVE_FIELD.toString(), UpdateOptionActions.NULL.toString()].includes(options.action))
|
|
2096
2107
|
return null;
|
|
2097
2108
|
return options.value;
|
|
2098
2109
|
};
|
|
@@ -2122,7 +2133,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2122
2133
|
const model = this.model;
|
|
2123
2134
|
if (model.isModel(params))
|
|
2124
2135
|
return params.toPlain();
|
|
2125
|
-
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] && { [currentKey]: getValueByAction(params[currentKey]) }))), {});
|
|
2136
|
+
return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && { [currentKey]: getValueByAction(params[currentKey]) }))), {});
|
|
2126
2137
|
}
|
|
2127
2138
|
getUpdateModelKeys(data) {
|
|
2128
2139
|
const instance = this.model.toInstance(data);
|
|
@@ -2149,10 +2160,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
2149
2160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2150
2161
|
const instance = this.model.toInstance(identifiers);
|
|
2151
2162
|
const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2163
|
+
var _a;
|
|
2152
2164
|
if (isNil(instance[identifier]))
|
|
2153
2165
|
return ids;
|
|
2154
2166
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2155
|
-
const value = columnOption.to(identifiers[identifier.toString()], instance);
|
|
2167
|
+
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
|
|
2156
2168
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
|
|
2157
2169
|
type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
2158
2170
|
value,
|
|
@@ -2336,11 +2348,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2336
2348
|
conditions: {
|
|
2337
2349
|
columnName: 'tag_condition',
|
|
2338
2350
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
2339
|
-
from: (tags, row) => ({ brand: row.brand_condition, tags }),
|
|
2351
|
+
from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
|
|
2340
2352
|
bindPersistData: (value) => {
|
|
2353
|
+
var _a, _b;
|
|
2341
2354
|
return {
|
|
2342
2355
|
brand_condition: value.brand,
|
|
2343
|
-
tag_condition: `{"${value.tags.join('","')}"}`,
|
|
2356
|
+
tag_condition: `{"${((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || ''}"}`,
|
|
2344
2357
|
};
|
|
2345
2358
|
},
|
|
2346
2359
|
bindFindFilter: (sentence) => {
|
|
@@ -2435,8 +2448,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2435
2448
|
},
|
|
2436
2449
|
},
|
|
2437
2450
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
2438
|
-
{ images: { columnName: 'images', to: (value) => `{"${value.join(`","`)}"}
|
|
2439
|
-
{ miniatures: { columnName: 'miniatures', to: (value) => `{"${value.join(`","`)}"}
|
|
2451
|
+
{ images: { columnName: 'images', to: (value) => { var _a; return `{"${((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, `","`)) || ''}"}`; } } },
|
|
2452
|
+
{ miniatures: { columnName: 'miniatures', to: (value) => { var _a; return `{"${((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, `","`)) || ''}"}`; } } },
|
|
2440
2453
|
'name',
|
|
2441
2454
|
{
|
|
2442
2455
|
price: {
|
|
@@ -2449,15 +2462,17 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2449
2462
|
} })), {}),
|
|
2450
2463
|
bindFindFilter: (sentence) => {
|
|
2451
2464
|
const filters = Object.values(sentence).shift();
|
|
2452
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.price) && { price: filters.price })), (filters.fullPrice && { full_price: filters.fullPrice })), (filters.subscriberDiscountPercentage && {
|
|
2465
|
+
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) && {
|
|
2453
2466
|
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2454
|
-
})), (filters.subscriberPrice
|
|
2467
|
+
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
2468
|
+
subscriber_price: filters.subscriberPrice,
|
|
2469
|
+
}));
|
|
2455
2470
|
},
|
|
2456
2471
|
bindPersistData: (value) => {
|
|
2457
2472
|
const priceData = Object.values(value).shift();
|
|
2458
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) && { price: priceData.price })), (priceData.fullPrice && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage && {
|
|
2473
|
+
return 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 && {
|
|
2459
2474
|
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2460
|
-
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
2475
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
2461
2476
|
},
|
|
2462
2477
|
},
|
|
2463
2478
|
},
|
|
@@ -2596,7 +2611,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2596
2611
|
type: '[product_kit_insert_input!]',
|
|
2597
2612
|
required: true,
|
|
2598
2613
|
value: plainData.kitProducts.map((kitProduct) => ({
|
|
2599
|
-
kit_product_id: kitProduct.
|
|
2614
|
+
kit_product_id: kitProduct.productId || kitProduct.product.id,
|
|
2600
2615
|
product_id: productId,
|
|
2601
2616
|
quantity: kitProduct.quantity,
|
|
2602
2617
|
})),
|
|
@@ -2710,46 +2725,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2710
2725
|
}
|
|
2711
2726
|
}
|
|
2712
2727
|
|
|
2713
|
-
class MilleniumProduct extends BaseModel {
|
|
2714
|
-
static get identifiersFields() {
|
|
2715
|
-
return ['id'];
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
__decorate([
|
|
2719
|
-
Type(() => Product),
|
|
2720
|
-
__metadata("design:type", Product)
|
|
2721
|
-
], MilleniumProduct.prototype, "product", void 0);
|
|
2722
|
-
class MilleniumProductHasuraGraphQL extends MilleniumProduct {
|
|
2723
|
-
}
|
|
2724
|
-
__decorate([
|
|
2725
|
-
Type(() => ProductHasuraGraphQL),
|
|
2726
|
-
__metadata("design:type", ProductHasuraGraphQL)
|
|
2727
|
-
], MilleniumProductHasuraGraphQL.prototype, "product", void 0);
|
|
2728
|
-
class MilleniumProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2729
|
-
constructor(endpoint, authOptions, productRepository) {
|
|
2730
|
-
super({
|
|
2731
|
-
endpoint,
|
|
2732
|
-
authOptions,
|
|
2733
|
-
model: MilleniumProduct,
|
|
2734
|
-
tableName: 'product_milleniun',
|
|
2735
|
-
fields: [
|
|
2736
|
-
'id',
|
|
2737
|
-
{ productId: { columnName: 'product_id' } },
|
|
2738
|
-
{ codProduct: { columnName: 'cod_product' } },
|
|
2739
|
-
{ internalId: { columnName: 'internal_id' } },
|
|
2740
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2741
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2742
|
-
{
|
|
2743
|
-
product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: productRepository.fields },
|
|
2744
|
-
},
|
|
2745
|
-
],
|
|
2746
|
-
});
|
|
2747
|
-
}
|
|
2748
|
-
}
|
|
2749
|
-
|
|
2750
2728
|
/**
|
|
2751
2729
|
* Generated bundle index. Do not edit.
|
|
2752
2730
|
*/
|
|
2753
2731
|
|
|
2754
|
-
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, FinancialCoupon, FragranceImportances, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem,
|
|
2732
|
+
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, FinancialCoupon, FragranceImportances, 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, UserSearchFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
2755
2733
|
//# sourceMappingURL=infrab4a-connect.js.map
|