@infrab4a/connect 1.0.0-beta.15 → 1.0.0-beta.17
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 +307 -138
- 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/firestore/mixins/with-find-firestore.mixin.js +2 -2
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +2 -3
- 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-create-hasura-graphql.mixin.js +1 -1
- 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/esm2015/infra/index.js +2 -1
- package/esm2015/infra/millenium/index.js +2 -0
- package/esm2015/infra/millenium/millenium.js +42 -0
- package/fesm2015/infrab4a-connect.js +215 -104
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +1 -1
- package/infra/firebase/firestore/mixins/with-firestore.mixin.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-create-hasura-graphql.mixin.d.ts +1 -1
- 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/infra/index.d.ts +1 -0
- package/infra/millenium/index.d.ts +1 -0
- package/infra/millenium/millenium.d.ts +25 -0
- package/package.json +1 -1
|
@@ -730,13 +730,6 @@ class RecoveryPassword {
|
|
|
730
730
|
}
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
var Shops;
|
|
734
|
-
(function (Shops) {
|
|
735
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
736
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
737
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
738
|
-
})(Shops || (Shops = {}));
|
|
739
|
-
|
|
740
733
|
class Category extends BaseModel {
|
|
741
734
|
identifierFields() {
|
|
742
735
|
return ['id'];
|
|
@@ -746,6 +739,13 @@ class Category extends BaseModel {
|
|
|
746
739
|
}
|
|
747
740
|
}
|
|
748
741
|
|
|
742
|
+
var Shops;
|
|
743
|
+
(function (Shops) {
|
|
744
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
745
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
746
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
747
|
+
})(Shops || (Shops = {}));
|
|
748
|
+
|
|
749
749
|
class Product extends BaseModel {
|
|
750
750
|
identifierFields() {
|
|
751
751
|
return ['id'];
|
|
@@ -758,6 +758,24 @@ class Product extends BaseModel {
|
|
|
758
758
|
return ['id'];
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
|
+
__decorate([
|
|
762
|
+
Type(() => KitProduct),
|
|
763
|
+
__metadata("design:type", Array)
|
|
764
|
+
], Product.prototype, "kitProducts", void 0);
|
|
765
|
+
|
|
766
|
+
class KitProduct extends BaseModel {
|
|
767
|
+
static get identifiersFields() {
|
|
768
|
+
return ['productId', 'kitProducId'];
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
__decorate([
|
|
772
|
+
Type(() => Product),
|
|
773
|
+
__metadata("design:type", Product)
|
|
774
|
+
], KitProduct.prototype, "kit", void 0);
|
|
775
|
+
__decorate([
|
|
776
|
+
Type(() => Product),
|
|
777
|
+
__metadata("design:type", Product)
|
|
778
|
+
], KitProduct.prototype, "product", void 0);
|
|
761
779
|
|
|
762
780
|
class Variant extends BaseModel {
|
|
763
781
|
identifierFields() {
|
|
@@ -1097,7 +1115,7 @@ const withFirestore = (MixinBase) => {
|
|
|
1097
1115
|
fromFirestore: (snap) => {
|
|
1098
1116
|
const data = snap.data();
|
|
1099
1117
|
Object.keys(data).forEach((key) => {
|
|
1100
|
-
if (data[key]
|
|
1118
|
+
if (typeof data[key] === 'object' && '_seconds' in data[key]) {
|
|
1101
1119
|
data[key] = data[key].toDate();
|
|
1102
1120
|
}
|
|
1103
1121
|
});
|
|
@@ -1186,7 +1204,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1186
1204
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1187
1205
|
let query = this.collection(this.buildCollectionPathForFind(filters));
|
|
1188
1206
|
query = this.makeFirestoreWhere(query, filters);
|
|
1189
|
-
Object.keys(orderBy).forEach((fieldName) => (query = query.orderBy(fieldName, orderBy[fieldName])));
|
|
1207
|
+
Object.keys(orderBy || {}).forEach((fieldName) => (query = query.orderBy(fieldName, orderBy[fieldName])));
|
|
1190
1208
|
query = yield this.defineLimits(query, filters, limits);
|
|
1191
1209
|
const docs = yield query.get();
|
|
1192
1210
|
const data = docs.docs.map((doc) => doc.data());
|
|
@@ -1826,8 +1844,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
|
1826
1844
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
1827
1845
|
return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
1828
1846
|
};
|
|
1829
|
-
AttributeOptionHelper.
|
|
1830
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => AttributeOptionHelper.CheckIsColumnModelOption(fieldValue) || !!fieldValue.columnName;
|
|
1847
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
|
|
1831
1848
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
1832
1849
|
if (fields.includes(columnName))
|
|
1833
1850
|
return { columnName, attributeName: columnName };
|
|
@@ -1848,23 +1865,21 @@ class GraphQLFieldHelper {
|
|
|
1848
1865
|
}
|
|
1849
1866
|
GraphQLFieldHelper.CheckIsGraphQLParams = (params) => !isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation;
|
|
1850
1867
|
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
1851
|
-
return fields
|
|
1852
|
-
.map((field) => {
|
|
1868
|
+
return fields === null || fields === void 0 ? void 0 : fields.map((field) => {
|
|
1853
1869
|
if (isString(field))
|
|
1854
1870
|
return field.toString();
|
|
1855
1871
|
const fieldName = Object.keys(field).shift();
|
|
1856
1872
|
const fieldValue = field[fieldName];
|
|
1857
1873
|
if (Array.isArray(fieldValue))
|
|
1858
1874
|
return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
|
|
1859
|
-
if (AttributeOptionHelper.
|
|
1875
|
+
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
1876
|
+
return;
|
|
1877
|
+
if (fieldValue.fields)
|
|
1860
1878
|
return {
|
|
1861
1879
|
[fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
1862
1880
|
};
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
return;
|
|
1866
|
-
})
|
|
1867
|
-
.filter((field) => !!field);
|
|
1881
|
+
return fieldValue.columnName;
|
|
1882
|
+
}).filter((field) => !!field);
|
|
1868
1883
|
};
|
|
1869
1884
|
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
1870
1885
|
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
@@ -1902,7 +1917,7 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
1902
1917
|
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
1903
1918
|
? {
|
|
1904
1919
|
[columnName]: {
|
|
1905
|
-
data:
|
|
1920
|
+
data: instance[attributeName] instanceof BaseModel
|
|
1906
1921
|
? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
|
|
1907
1922
|
: converted,
|
|
1908
1923
|
},
|
|
@@ -2073,6 +2088,8 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
2073
2088
|
|
|
2074
2089
|
const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
2075
2090
|
const getValueByAction = (options) => {
|
|
2091
|
+
if (options instanceof BaseModel)
|
|
2092
|
+
return options.toPlain();
|
|
2076
2093
|
if (isNil(options.action))
|
|
2077
2094
|
return options;
|
|
2078
2095
|
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
@@ -2110,10 +2127,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
|
|
|
2110
2127
|
getUpdateModelKeys(data) {
|
|
2111
2128
|
const instance = this.model.toInstance(data);
|
|
2112
2129
|
return this.model.identifiersFields.reduce((ids, identifier) => {
|
|
2130
|
+
var _a;
|
|
2113
2131
|
if (isNil(instance[identifier]))
|
|
2114
2132
|
return ids;
|
|
2115
2133
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
|
|
2116
|
-
const value = columnOption.to(data[identifier.toString()], instance);
|
|
2134
|
+
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
2135
|
return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
|
|
2118
2136
|
}, {});
|
|
2119
2137
|
}
|
|
@@ -2197,7 +2215,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2197
2215
|
isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
2198
2216
|
isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
2199
2217
|
return Object.keys(options).reduce((variables, key) => {
|
|
2200
|
-
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fields);
|
|
2218
|
+
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2201
2219
|
const columnName = fieldOptions.columnName;
|
|
2202
2220
|
const columnFields = fieldOptions.fields;
|
|
2203
2221
|
return Object.assign(Object.assign({}, variables), { [columnName]: this.buildWhereSentence(key, options[key], columnFields || []) });
|
|
@@ -2264,6 +2282,35 @@ const withCrudHasuraGraphQL = (MixinBase) => {
|
|
|
2264
2282
|
};
|
|
2265
2283
|
};
|
|
2266
2284
|
|
|
2285
|
+
class CategoryHasuraGraphQL extends Category {
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
class ProductHasuraGraphQL extends Product {
|
|
2289
|
+
}
|
|
2290
|
+
__decorate([
|
|
2291
|
+
Type(() => KitProductHasuraGraphQL),
|
|
2292
|
+
__metadata("design:type", Array)
|
|
2293
|
+
], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
|
|
2294
|
+
|
|
2295
|
+
class KitProductHasuraGraphQL extends KitProduct {
|
|
2296
|
+
}
|
|
2297
|
+
__decorate([
|
|
2298
|
+
Type(() => ProductHasuraGraphQL),
|
|
2299
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
2300
|
+
], KitProductHasuraGraphQL.prototype, "kit", void 0);
|
|
2301
|
+
__decorate([
|
|
2302
|
+
Type(() => ProductHasuraGraphQL),
|
|
2303
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
2304
|
+
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
2305
|
+
|
|
2306
|
+
class VariantHasuraGraphQL extends Variant {
|
|
2307
|
+
constructor() {
|
|
2308
|
+
super(...arguments);
|
|
2309
|
+
this.name = '';
|
|
2310
|
+
this.hasVariants = false;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2267
2314
|
class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2268
2315
|
constructor(endpoint, authOptions, productRepository) {
|
|
2269
2316
|
super({
|
|
@@ -2370,86 +2417,87 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2370
2417
|
}
|
|
2371
2418
|
}
|
|
2372
2419
|
|
|
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
2420
|
class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
2388
2421
|
constructor(endpoint, authOptions) {
|
|
2422
|
+
const commonFields = [
|
|
2423
|
+
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
2424
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
2425
|
+
{ CEST: { columnName: 'cest' } },
|
|
2426
|
+
{ EAN: { columnName: 'ean' } },
|
|
2427
|
+
{ NCM: { columnName: 'ncm' } },
|
|
2428
|
+
'brand',
|
|
2429
|
+
{ costPrice: { columnName: 'cost_price' } },
|
|
2430
|
+
{
|
|
2431
|
+
description: {
|
|
2432
|
+
columnName: 'description',
|
|
2433
|
+
from: (description) => Object.values(Shops).reduce((shops, shop) => (Object.assign(Object.assign({}, shops), { [shop]: { description } })), {}),
|
|
2434
|
+
to: (value) => Object.values(value).shift().description,
|
|
2435
|
+
},
|
|
2436
|
+
},
|
|
2437
|
+
{ hasVariants: { columnName: 'has_variants' } },
|
|
2438
|
+
{ images: { columnName: 'images', to: (value) => `{"${value.join(`","`)}"}` } },
|
|
2439
|
+
{ miniatures: { columnName: 'miniatures', to: (value) => `{"${value.join(`","`)}"}` } },
|
|
2440
|
+
'name',
|
|
2441
|
+
{
|
|
2442
|
+
price: {
|
|
2443
|
+
columnName: 'price',
|
|
2444
|
+
from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
|
|
2445
|
+
price,
|
|
2446
|
+
fullPrice: data.full_price,
|
|
2447
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
2448
|
+
subscriberPrice: data.subscriber_price,
|
|
2449
|
+
} })), {}),
|
|
2450
|
+
bindFindFilter: (sentence) => {
|
|
2451
|
+
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 && {
|
|
2453
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
2454
|
+
})), (filters.subscriberPrice && { subscriber_price: filters.subscriberPrice }));
|
|
2455
|
+
},
|
|
2456
|
+
bindPersistData: (value) => {
|
|
2457
|
+
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 && {
|
|
2459
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
2460
|
+
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
2461
|
+
},
|
|
2462
|
+
},
|
|
2463
|
+
},
|
|
2464
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
2465
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
2466
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
2467
|
+
'published',
|
|
2468
|
+
{ publishedGlam: { columnName: 'published_glam' } },
|
|
2469
|
+
'sku',
|
|
2470
|
+
{
|
|
2471
|
+
stock: {
|
|
2472
|
+
columnName: 'stock',
|
|
2473
|
+
from: (quantity) => ({ quantity }),
|
|
2474
|
+
to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
|
|
2475
|
+
},
|
|
2476
|
+
},
|
|
2477
|
+
'slug',
|
|
2478
|
+
'type',
|
|
2479
|
+
'video',
|
|
2480
|
+
'weight',
|
|
2481
|
+
{
|
|
2482
|
+
shopAvailability: {
|
|
2483
|
+
columnName: 'shop_availabilities',
|
|
2484
|
+
fields: ['shop'],
|
|
2485
|
+
from: (shop) => (Array.isArray(shop) ? shop.map((row) => row.shop) : []),
|
|
2486
|
+
to: (shops) => shops.map((shop) => ({ shop })),
|
|
2487
|
+
},
|
|
2488
|
+
},
|
|
2489
|
+
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2490
|
+
{ isKit: { columnName: 'is_kit' } },
|
|
2491
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
2492
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
2493
|
+
];
|
|
2389
2494
|
super({
|
|
2390
2495
|
tableName: 'product',
|
|
2391
2496
|
model: ProductHasuraGraphQL,
|
|
2392
2497
|
endpoint,
|
|
2393
2498
|
authOptions,
|
|
2394
2499
|
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',
|
|
2500
|
+
...commonFields,
|
|
2453
2501
|
{
|
|
2454
2502
|
categories: {
|
|
2455
2503
|
columnName: 'categories',
|
|
@@ -2462,16 +2510,17 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2462
2510
|
},
|
|
2463
2511
|
},
|
|
2464
2512
|
{
|
|
2465
|
-
|
|
2466
|
-
columnName: '
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2513
|
+
kitProducts: {
|
|
2514
|
+
columnName: 'kit_products',
|
|
2515
|
+
foreignKeyColumn: { productId: 'id' },
|
|
2516
|
+
fields: [
|
|
2517
|
+
{ productId: { columnName: 'product_id' } },
|
|
2518
|
+
{ kitProductId: { columnName: 'kit_product_id' } },
|
|
2519
|
+
'quantity',
|
|
2520
|
+
{ product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
|
|
2521
|
+
],
|
|
2470
2522
|
},
|
|
2471
2523
|
},
|
|
2472
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
2473
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
2474
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
2475
2524
|
],
|
|
2476
2525
|
});
|
|
2477
2526
|
}
|
|
@@ -2503,11 +2552,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2503
2552
|
update: { get: () => super.update }
|
|
2504
2553
|
});
|
|
2505
2554
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2506
|
-
const { categories, id: checkId } = params, data = __rest(params, ["categories", "id"]);
|
|
2555
|
+
const { categories, kitProducts, id: checkId } = params, data = __rest(params, ["categories", "kitProducts", "id"]);
|
|
2507
2556
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
2508
2557
|
const id = yield this.getId(plainData.id);
|
|
2509
2558
|
const product = yield _super.update.call(this, Object.assign({ id }, data));
|
|
2510
2559
|
product.categories = categories && (yield this.updateCategories(+id, { categories }));
|
|
2560
|
+
product.kitProducts = kitProducts && (yield this.updateKitProducts(+id, { kitProducts }));
|
|
2511
2561
|
return product;
|
|
2512
2562
|
});
|
|
2513
2563
|
}
|
|
@@ -2531,6 +2581,30 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2531
2581
|
return plainData.categories;
|
|
2532
2582
|
});
|
|
2533
2583
|
}
|
|
2584
|
+
updateKitProducts(productId, { kitProducts }) {
|
|
2585
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2586
|
+
const plainData = this.paramsToPlain({ kitProducts });
|
|
2587
|
+
yield this.mutation('delete_product_kit', ['affected_rows'], {
|
|
2588
|
+
where: {
|
|
2589
|
+
type: 'product_kit_bool_exp',
|
|
2590
|
+
required: true,
|
|
2591
|
+
value: { product_id: { _eq: productId } },
|
|
2592
|
+
},
|
|
2593
|
+
});
|
|
2594
|
+
yield this.mutation('insert_product_kit', ['affected_rows'], {
|
|
2595
|
+
objects: {
|
|
2596
|
+
type: '[product_kit_insert_input!]',
|
|
2597
|
+
required: true,
|
|
2598
|
+
value: plainData.kitProducts.map((kitProduct) => ({
|
|
2599
|
+
kit_product_id: kitProduct.kitProductId,
|
|
2600
|
+
product_id: productId,
|
|
2601
|
+
quantity: kitProduct.quantity,
|
|
2602
|
+
})),
|
|
2603
|
+
},
|
|
2604
|
+
});
|
|
2605
|
+
return plainData.kitProducts;
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2534
2608
|
getId(id) {
|
|
2535
2609
|
var _a, _b;
|
|
2536
2610
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2636,9 +2710,46 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2636
2710
|
}
|
|
2637
2711
|
}
|
|
2638
2712
|
|
|
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
|
+
|
|
2639
2750
|
/**
|
|
2640
2751
|
* Generated bundle index. Do not edit.
|
|
2641
2752
|
*/
|
|
2642
2753
|
|
|
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 };
|
|
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, MilleniumProduct, MilleniumProductHasuraGraphQL, MilleniumProductHasuraGraphQLRepository, 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
2755
|
//# sourceMappingURL=infrab4a-connect.js.map
|