@infrab4a/connect 1.0.0-beta.16 → 1.0.0-beta.18
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 +254 -142
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/index.d.ts +3 -2
- package/domain/catalog/models/kit-product.d.ts +12 -0
- package/domain/catalog/models/product.d.ts +3 -0
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
- package/esm2015/domain/catalog/models/index.js +4 -3
- package/esm2015/domain/catalog/models/kit-product.js +18 -0
- package/esm2015/domain/catalog/models/product.js +8 -1
- package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +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/index.js +3 -2
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +2 -3
- package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +8 -10
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +3 -3
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +6 -3
- package/esm2015/infra/hasura-graphql/models/index.js +2 -1
- package/esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js +15 -0
- package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +8 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +109 -68
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +177 -104
- 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/index.d.ts +2 -1
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +1 -5
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/models/index.d.ts +1 -0
- package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +6 -0
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +2 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +1 -0
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +8 -14
- package/package.json +1 -1
|
@@ -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
|
|
|
@@ -730,13 +729,6 @@ class RecoveryPassword {
|
|
|
730
729
|
}
|
|
731
730
|
}
|
|
732
731
|
|
|
733
|
-
var Shops;
|
|
734
|
-
(function (Shops) {
|
|
735
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
736
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
737
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
738
|
-
})(Shops || (Shops = {}));
|
|
739
|
-
|
|
740
732
|
class Category extends BaseModel {
|
|
741
733
|
identifierFields() {
|
|
742
734
|
return ['id'];
|
|
@@ -746,6 +738,13 @@ class Category extends BaseModel {
|
|
|
746
738
|
}
|
|
747
739
|
}
|
|
748
740
|
|
|
741
|
+
var Shops;
|
|
742
|
+
(function (Shops) {
|
|
743
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
744
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
745
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
746
|
+
})(Shops || (Shops = {}));
|
|
747
|
+
|
|
749
748
|
class Product extends BaseModel {
|
|
750
749
|
identifierFields() {
|
|
751
750
|
return ['id'];
|
|
@@ -758,6 +757,24 @@ class Product extends BaseModel {
|
|
|
758
757
|
return ['id'];
|
|
759
758
|
}
|
|
760
759
|
}
|
|
760
|
+
__decorate([
|
|
761
|
+
Type(() => KitProduct),
|
|
762
|
+
__metadata("design:type", Array)
|
|
763
|
+
], Product.prototype, "kitProducts", void 0);
|
|
764
|
+
|
|
765
|
+
class KitProduct extends BaseModel {
|
|
766
|
+
static get identifiersFields() {
|
|
767
|
+
return ['productId', 'kitProducId'];
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
__decorate([
|
|
771
|
+
Type(() => Product),
|
|
772
|
+
__metadata("design:type", Product)
|
|
773
|
+
], KitProduct.prototype, "kit", void 0);
|
|
774
|
+
__decorate([
|
|
775
|
+
Type(() => Product),
|
|
776
|
+
__metadata("design:type", Product)
|
|
777
|
+
], KitProduct.prototype, "product", void 0);
|
|
761
778
|
|
|
762
779
|
class Variant extends BaseModel {
|
|
763
780
|
identifierFields() {
|
|
@@ -1758,7 +1775,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1758
1775
|
}
|
|
1759
1776
|
signInWithGoogle() {
|
|
1760
1777
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1761
|
-
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase
|
|
1778
|
+
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
|
|
1762
1779
|
const user = credentials.user;
|
|
1763
1780
|
return {
|
|
1764
1781
|
id: user.uid,
|
|
@@ -1826,8 +1843,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
|
1826
1843
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
1827
1844
|
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
1828
1845
|
};
|
|
1829
|
-
AttributeOptionHelper.
|
|
1830
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => AttributeOptionHelper.CheckIsColumnModelOption(fieldValue) || !!fieldValue.columnName;
|
|
1846
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
1831
1847
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
1832
1848
|
if (fields.includes(columnName))
|
|
1833
1849
|
return { columnName, attributeName: columnName };
|
|
@@ -1848,23 +1864,21 @@ class GraphQLFieldHelper {
|
|
|
1848
1864
|
}
|
|
1849
1865
|
GraphQLFieldHelper.CheckIsGraphQLParams = (params) => !isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation;
|
|
1850
1866
|
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
1851
|
-
return fields
|
|
1852
|
-
.map((field) => {
|
|
1867
|
+
return fields === null || fields === void 0 ? void 0 : fields.map((field) => {
|
|
1853
1868
|
if (isString(field))
|
|
1854
1869
|
return field.toString();
|
|
1855
1870
|
const fieldName = Object.keys(field).shift();
|
|
1856
1871
|
const fieldValue = field[fieldName];
|
|
1857
1872
|
if (Array.isArray(fieldValue))
|
|
1858
1873
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
1859
|
-
if (AttributeOptionHelper.
|
|
1874
|
+
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
1875
|
+
return;
|
|
1876
|
+
if (fieldValue.fields)
|
|
1860
1877
|
return {
|
|
1861
1878
|
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
1862
1879
|
};
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
return;
|
|
1866
|
-
})
|
|
1867
|
-
.filter((field) => !!field);
|
|
1880
|
+
return fieldValue.columnName;
|
|
1881
|
+
}).filter((field) => !!field);
|
|
1868
1882
|
};
|
|
1869
1883
|
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
1870
1884
|
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
@@ -1902,7 +1916,7 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
1902
1916
|
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
1903
1917
|
? {
|
|
1904
1918
|
[columnName]: {
|
|
1905
|
-
data:
|
|
1919
|
+
data: instance[attributeName] instanceof BaseModel
|
|
1906
1920
|
? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
|
|
1907
1921
|
: converted,
|
|
1908
1922
|
},
|
|
@@ -2073,6 +2087,8 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2073
2087
|
|
|
2074
2088
|
const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
2075
2089
|
const getValueByAction = (options) => {
|
|
2090
|
+
if (options instanceof BaseModel)
|
|
2091
|
+
return options.toPlain();
|
|
2076
2092
|
if (isNil(options.action))
|
|
2077
2093
|
return options;
|
|
2078
2094
|
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
@@ -2110,10 +2126,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2110
2126
|
getUpdateModelKeys(data) {
|
|
2111
2127
|
const instance = this.model.toInstance(data);
|
|
2112
2128
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2129
|
+
var _a;
|
|
2113
2130
|
if (isNil(instance[identifier]))
|
|
2114
2131
|
return ids;
|
|
2115
2132
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2116
|
-
const value = columnOption.to(data[identifier.toString()], instance);
|
|
2133
|
+
const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier.toString()], instance)) || data[columnOption.attributeName];
|
|
2117
2134
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2118
2135
|
}, {});
|
|
2119
2136
|
}
|
|
@@ -2197,7 +2214,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2197
2214
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2198
2215
|
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
2199
2216
|
return Object.keys(options).reduce((variables, key) => {
|
|
2200
|
-
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fields);
|
|
2217
|
+
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2201
2218
|
const columnName = fieldOptions.columnName;
|
|
2202
2219
|
const columnFields = fieldOptions.fields;
|
|
2203
2220
|
return Object.assign(Object.assign({}, variables), { [columnName]: this.buildWhereSentence(key, options[key], columnFields || []) });
|
|
@@ -2264,6 +2281,35 @@ const withCrudHasuraGraphQL = (MixinBase) => {
|
|
|
2264
2281
|
};
|
|
2265
2282
|
};
|
|
2266
2283
|
|
|
2284
|
+
class CategoryHasuraGraphQL extends Category {
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
class ProductHasuraGraphQL extends Product {
|
|
2288
|
+
}
|
|
2289
|
+
__decorate([
|
|
2290
|
+
Type(() => KitProductHasuraGraphQL),
|
|
2291
|
+
__metadata("design:type", Array)
|
|
2292
|
+
], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
|
|
2293
|
+
|
|
2294
|
+
class KitProductHasuraGraphQL extends KitProduct {
|
|
2295
|
+
}
|
|
2296
|
+
__decorate([
|
|
2297
|
+
Type(() => ProductHasuraGraphQL),
|
|
2298
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
2299
|
+
], KitProductHasuraGraphQL.prototype, "kit", void 0);
|
|
2300
|
+
__decorate([
|
|
2301
|
+
Type(() => ProductHasuraGraphQL),
|
|
2302
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
2303
|
+
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
2304
|
+
|
|
2305
|
+
class VariantHasuraGraphQL extends Variant {
|
|
2306
|
+
constructor() {
|
|
2307
|
+
super(...arguments);
|
|
2308
|
+
this.name = '';
|
|
2309
|
+
this.hasVariants = false;
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
|
|
2267
2313
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2268
2314
|
constructor(endpoint, authOptions, productRepository) {
|
|
2269
2315
|
super({
|
|
@@ -2370,86 +2416,87 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2370
2416
|
}
|
|
2371
2417
|
}
|
|
2372
2418
|
|
|
2373
|
-
class CategoryHasuraGraphQL extends Category {
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
class ProductHasuraGraphQL extends Product {
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
class VariantHasuraGraphQL extends Variant {
|
|
2380
|
-
constructor() {
|
|
2381
|
-
super(...arguments);
|
|
2382
|
-
this.name = '';
|
|
2383
|
-
this.hasVariants = false;
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
|
|
2387
2419
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2388
2420
|
constructor(endpoint, authOptions) {
|
|
2421
|
+
const commonFields = [
|
|
2422
|
+
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2423
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
2424
|
+
{ CEST: { columnName: 'cest' } },
|
|
2425
|
+
{ EAN: { columnName: 'ean' } },
|
|
2426
|
+
{ NCM: { columnName: 'ncm' } },
|
|
2427
|
+
'brand',
|
|
2428
|
+
{ costPrice: { columnName: 'cost_price' } },
|
|
2429
|
+
{
|
|
2430
|
+
description: {
|
|
2431
|
+
columnName: 'description',
|
|
2432
|
+
from: (description) => Object.values(Shops).reduce((shops, shop) => (Object.assign(Object.assign({}, shops), { [shop]: { description } })), {}),
|
|
2433
|
+
to: (value) => Object.values(value).shift().description,
|
|
2434
|
+
},
|
|
2435
|
+
},
|
|
2436
|
+
{ hasVariants: { columnName: 'has_variants' } },
|
|
2437
|
+
{ images: { columnName: 'images', to: (value) => `{"${value.join(`","`)}"}` } },
|
|
2438
|
+
{ miniatures: { columnName: 'miniatures', to: (value) => `{"${value.join(`","`)}"}` } },
|
|
2439
|
+
'name',
|
|
2440
|
+
{
|
|
2441
|
+
price: {
|
|
2442
|
+
columnName: 'price',
|
|
2443
|
+
from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
|
|
2444
|
+
price,
|
|
2445
|
+
fullPrice: data.full_price,
|
|
2446
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2447
|
+
subscriberPrice: data.subscriber_price,
|
|
2448
|
+
} })), {}),
|
|
2449
|
+
bindFindFilter: (sentence) => {
|
|
2450
|
+
const filters = Object.values(sentence).shift();
|
|
2451
|
+
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 && {
|
|
2452
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2453
|
+
})), (filters.subscriberPrice && { subscriber_price: filters.subscriberPrice }));
|
|
2454
|
+
},
|
|
2455
|
+
bindPersistData: (value) => {
|
|
2456
|
+
const priceData = Object.values(value).shift();
|
|
2457
|
+
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 && {
|
|
2458
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2459
|
+
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
2460
|
+
},
|
|
2461
|
+
},
|
|
2462
|
+
},
|
|
2463
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
2464
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
2465
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
2466
|
+
'published',
|
|
2467
|
+
{ publishedGlam: { columnName: 'published_glam' } },
|
|
2468
|
+
'sku',
|
|
2469
|
+
{
|
|
2470
|
+
stock: {
|
|
2471
|
+
columnName: 'stock',
|
|
2472
|
+
from: (quantity) => ({ quantity }),
|
|
2473
|
+
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2474
|
+
},
|
|
2475
|
+
},
|
|
2476
|
+
'slug',
|
|
2477
|
+
'type',
|
|
2478
|
+
'video',
|
|
2479
|
+
'weight',
|
|
2480
|
+
{
|
|
2481
|
+
shopAvailability: {
|
|
2482
|
+
columnName: 'shop_availabilities',
|
|
2483
|
+
fields: ['shop'],
|
|
2484
|
+
from: (shop) => (Array.isArray(shop) ? shop.map((row) => row.shop) : []),
|
|
2485
|
+
to: (shops) => shops.map((shop) => ({ shop })),
|
|
2486
|
+
},
|
|
2487
|
+
},
|
|
2488
|
+
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2489
|
+
{ isKit: { columnName: 'is_kit' } },
|
|
2490
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2491
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2492
|
+
];
|
|
2389
2493
|
super({
|
|
2390
2494
|
tableName: 'product',
|
|
2391
2495
|
model: ProductHasuraGraphQL,
|
|
2392
2496
|
endpoint,
|
|
2393
2497
|
authOptions,
|
|
2394
2498
|
fields: [
|
|
2395
|
-
|
|
2396
|
-
{ firestoreId: { columnName: 'firestore_id' } },
|
|
2397
|
-
{ CEST: { columnName: 'cest' } },
|
|
2398
|
-
{ EAN: { columnName: 'ean' } },
|
|
2399
|
-
{ NCM: { columnName: 'ncm' } },
|
|
2400
|
-
'brand',
|
|
2401
|
-
{ costPrice: { columnName: 'cost_price' } },
|
|
2402
|
-
{
|
|
2403
|
-
description: {
|
|
2404
|
-
columnName: 'description',
|
|
2405
|
-
from: (description) => Object.values(Shops).reduce((shops, shop) => (Object.assign(Object.assign({}, shops), { [shop]: { description } })), {}),
|
|
2406
|
-
to: (value) => Object.values(value).shift().description,
|
|
2407
|
-
},
|
|
2408
|
-
},
|
|
2409
|
-
{ hasVariants: { columnName: 'has_variants' } },
|
|
2410
|
-
{ images: { columnName: 'images', to: (value) => `{"${value.join(`","`)}"}` } },
|
|
2411
|
-
{ miniatures: { columnName: 'miniatures', to: (value) => `{"${value.join(`","`)}"}` } },
|
|
2412
|
-
'name',
|
|
2413
|
-
{
|
|
2414
|
-
price: {
|
|
2415
|
-
columnName: 'price',
|
|
2416
|
-
from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
|
|
2417
|
-
price,
|
|
2418
|
-
fullPrice: data.full_price,
|
|
2419
|
-
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2420
|
-
subscriberPrice: data.subscriber_price,
|
|
2421
|
-
} })), {}),
|
|
2422
|
-
bindFindFilter: (sentence) => {
|
|
2423
|
-
const filters = Object.values(sentence).shift();
|
|
2424
|
-
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 && {
|
|
2425
|
-
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2426
|
-
})), (filters.subscriberPrice && { subscriber_price: filters.subscriberPrice }));
|
|
2427
|
-
},
|
|
2428
|
-
bindPersistData: (value) => {
|
|
2429
|
-
const priceData = Object.values(value).shift();
|
|
2430
|
-
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 && {
|
|
2431
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2432
|
-
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
2433
|
-
},
|
|
2434
|
-
},
|
|
2435
|
-
},
|
|
2436
|
-
{ fullPrice: { columnName: 'full_price' } },
|
|
2437
|
-
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
2438
|
-
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
2439
|
-
'published',
|
|
2440
|
-
{ publishedGlam: { columnName: 'published_glam' } },
|
|
2441
|
-
'sku',
|
|
2442
|
-
{
|
|
2443
|
-
stock: {
|
|
2444
|
-
columnName: 'stock',
|
|
2445
|
-
from: (quantity) => ({ quantity }),
|
|
2446
|
-
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2447
|
-
},
|
|
2448
|
-
},
|
|
2449
|
-
'slug',
|
|
2450
|
-
'type',
|
|
2451
|
-
'video',
|
|
2452
|
-
'weight',
|
|
2499
|
+
...commonFields,
|
|
2453
2500
|
{
|
|
2454
2501
|
categories: {
|
|
2455
2502
|
columnName: 'categories',
|
|
@@ -2462,16 +2509,17 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2462
2509
|
},
|
|
2463
2510
|
},
|
|
2464
2511
|
{
|
|
2465
|
-
|
|
2466
|
-
columnName: '
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2512
|
+
kitProducts: {
|
|
2513
|
+
columnName: 'kit_products',
|
|
2514
|
+
foreignKeyColumn: { productId: 'id' },
|
|
2515
|
+
fields: [
|
|
2516
|
+
{ productId: { columnName: 'product_id' } },
|
|
2517
|
+
{ kitProductId: { columnName: 'kit_product_id' } },
|
|
2518
|
+
'quantity',
|
|
2519
|
+
{ product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
|
|
2520
|
+
],
|
|
2470
2521
|
},
|
|
2471
2522
|
},
|
|
2472
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2473
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2474
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2475
2523
|
],
|
|
2476
2524
|
});
|
|
2477
2525
|
}
|
|
@@ -2503,11 +2551,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2503
2551
|
update: { get: () => super.update }
|
|
2504
2552
|
});
|
|
2505
2553
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2506
|
-
const { categories, id: checkId } = params, data = __rest(params, ["categories", "id"]);
|
|
2554
|
+
const { categories, kitProducts, id: checkId } = params, data = __rest(params, ["categories", "kitProducts", "id"]);
|
|
2507
2555
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2508
2556
|
const id = yield this.getId(plainData.id);
|
|
2509
2557
|
const product = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2510
2558
|
product.categories = categories && (yield this.updateCategories(+id, { categories }));
|
|
2559
|
+
product.kitProducts = kitProducts && (yield this.updateKitProducts(+id, { kitProducts }));
|
|
2511
2560
|
return product;
|
|
2512
2561
|
});
|
|
2513
2562
|
}
|
|
@@ -2531,6 +2580,30 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2531
2580
|
return plainData.categories;
|
|
2532
2581
|
});
|
|
2533
2582
|
}
|
|
2583
|
+
updateKitProducts(productId, { kitProducts }) {
|
|
2584
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2585
|
+
const plainData = this.paramsToPlain({ kitProducts });
|
|
2586
|
+
yield this.mutation('delete_product_kit', ['affected_rows'], {
|
|
2587
|
+
where: {
|
|
2588
|
+
type: 'product_kit_bool_exp',
|
|
2589
|
+
required: true,
|
|
2590
|
+
value: { product_id: { _eq: productId } },
|
|
2591
|
+
},
|
|
2592
|
+
});
|
|
2593
|
+
yield this.mutation('insert_product_kit', ['affected_rows'], {
|
|
2594
|
+
objects: {
|
|
2595
|
+
type: '[product_kit_insert_input!]',
|
|
2596
|
+
required: true,
|
|
2597
|
+
value: plainData.kitProducts.map((kitProduct) => ({
|
|
2598
|
+
kit_product_id: kitProduct.kitProductId,
|
|
2599
|
+
product_id: productId,
|
|
2600
|
+
quantity: kitProduct.quantity,
|
|
2601
|
+
})),
|
|
2602
|
+
},
|
|
2603
|
+
});
|
|
2604
|
+
return plainData.kitProducts;
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2534
2607
|
getId(id) {
|
|
2535
2608
|
var _a, _b;
|
|
2536
2609
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2640,5 +2713,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2640
2713
|
* Generated bundle index. Do not edit.
|
|
2641
2714
|
*/
|
|
2642
2715
|
|
|
2643
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, 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, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, 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, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
2716
|
+
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 };
|
|
2644
2717
|
//# sourceMappingURL=infrab4a-connect.js.map
|