@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
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-md5'), require('axios'), require('firebase'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-md5', 'axios', 'firebase', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global
|
|
5
|
-
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsMd5, axios, firebase,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-md5'), require('axios'), require('firebase'), require('gql-query-builder'), require('node-fetch')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-md5', 'axios', 'firebase', 'gql-query-builder', 'node-fetch'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global["ts-md5"], global.axios, global.firebase, global["gql-query-builder"], global["node-fetch"]));
|
|
5
|
+
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsMd5, axios, firebase, gqlQueryBuilder, fetch) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
10
10
|
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
11
|
-
var firebase__default$1 = /*#__PURE__*/_interopDefaultLegacy(firebase$1);
|
|
12
11
|
var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
|
|
13
12
|
|
|
14
13
|
var BaseModel = /** @class */ (function () {
|
|
@@ -1204,13 +1203,6 @@
|
|
|
1204
1203
|
return RecoveryPassword;
|
|
1205
1204
|
}());
|
|
1206
1205
|
|
|
1207
|
-
exports.Shops = void 0;
|
|
1208
|
-
(function (Shops) {
|
|
1209
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
1210
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
1211
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
1212
|
-
})(exports.Shops || (exports.Shops = {}));
|
|
1213
|
-
|
|
1214
1206
|
var Category = /** @class */ (function (_super) {
|
|
1215
1207
|
__extends(Category, _super);
|
|
1216
1208
|
function Category() {
|
|
@@ -1229,6 +1221,13 @@
|
|
|
1229
1221
|
return Category;
|
|
1230
1222
|
}(BaseModel));
|
|
1231
1223
|
|
|
1224
|
+
exports.Shops = void 0;
|
|
1225
|
+
(function (Shops) {
|
|
1226
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
1227
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
1228
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
1229
|
+
})(exports.Shops || (exports.Shops = {}));
|
|
1230
|
+
|
|
1232
1231
|
var Product = /** @class */ (function (_super) {
|
|
1233
1232
|
__extends(Product, _super);
|
|
1234
1233
|
function Product() {
|
|
@@ -1250,6 +1249,33 @@
|
|
|
1250
1249
|
});
|
|
1251
1250
|
return Product;
|
|
1252
1251
|
}(BaseModel));
|
|
1252
|
+
__decorate([
|
|
1253
|
+
classTransformer.Type(function () { return KitProduct; }),
|
|
1254
|
+
__metadata("design:type", Array)
|
|
1255
|
+
], Product.prototype, "kitProducts", void 0);
|
|
1256
|
+
|
|
1257
|
+
var KitProduct = /** @class */ (function (_super) {
|
|
1258
|
+
__extends(KitProduct, _super);
|
|
1259
|
+
function KitProduct() {
|
|
1260
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1261
|
+
}
|
|
1262
|
+
Object.defineProperty(KitProduct, "identifiersFields", {
|
|
1263
|
+
get: function () {
|
|
1264
|
+
return ['productId', 'kitProducId'];
|
|
1265
|
+
},
|
|
1266
|
+
enumerable: false,
|
|
1267
|
+
configurable: true
|
|
1268
|
+
});
|
|
1269
|
+
return KitProduct;
|
|
1270
|
+
}(BaseModel));
|
|
1271
|
+
__decorate([
|
|
1272
|
+
classTransformer.Type(function () { return Product; }),
|
|
1273
|
+
__metadata("design:type", Product)
|
|
1274
|
+
], KitProduct.prototype, "kit", void 0);
|
|
1275
|
+
__decorate([
|
|
1276
|
+
classTransformer.Type(function () { return Product; }),
|
|
1277
|
+
__metadata("design:type", Product)
|
|
1278
|
+
], KitProduct.prototype, "product", void 0);
|
|
1253
1279
|
|
|
1254
1280
|
var Variant = /** @class */ (function (_super) {
|
|
1255
1281
|
__extends(Variant, _super);
|
|
@@ -2680,7 +2706,7 @@
|
|
|
2680
2706
|
var credentials, user;
|
|
2681
2707
|
return __generator(this, function (_a) {
|
|
2682
2708
|
switch (_a.label) {
|
|
2683
|
-
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default
|
|
2709
|
+
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default["default"].auth.GoogleAuthProvider())];
|
|
2684
2710
|
case 1:
|
|
2685
2711
|
credentials = _a.sent();
|
|
2686
2712
|
user = credentials.user;
|
|
@@ -2777,8 +2803,7 @@
|
|
|
2777
2803
|
return { columnName: attributeName.toString(), attributeName: attributeName, fields: fieldOption };
|
|
2778
2804
|
return Object.assign({ attributeName: attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2779
2805
|
};
|
|
2780
|
-
AttributeOptionHelper.
|
|
2781
|
-
AttributeOptionHelper.CheckIsColumnOption = function (fieldValue) { return AttributeOptionHelper.CheckIsColumnModelOption(fieldValue) || !!fieldValue.columnName; };
|
|
2806
|
+
AttributeOptionHelper.CheckIsColumnOption = function (fieldValue) { return !!fieldValue.columnName; };
|
|
2782
2807
|
AttributeOptionHelper.FindColumnOptionFromList = function (columnName, fields) {
|
|
2783
2808
|
if (fields.includes(columnName))
|
|
2784
2809
|
return { columnName: columnName, attributeName: columnName };
|
|
@@ -2802,8 +2827,7 @@
|
|
|
2802
2827
|
}());
|
|
2803
2828
|
GraphQLFieldHelper.CheckIsGraphQLParams = function (params) { return !lodash.isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation; };
|
|
2804
2829
|
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = function (fields) {
|
|
2805
|
-
return fields
|
|
2806
|
-
.map(function (field) {
|
|
2830
|
+
return fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
|
|
2807
2831
|
var _b, _c;
|
|
2808
2832
|
if (lodash.isString(field))
|
|
2809
2833
|
return field.toString();
|
|
@@ -2811,15 +2835,14 @@
|
|
|
2811
2835
|
var fieldValue = field[fieldName];
|
|
2812
2836
|
if (Array.isArray(fieldValue))
|
|
2813
2837
|
return _b = {}, _b[fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue), _b;
|
|
2814
|
-
if (AttributeOptionHelper.
|
|
2838
|
+
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
2839
|
+
return;
|
|
2840
|
+
if (fieldValue.fields)
|
|
2815
2841
|
return _c = {},
|
|
2816
2842
|
_c[fieldValue.columnName || fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
2817
2843
|
_c;
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
return;
|
|
2821
|
-
})
|
|
2822
|
-
.filter(function (field) { return !!field; });
|
|
2844
|
+
return fieldValue.columnName;
|
|
2845
|
+
}).filter(function (field) { return !!field; });
|
|
2823
2846
|
};
|
|
2824
2847
|
GraphQLFieldHelper.ConvertFieldValueFrom = function (data, fields) { return Object.keys(data).reduce(function (result, columnName) {
|
|
2825
2848
|
var _b, _c, _d, _e;
|
|
@@ -2863,7 +2886,7 @@
|
|
|
2863
2886
|
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
2864
2887
|
? (_b = {},
|
|
2865
2888
|
_b[columnName] = {
|
|
2866
|
-
data:
|
|
2889
|
+
data: instance[attributeName] instanceof BaseModel
|
|
2867
2890
|
? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
|
|
2868
2891
|
: converted,
|
|
2869
2892
|
},
|
|
@@ -3107,6 +3130,8 @@
|
|
|
3107
3130
|
|
|
3108
3131
|
var withUpdateHasuraGraphQL = function (MixinBase) {
|
|
3109
3132
|
var getValueByAction = function (options) {
|
|
3133
|
+
if (options instanceof BaseModel)
|
|
3134
|
+
return options.toPlain();
|
|
3110
3135
|
if (lodash.isNil(options.action))
|
|
3111
3136
|
return options;
|
|
3112
3137
|
if (options.action === exports.UpdateOptionActions.REMOVE_FIELD)
|
|
@@ -3132,8 +3157,8 @@
|
|
|
3132
3157
|
return __awaiter(this, void 0, void 0, function () {
|
|
3133
3158
|
var plainData;
|
|
3134
3159
|
var _this = this;
|
|
3135
|
-
return __generator(this, function (
|
|
3136
|
-
switch (
|
|
3160
|
+
return __generator(this, function (_b) {
|
|
3161
|
+
switch (_b.label) {
|
|
3137
3162
|
case 0:
|
|
3138
3163
|
plainData = this.paramsToPlain(data);
|
|
3139
3164
|
return [4 /*yield*/, this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), {
|
|
@@ -3145,7 +3170,7 @@
|
|
|
3145
3170
|
pk_columns: { type: this.updateGraphQLPKType, value: this.getUpdateModelKeys(plainData), required: true },
|
|
3146
3171
|
})];
|
|
3147
3172
|
case 1:
|
|
3148
|
-
|
|
3173
|
+
_b.sent();
|
|
3149
3174
|
return [2 /*return*/, this.model.toInstance(plainData)];
|
|
3150
3175
|
}
|
|
3151
3176
|
});
|
|
@@ -3156,20 +3181,21 @@
|
|
|
3156
3181
|
if (model.isModel(params))
|
|
3157
3182
|
return params.toPlain();
|
|
3158
3183
|
return Object.keys(params).reduce(function (data, currentKey) {
|
|
3159
|
-
var
|
|
3160
|
-
return (Object.assign(Object.assign({}, data), (params[currentKey] && (
|
|
3184
|
+
var _b;
|
|
3185
|
+
return (Object.assign(Object.assign({}, data), (params[currentKey] && (_b = {}, _b[currentKey] = getValueByAction(params[currentKey]), _b))));
|
|
3161
3186
|
}, {});
|
|
3162
3187
|
};
|
|
3163
3188
|
UpdateHasuraGraphQLMixin.prototype.getUpdateModelKeys = function (data) {
|
|
3164
3189
|
var _this = this;
|
|
3165
3190
|
var instance = this.model.toInstance(data);
|
|
3166
3191
|
return this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
3192
|
+
var _b;
|
|
3167
3193
|
var _a;
|
|
3168
3194
|
if (lodash.isNil(instance[identifier]))
|
|
3169
3195
|
return ids;
|
|
3170
3196
|
var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
|
|
3171
|
-
var value = columnOption.to(data[identifier.toString()], instance);
|
|
3172
|
-
return Object.assign(Object.assign({}, ids), (
|
|
3197
|
+
var 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];
|
|
3198
|
+
return Object.assign(Object.assign({}, ids), (_b = {}, _b[columnOption.columnName] = value, _b));
|
|
3173
3199
|
}, {});
|
|
3174
3200
|
};
|
|
3175
3201
|
return UpdateHasuraGraphQLMixin;
|
|
@@ -3278,7 +3304,7 @@
|
|
|
3278
3304
|
lodash.isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
3279
3305
|
return Object.keys(options).reduce(function (variables, key) {
|
|
3280
3306
|
var _a;
|
|
3281
|
-
var fieldOptions = AttributeOptionHelper.FindByAttribute(key, fields);
|
|
3307
|
+
var fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
3282
3308
|
var columnName = fieldOptions.columnName;
|
|
3283
3309
|
var columnFields = fieldOptions.fields;
|
|
3284
3310
|
return Object.assign(Object.assign({}, variables), (_a = {}, _a[columnName] = _this.buildWhereSentence(key, options[key], columnFields || []), _a));
|
|
@@ -3364,6 +3390,53 @@
|
|
|
3364
3390
|
}(withUpdateHasuraGraphQL(withGetHasuraGraphQL(withFindHasuraGraphQL(withDeleteHasuraGraphQL(withCreateHasuraGraphQL(MixinBase)))))));
|
|
3365
3391
|
};
|
|
3366
3392
|
|
|
3393
|
+
var CategoryHasuraGraphQL = /** @class */ (function (_super) {
|
|
3394
|
+
__extends(CategoryHasuraGraphQL, _super);
|
|
3395
|
+
function CategoryHasuraGraphQL() {
|
|
3396
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3397
|
+
}
|
|
3398
|
+
return CategoryHasuraGraphQL;
|
|
3399
|
+
}(Category));
|
|
3400
|
+
|
|
3401
|
+
var ProductHasuraGraphQL = /** @class */ (function (_super) {
|
|
3402
|
+
__extends(ProductHasuraGraphQL, _super);
|
|
3403
|
+
function ProductHasuraGraphQL() {
|
|
3404
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3405
|
+
}
|
|
3406
|
+
return ProductHasuraGraphQL;
|
|
3407
|
+
}(Product));
|
|
3408
|
+
__decorate([
|
|
3409
|
+
classTransformer.Type(function () { return KitProductHasuraGraphQL; }),
|
|
3410
|
+
__metadata("design:type", Array)
|
|
3411
|
+
], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
|
|
3412
|
+
|
|
3413
|
+
var KitProductHasuraGraphQL = /** @class */ (function (_super) {
|
|
3414
|
+
__extends(KitProductHasuraGraphQL, _super);
|
|
3415
|
+
function KitProductHasuraGraphQL() {
|
|
3416
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3417
|
+
}
|
|
3418
|
+
return KitProductHasuraGraphQL;
|
|
3419
|
+
}(KitProduct));
|
|
3420
|
+
__decorate([
|
|
3421
|
+
classTransformer.Type(function () { return ProductHasuraGraphQL; }),
|
|
3422
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
3423
|
+
], KitProductHasuraGraphQL.prototype, "kit", void 0);
|
|
3424
|
+
__decorate([
|
|
3425
|
+
classTransformer.Type(function () { return ProductHasuraGraphQL; }),
|
|
3426
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
3427
|
+
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
3428
|
+
|
|
3429
|
+
var VariantHasuraGraphQL = /** @class */ (function (_super) {
|
|
3430
|
+
__extends(VariantHasuraGraphQL, _super);
|
|
3431
|
+
function VariantHasuraGraphQL() {
|
|
3432
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3433
|
+
_this.name = '';
|
|
3434
|
+
_this.hasVariants = false;
|
|
3435
|
+
return _this;
|
|
3436
|
+
}
|
|
3437
|
+
return VariantHasuraGraphQL;
|
|
3438
|
+
}(Variant));
|
|
3439
|
+
|
|
3367
3440
|
var CategoryHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
3368
3441
|
__extends(CategoryHasuraGraphQLRepository, _super_1);
|
|
3369
3442
|
function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository) {
|
|
@@ -3521,106 +3594,94 @@
|
|
|
3521
3594
|
return CategoryHasuraGraphQLRepository;
|
|
3522
3595
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3523
3596
|
|
|
3524
|
-
var CategoryHasuraGraphQL = /** @class */ (function (_super) {
|
|
3525
|
-
__extends(CategoryHasuraGraphQL, _super);
|
|
3526
|
-
function CategoryHasuraGraphQL() {
|
|
3527
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3528
|
-
}
|
|
3529
|
-
return CategoryHasuraGraphQL;
|
|
3530
|
-
}(Category));
|
|
3531
|
-
|
|
3532
|
-
var ProductHasuraGraphQL = /** @class */ (function (_super) {
|
|
3533
|
-
__extends(ProductHasuraGraphQL, _super);
|
|
3534
|
-
function ProductHasuraGraphQL() {
|
|
3535
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
3536
|
-
}
|
|
3537
|
-
return ProductHasuraGraphQL;
|
|
3538
|
-
}(Product));
|
|
3539
|
-
|
|
3540
|
-
var VariantHasuraGraphQL = /** @class */ (function (_super) {
|
|
3541
|
-
__extends(VariantHasuraGraphQL, _super);
|
|
3542
|
-
function VariantHasuraGraphQL() {
|
|
3543
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3544
|
-
_this.name = '';
|
|
3545
|
-
_this.hasVariants = false;
|
|
3546
|
-
return _this;
|
|
3547
|
-
}
|
|
3548
|
-
return VariantHasuraGraphQL;
|
|
3549
|
-
}(Variant));
|
|
3550
|
-
|
|
3551
3597
|
var ProductHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
3552
3598
|
__extends(ProductHasuraGraphQLRepository, _super_1);
|
|
3553
3599
|
function ProductHasuraGraphQLRepository(endpoint, authOptions) {
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
var _c;
|
|
3572
|
-
return (Object.assign(Object.assign({}, shops), (_c = {}, _c[shop] = { description: description }, _c)));
|
|
3573
|
-
}, {}); },
|
|
3574
|
-
to: function (value) { return Object.values(value).shift().description; },
|
|
3575
|
-
},
|
|
3600
|
+
var _this = this;
|
|
3601
|
+
var commonFields = [
|
|
3602
|
+
{ id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
|
|
3603
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
3604
|
+
{ CEST: { columnName: 'cest' } },
|
|
3605
|
+
{ EAN: { columnName: 'ean' } },
|
|
3606
|
+
{ NCM: { columnName: 'ncm' } },
|
|
3607
|
+
'brand',
|
|
3608
|
+
{ costPrice: { columnName: 'cost_price' } },
|
|
3609
|
+
{
|
|
3610
|
+
description: {
|
|
3611
|
+
columnName: 'description',
|
|
3612
|
+
from: function (description) { return Object.values(exports.Shops).reduce(function (shops, shop) {
|
|
3613
|
+
var _c;
|
|
3614
|
+
return (Object.assign(Object.assign({}, shops), (_c = {}, _c[shop] = { description: description }, _c)));
|
|
3615
|
+
}, {}); },
|
|
3616
|
+
to: function (value) { return Object.values(value).shift().description; },
|
|
3576
3617
|
},
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
},
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
},
|
|
3599
|
-
bindPersistData: function (value) {
|
|
3600
|
-
var priceData = Object.values(value).shift();
|
|
3601
|
-
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 && {
|
|
3602
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3603
|
-
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
3604
|
-
},
|
|
3618
|
+
},
|
|
3619
|
+
{ hasVariants: { columnName: 'has_variants' } },
|
|
3620
|
+
{ images: { columnName: 'images', to: function (value) { return "{\"" + value.join("\",\"") + "\"}"; } } },
|
|
3621
|
+
{ miniatures: { columnName: 'miniatures', to: function (value) { return "{\"" + value.join("\",\"") + "\"}"; } } },
|
|
3622
|
+
'name',
|
|
3623
|
+
{
|
|
3624
|
+
price: {
|
|
3625
|
+
columnName: 'price',
|
|
3626
|
+
from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
|
|
3627
|
+
var _c;
|
|
3628
|
+
return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
|
|
3629
|
+
price: price,
|
|
3630
|
+
fullPrice: data.full_price,
|
|
3631
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
3632
|
+
subscriberPrice: data.subscriber_price,
|
|
3633
|
+
}, _c)));
|
|
3634
|
+
}, {}); },
|
|
3635
|
+
bindFindFilter: function (sentence) {
|
|
3636
|
+
var filters = Object.values(sentence).shift();
|
|
3637
|
+
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 && {
|
|
3638
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
3639
|
+
})), (filters.subscriberPrice && { subscriber_price: filters.subscriberPrice }));
|
|
3605
3640
|
},
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
{ publishedGlam: { columnName: 'published_glam' } },
|
|
3612
|
-
'sku',
|
|
3613
|
-
{
|
|
3614
|
-
stock: {
|
|
3615
|
-
columnName: 'stock',
|
|
3616
|
-
from: function (quantity) { return ({ quantity: quantity }); },
|
|
3617
|
-
to: function (value) { return (lodash.isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity); },
|
|
3641
|
+
bindPersistData: function (value) {
|
|
3642
|
+
var priceData = Object.values(value).shift();
|
|
3643
|
+
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 && {
|
|
3644
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3645
|
+
})), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
|
|
3618
3646
|
},
|
|
3619
3647
|
},
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3648
|
+
},
|
|
3649
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
3650
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
3651
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
3652
|
+
'published',
|
|
3653
|
+
{ publishedGlam: { columnName: 'published_glam' } },
|
|
3654
|
+
'sku',
|
|
3655
|
+
{
|
|
3656
|
+
stock: {
|
|
3657
|
+
columnName: 'stock',
|
|
3658
|
+
from: function (quantity) { return ({ quantity: quantity }); },
|
|
3659
|
+
to: function (value) { return (lodash.isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity); },
|
|
3660
|
+
},
|
|
3661
|
+
},
|
|
3662
|
+
'slug',
|
|
3663
|
+
'type',
|
|
3664
|
+
'video',
|
|
3665
|
+
'weight',
|
|
3666
|
+
{
|
|
3667
|
+
shopAvailability: {
|
|
3668
|
+
columnName: 'shop_availabilities',
|
|
3669
|
+
fields: ['shop'],
|
|
3670
|
+
from: function (shop) { return (Array.isArray(shop) ? shop.map(function (row) { return row.shop; }) : []); },
|
|
3671
|
+
to: function (shops) { return shops.map(function (shop) { return ({ shop: shop }); }); },
|
|
3672
|
+
},
|
|
3673
|
+
},
|
|
3674
|
+
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3675
|
+
{ isKit: { columnName: 'is_kit' } },
|
|
3676
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3677
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3678
|
+
];
|
|
3679
|
+
_this = _super_1.call(this, {
|
|
3680
|
+
tableName: 'product',
|
|
3681
|
+
model: ProductHasuraGraphQL,
|
|
3682
|
+
endpoint: endpoint,
|
|
3683
|
+
authOptions: authOptions,
|
|
3684
|
+
fields: __spreadArray(__spreadArray([], __read(commonFields)), [
|
|
3624
3685
|
{
|
|
3625
3686
|
categories: {
|
|
3626
3687
|
columnName: 'categories',
|
|
@@ -3633,18 +3694,20 @@
|
|
|
3633
3694
|
},
|
|
3634
3695
|
},
|
|
3635
3696
|
{
|
|
3636
|
-
|
|
3637
|
-
columnName: '
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3697
|
+
kitProducts: {
|
|
3698
|
+
columnName: 'kit_products',
|
|
3699
|
+
foreignKeyColumn: { productId: 'id' },
|
|
3700
|
+
fields: [
|
|
3701
|
+
{ productId: { columnName: 'product_id' } },
|
|
3702
|
+
{ kitProductId: { columnName: 'kit_product_id' } },
|
|
3703
|
+
'quantity',
|
|
3704
|
+
{ product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
|
|
3705
|
+
],
|
|
3641
3706
|
},
|
|
3642
3707
|
},
|
|
3643
|
-
|
|
3644
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3645
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3646
|
-
],
|
|
3708
|
+
]),
|
|
3647
3709
|
}) || this;
|
|
3710
|
+
return _this;
|
|
3648
3711
|
}
|
|
3649
3712
|
ProductHasuraGraphQLRepository.prototype.get = function (identifiers) {
|
|
3650
3713
|
var _super = Object.create(null, {
|
|
@@ -3693,27 +3756,36 @@
|
|
|
3693
3756
|
update: { get: function () { return _super_1.prototype.update; } }
|
|
3694
3757
|
});
|
|
3695
3758
|
return __awaiter(this, void 0, void 0, function () {
|
|
3696
|
-
var categories, checkId, data, plainData, id, product, _c, _d;
|
|
3697
|
-
return __generator(this, function (
|
|
3698
|
-
switch (
|
|
3759
|
+
var categories, kitProducts, checkId, data, plainData, id, product, _c, _d, _e, _f;
|
|
3760
|
+
return __generator(this, function (_g) {
|
|
3761
|
+
switch (_g.label) {
|
|
3699
3762
|
case 0:
|
|
3700
|
-
categories = params.categories, checkId = params.id, data = __rest(params, ["categories", "id"]);
|
|
3763
|
+
categories = params.categories, kitProducts = params.kitProducts, checkId = params.id, data = __rest(params, ["categories", "kitProducts", "id"]);
|
|
3701
3764
|
plainData = this.paramsToPlain({ id: checkId });
|
|
3702
3765
|
return [4 /*yield*/, this.getId(plainData.id)];
|
|
3703
3766
|
case 1:
|
|
3704
|
-
id =
|
|
3767
|
+
id = _g.sent();
|
|
3705
3768
|
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
3706
3769
|
case 2:
|
|
3707
|
-
product =
|
|
3770
|
+
product = _g.sent();
|
|
3708
3771
|
_c = product;
|
|
3709
3772
|
_d = categories;
|
|
3710
3773
|
if (!_d) return [3 /*break*/, 4];
|
|
3711
3774
|
return [4 /*yield*/, this.updateCategories(+id, { categories: categories })];
|
|
3712
3775
|
case 3:
|
|
3713
|
-
_d = (
|
|
3714
|
-
|
|
3776
|
+
_d = (_g.sent());
|
|
3777
|
+
_g.label = 4;
|
|
3715
3778
|
case 4:
|
|
3716
3779
|
_c.categories = _d;
|
|
3780
|
+
_e = product;
|
|
3781
|
+
_f = kitProducts;
|
|
3782
|
+
if (!_f) return [3 /*break*/, 6];
|
|
3783
|
+
return [4 /*yield*/, this.updateKitProducts(+id, { kitProducts: kitProducts })];
|
|
3784
|
+
case 5:
|
|
3785
|
+
_f = (_g.sent());
|
|
3786
|
+
_g.label = 6;
|
|
3787
|
+
case 6:
|
|
3788
|
+
_e.kitProducts = _f;
|
|
3717
3789
|
return [2 /*return*/, product];
|
|
3718
3790
|
}
|
|
3719
3791
|
});
|
|
@@ -3750,6 +3822,41 @@
|
|
|
3750
3822
|
});
|
|
3751
3823
|
});
|
|
3752
3824
|
};
|
|
3825
|
+
ProductHasuraGraphQLRepository.prototype.updateKitProducts = function (productId, _c) {
|
|
3826
|
+
var kitProducts = _c.kitProducts;
|
|
3827
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3828
|
+
var plainData;
|
|
3829
|
+
return __generator(this, function (_c) {
|
|
3830
|
+
switch (_c.label) {
|
|
3831
|
+
case 0:
|
|
3832
|
+
plainData = this.paramsToPlain({ kitProducts: kitProducts });
|
|
3833
|
+
return [4 /*yield*/, this.mutation('delete_product_kit', ['affected_rows'], {
|
|
3834
|
+
where: {
|
|
3835
|
+
type: 'product_kit_bool_exp',
|
|
3836
|
+
required: true,
|
|
3837
|
+
value: { product_id: { _eq: productId } },
|
|
3838
|
+
},
|
|
3839
|
+
})];
|
|
3840
|
+
case 1:
|
|
3841
|
+
_c.sent();
|
|
3842
|
+
return [4 /*yield*/, this.mutation('insert_product_kit', ['affected_rows'], {
|
|
3843
|
+
objects: {
|
|
3844
|
+
type: '[product_kit_insert_input!]',
|
|
3845
|
+
required: true,
|
|
3846
|
+
value: plainData.kitProducts.map(function (kitProduct) { return ({
|
|
3847
|
+
kit_product_id: kitProduct.kitProductId,
|
|
3848
|
+
product_id: productId,
|
|
3849
|
+
quantity: kitProduct.quantity,
|
|
3850
|
+
}); }),
|
|
3851
|
+
},
|
|
3852
|
+
})];
|
|
3853
|
+
case 2:
|
|
3854
|
+
_c.sent();
|
|
3855
|
+
return [2 /*return*/, plainData.kitProducts];
|
|
3856
|
+
}
|
|
3857
|
+
});
|
|
3858
|
+
});
|
|
3859
|
+
};
|
|
3753
3860
|
ProductHasuraGraphQLRepository.prototype.getId = function (id) {
|
|
3754
3861
|
var _a, _b;
|
|
3755
3862
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -4015,6 +4122,7 @@
|
|
|
4015
4122
|
exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
|
|
4016
4123
|
exports.Category = Category;
|
|
4017
4124
|
exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
|
|
4125
|
+
exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
|
|
4018
4126
|
exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
|
|
4019
4127
|
exports.Checkout = Checkout;
|
|
4020
4128
|
exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
|
|
@@ -4028,6 +4136,8 @@
|
|
|
4028
4136
|
exports.Home = Home;
|
|
4029
4137
|
exports.HomeFirestoreRepository = HomeFirestoreRepository;
|
|
4030
4138
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
4139
|
+
exports.KitProduct = KitProduct;
|
|
4140
|
+
exports.KitProductHasuraGraphQL = KitProductHasuraGraphQL;
|
|
4031
4141
|
exports.Lead = Lead;
|
|
4032
4142
|
exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
4033
4143
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
@@ -4039,6 +4149,7 @@
|
|
|
4039
4149
|
exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
4040
4150
|
exports.Product = Product;
|
|
4041
4151
|
exports.ProductFirestoreRepository = ProductFirestoreRepository;
|
|
4152
|
+
exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
|
|
4042
4153
|
exports.ProductHasuraGraphQLRepository = ProductHasuraGraphQLRepository;
|
|
4043
4154
|
exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
|
|
4044
4155
|
exports.ProductsIndex = ProductsIndex;
|
|
@@ -4069,6 +4180,7 @@
|
|
|
4069
4180
|
exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
|
|
4070
4181
|
exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
|
|
4071
4182
|
exports.Variant = Variant;
|
|
4183
|
+
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
4072
4184
|
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|
|
4073
4185
|
exports.WeakPasswordError = WeakPasswordError;
|
|
4074
4186
|
exports.isUUID = isUUID;
|