@infrab4a/connect 1.0.0-beta.9 → 1.0.1-beta.0
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 +1297 -321
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category.d.ts +2 -2
- 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 +6 -2
- package/domain/catalog/models/types/product-review.type.d.ts +10 -8
- package/domain/catalog/models/variant.d.ts +3 -1
- package/domain/catalog/repositories/product.repository.d.ts +9 -2
- package/domain/generic/model/base.model.d.ts +1 -1
- package/domain/generic/model/types/base-model-builder.type.d.ts +1 -1
- package/domain/generic/model/types/non-function-property-name.type.d.ts +1 -1
- package/domain/generic/repository/create.repository.d.ts +2 -2
- package/domain/generic/repository/delete.repository.d.ts +3 -1
- package/domain/generic/repository/find.repository.d.ts +2 -1
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +4 -4
- package/domain/generic/repository/types/repository-update-params.type.d.ts +4 -4
- package/domain/users/errors/unauthorized.error.d.ts +2 -1
- package/domain/users/errors/user-already-registered.error.d.ts +2 -1
- package/domain/users/errors/weak-password.error.d.ts +2 -1
- package/domain/users/models/user.d.ts +2 -0
- package/errors/duplicated-results.error.d.ts +2 -1
- package/errors/invalid-argument.error.d.ts +2 -1
- package/errors/not-found.error.d.ts +2 -1
- package/errors/required-argument.error.d.ts +2 -1
- package/esm2015/domain/catalog/models/category.js +1 -1
- 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/catalog/models/types/product-review.type.js +1 -1
- package/esm2015/domain/catalog/models/variant.js +1 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/model/base.model.js +4 -4
- package/esm2015/domain/generic/model/types/base-model-builder.type.js +1 -1
- package/esm2015/domain/generic/model/types/non-function-property-name.type.js +1 -1
- package/esm2015/domain/generic/repository/create.repository.js +1 -1
- package/esm2015/domain/generic/repository/delete.repository.js +1 -1
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-update-params.type.js +1 -1
- package/esm2015/domain/users/errors/unauthorized.error.js +3 -2
- package/esm2015/domain/users/errors/user-already-registered.error.js +3 -2
- package/esm2015/domain/users/errors/weak-password.error.js +3 -2
- package/esm2015/domain/users/models/user.js +1 -1
- package/esm2015/errors/duplicated-results.error.js +3 -2
- package/esm2015/errors/invalid-argument.error.js +3 -2
- package/esm2015/errors/not-found.error.js +3 -2
- package/esm2015/errors/required-argument.error.js +3 -2
- package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +36 -1
- package/esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +35 -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/firebase/firestore/mixins/with-find-firestore.mixin.js +11 -5
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +2 -3
- package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -2
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +32 -5
- package/esm2015/infra/hasura-graphql/index.js +3 -2
- package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +18 -2
- package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +20 -0
- package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +72 -0
- package/esm2015/infra/hasura-graphql/mixins/helpers/index.js +3 -1
- package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +21 -2
- package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +14 -6
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +24 -26
- package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +14 -10
- package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +10 -84
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +18 -7
- package/esm2015/infra/hasura-graphql/models/category-hasura-graphql.js +1 -1
- package/esm2015/infra/hasura-graphql/models/index.js +4 -1
- package/esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js +15 -0
- package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +11 -0
- package/esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js +9 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +47 -15
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +2 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +362 -63
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +116 -0
- package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +1 -1
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js +2 -0
- package/esm2015/infra/hasura-graphql/types/index.js +2 -1
- package/fesm2015/infrab4a-connect.js +870 -219
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/elasticsearch/adapters/axios.adapter.d.ts +3 -0
- package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +3 -0
- package/infra/elasticsearch/indexes/products-index.d.ts +5 -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/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/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +4 -2
- package/infra/hasura-graphql/index.d.ts +2 -1
- package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +9 -6
- package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +6 -0
- package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +8 -0
- package/infra/hasura-graphql/mixins/helpers/index.d.ts +2 -0
- 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 +8 -7
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +5 -5
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +3 -3
- package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +1 -1
- package/infra/hasura-graphql/models/category-hasura-graphql.d.ts +3 -1
- package/infra/hasura-graphql/models/index.d.ts +3 -0
- package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +6 -0
- package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +10 -0
- package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +9 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +22 -5
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +14 -0
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +5 -5
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +15 -19
- package/infra/hasura-graphql/types/hasura-graphql-headers.type.d.ts +7 -0
- package/infra/hasura-graphql/types/index.d.ts +1 -0
- package/package.json +4 -3
|
@@ -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-
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-
|
|
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-custom-error'), 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-custom-error', '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-custom-error"], global["ts-md5"], global.axios, global.firebase, global["gql-query-builder"], global["node-fetch"]));
|
|
5
|
+
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsCustomError, 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 () {
|
|
@@ -35,13 +34,13 @@
|
|
|
35
34
|
configurable: true
|
|
36
35
|
});
|
|
37
36
|
BaseModel.toInstance = function (data) {
|
|
38
|
-
return classTransformer.
|
|
37
|
+
return classTransformer.plainToInstance(this, data || {});
|
|
39
38
|
};
|
|
40
39
|
BaseModel.isModel = function (value) {
|
|
41
40
|
return value instanceof this;
|
|
42
41
|
};
|
|
43
42
|
BaseModel.prototype.toPlain = function () {
|
|
44
|
-
return classTransformer.
|
|
43
|
+
return classTransformer.instanceToPlain(this);
|
|
45
44
|
};
|
|
46
45
|
return BaseModel;
|
|
47
46
|
}());
|
|
@@ -1048,7 +1047,7 @@
|
|
|
1048
1047
|
return _this;
|
|
1049
1048
|
}
|
|
1050
1049
|
return UnauthorizedError;
|
|
1051
|
-
}(
|
|
1050
|
+
}(tsCustomError.CustomError));
|
|
1052
1051
|
|
|
1053
1052
|
exports.SignInMethods = void 0;
|
|
1054
1053
|
(function (SignInMethods) {
|
|
@@ -1107,7 +1106,7 @@
|
|
|
1107
1106
|
return _this;
|
|
1108
1107
|
}
|
|
1109
1108
|
return UserAlreadyRegisteredError;
|
|
1110
|
-
}(
|
|
1109
|
+
}(tsCustomError.CustomError));
|
|
1111
1110
|
|
|
1112
1111
|
var WeakPasswordError = /** @class */ (function (_super) {
|
|
1113
1112
|
__extends(WeakPasswordError, _super);
|
|
@@ -1118,7 +1117,7 @@
|
|
|
1118
1117
|
return _this;
|
|
1119
1118
|
}
|
|
1120
1119
|
return WeakPasswordError;
|
|
1121
|
-
}(
|
|
1120
|
+
}(tsCustomError.CustomError));
|
|
1122
1121
|
|
|
1123
1122
|
var Register = /** @class */ (function () {
|
|
1124
1123
|
function Register(registerService, userRepository) {
|
|
@@ -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);
|
|
@@ -1586,7 +1612,7 @@
|
|
|
1586
1612
|
return _this;
|
|
1587
1613
|
}
|
|
1588
1614
|
return InvalidArgumentError;
|
|
1589
|
-
}(
|
|
1615
|
+
}(tsCustomError.CustomError));
|
|
1590
1616
|
|
|
1591
1617
|
var RequiredArgumentError = /** @class */ (function (_super) {
|
|
1592
1618
|
__extends(RequiredArgumentError, _super);
|
|
@@ -1597,7 +1623,7 @@
|
|
|
1597
1623
|
return _this;
|
|
1598
1624
|
}
|
|
1599
1625
|
return RequiredArgumentError;
|
|
1600
|
-
}(
|
|
1626
|
+
}(tsCustomError.CustomError));
|
|
1601
1627
|
|
|
1602
1628
|
var NotFoundError = /** @class */ (function (_super) {
|
|
1603
1629
|
__extends(NotFoundError, _super);
|
|
@@ -1607,7 +1633,7 @@
|
|
|
1607
1633
|
return _this;
|
|
1608
1634
|
}
|
|
1609
1635
|
return NotFoundError;
|
|
1610
|
-
}(
|
|
1636
|
+
}(tsCustomError.CustomError));
|
|
1611
1637
|
|
|
1612
1638
|
var DuplicatedResultsError = /** @class */ (function (_super) {
|
|
1613
1639
|
__extends(DuplicatedResultsError, _super);
|
|
@@ -1617,12 +1643,35 @@
|
|
|
1617
1643
|
return _this;
|
|
1618
1644
|
}
|
|
1619
1645
|
return DuplicatedResultsError;
|
|
1620
|
-
}(
|
|
1646
|
+
}(tsCustomError.CustomError));
|
|
1621
1647
|
|
|
1622
1648
|
var AxiosAdapter = /** @class */ (function () {
|
|
1623
1649
|
function AxiosAdapter(config) {
|
|
1624
1650
|
this.config = config;
|
|
1625
1651
|
}
|
|
1652
|
+
AxiosAdapter.prototype.get = function (index) {
|
|
1653
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1654
|
+
var data, error_1;
|
|
1655
|
+
return __generator(this, function (_a) {
|
|
1656
|
+
switch (_a.label) {
|
|
1657
|
+
case 0:
|
|
1658
|
+
_a.trys.push([0, 2, , 3]);
|
|
1659
|
+
return [4 /*yield*/, axios__default["default"]({
|
|
1660
|
+
url: this.config.url + "/" + index,
|
|
1661
|
+
method: 'GET',
|
|
1662
|
+
headers: { Authorization: "Basic " + this.config.credential },
|
|
1663
|
+
})];
|
|
1664
|
+
case 1:
|
|
1665
|
+
data = (_a.sent()).data;
|
|
1666
|
+
return [2 /*return*/, data._source];
|
|
1667
|
+
case 2:
|
|
1668
|
+
error_1 = _a.sent();
|
|
1669
|
+
throw new NotFoundError(error_1.message);
|
|
1670
|
+
case 3: return [2 /*return*/];
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
};
|
|
1626
1675
|
AxiosAdapter.prototype.query = function (index, query) {
|
|
1627
1676
|
return __awaiter(this, void 0, void 0, function () {
|
|
1628
1677
|
var data;
|
|
@@ -1644,6 +1693,39 @@
|
|
|
1644
1693
|
});
|
|
1645
1694
|
});
|
|
1646
1695
|
};
|
|
1696
|
+
AxiosAdapter.prototype.save = function (index, data) {
|
|
1697
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1698
|
+
return __generator(this, function (_a) {
|
|
1699
|
+
switch (_a.label) {
|
|
1700
|
+
case 0: return [4 /*yield*/, axios__default["default"]({
|
|
1701
|
+
url: this.config.url + "/" + index,
|
|
1702
|
+
method: 'PUT',
|
|
1703
|
+
headers: { Authorization: "Basic " + this.config.credential },
|
|
1704
|
+
data: data,
|
|
1705
|
+
})];
|
|
1706
|
+
case 1:
|
|
1707
|
+
_a.sent();
|
|
1708
|
+
return [2 /*return*/];
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
});
|
|
1712
|
+
};
|
|
1713
|
+
AxiosAdapter.prototype.delete = function (index) {
|
|
1714
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1715
|
+
return __generator(this, function (_a) {
|
|
1716
|
+
switch (_a.label) {
|
|
1717
|
+
case 0: return [4 /*yield*/, axios__default["default"]({
|
|
1718
|
+
url: this.config.url + "/" + index,
|
|
1719
|
+
method: 'DELETE',
|
|
1720
|
+
headers: { Authorization: "Basic " + this.config.credential },
|
|
1721
|
+
})];
|
|
1722
|
+
case 1:
|
|
1723
|
+
_a.sent();
|
|
1724
|
+
return [2 /*return*/];
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
});
|
|
1728
|
+
};
|
|
1647
1729
|
return AxiosAdapter;
|
|
1648
1730
|
}());
|
|
1649
1731
|
|
|
@@ -1651,6 +1733,19 @@
|
|
|
1651
1733
|
function ProductsIndex(adapter) {
|
|
1652
1734
|
this.adapter = adapter;
|
|
1653
1735
|
}
|
|
1736
|
+
ProductsIndex.prototype.get = function (id) {
|
|
1737
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1738
|
+
var data;
|
|
1739
|
+
return __generator(this, function (_a) {
|
|
1740
|
+
switch (_a.label) {
|
|
1741
|
+
case 0: return [4 /*yield*/, this.adapter.get("products/_doc/" + id)];
|
|
1742
|
+
case 1:
|
|
1743
|
+
data = _a.sent();
|
|
1744
|
+
return [2 /*return*/, Product.toInstance(data)];
|
|
1745
|
+
}
|
|
1746
|
+
});
|
|
1747
|
+
});
|
|
1748
|
+
};
|
|
1654
1749
|
ProductsIndex.prototype.findById = function (ids, options) {
|
|
1655
1750
|
return __awaiter(this, void 0, void 0, function () {
|
|
1656
1751
|
var publishedField, fields, hits;
|
|
@@ -1710,6 +1805,64 @@
|
|
|
1710
1805
|
});
|
|
1711
1806
|
});
|
|
1712
1807
|
};
|
|
1808
|
+
ProductsIndex.prototype.save = function (product) {
|
|
1809
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1810
|
+
var error_1;
|
|
1811
|
+
return __generator(this, function (_a) {
|
|
1812
|
+
switch (_a.label) {
|
|
1813
|
+
case 0:
|
|
1814
|
+
delete product.createdAt;
|
|
1815
|
+
delete product.updatedAt;
|
|
1816
|
+
delete product.kitProducts;
|
|
1817
|
+
_a.label = 1;
|
|
1818
|
+
case 1:
|
|
1819
|
+
_a.trys.push([1, 4, , 6]);
|
|
1820
|
+
if (!product.firestoreId)
|
|
1821
|
+
throw new Error('Is not a product from firestore');
|
|
1822
|
+
return [4 /*yield*/, this.get(product.firestoreId)];
|
|
1823
|
+
case 2:
|
|
1824
|
+
_a.sent();
|
|
1825
|
+
return [4 /*yield*/, this.adapter.save("products/_doc/" + product.firestoreId, product.toPlain())];
|
|
1826
|
+
case 3:
|
|
1827
|
+
_a.sent();
|
|
1828
|
+
return [3 /*break*/, 6];
|
|
1829
|
+
case 4:
|
|
1830
|
+
error_1 = _a.sent();
|
|
1831
|
+
console.info(error_1.message);
|
|
1832
|
+
return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
|
|
1833
|
+
case 5:
|
|
1834
|
+
_a.sent();
|
|
1835
|
+
return [3 /*break*/, 6];
|
|
1836
|
+
case 6: return [2 /*return*/];
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
});
|
|
1840
|
+
};
|
|
1841
|
+
ProductsIndex.prototype.delete = function (product) {
|
|
1842
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1843
|
+
var error_2;
|
|
1844
|
+
return __generator(this, function (_a) {
|
|
1845
|
+
switch (_a.label) {
|
|
1846
|
+
case 0:
|
|
1847
|
+
_a.trys.push([0, 3, , 5]);
|
|
1848
|
+
return [4 /*yield*/, this.get(product.firestoreId)];
|
|
1849
|
+
case 1:
|
|
1850
|
+
_a.sent();
|
|
1851
|
+
return [4 /*yield*/, this.adapter.delete("products/_doc/" + product.firestoreId)];
|
|
1852
|
+
case 2:
|
|
1853
|
+
_a.sent();
|
|
1854
|
+
return [3 /*break*/, 5];
|
|
1855
|
+
case 3:
|
|
1856
|
+
error_2 = _a.sent();
|
|
1857
|
+
return [4 /*yield*/, this.adapter.delete("products/_doc/" + product.id)];
|
|
1858
|
+
case 4:
|
|
1859
|
+
_a.sent();
|
|
1860
|
+
return [3 /*break*/, 5];
|
|
1861
|
+
case 5: return [2 /*return*/];
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
});
|
|
1865
|
+
};
|
|
1713
1866
|
return ProductsIndex;
|
|
1714
1867
|
}());
|
|
1715
1868
|
|
|
@@ -1729,7 +1882,7 @@
|
|
|
1729
1882
|
fromFirestore: function (snap) {
|
|
1730
1883
|
var data = snap.data();
|
|
1731
1884
|
Object.keys(data).forEach(function (key) {
|
|
1732
|
-
if (data[key]
|
|
1885
|
+
if (data[key] && typeof data[key] === 'object' && '_seconds' in data[key]) {
|
|
1733
1886
|
data[key] = data[key].toDate();
|
|
1734
1887
|
}
|
|
1735
1888
|
});
|
|
@@ -1835,15 +1988,24 @@
|
|
|
1835
1988
|
return _this;
|
|
1836
1989
|
}
|
|
1837
1990
|
FindFirestore.prototype.find = function (_a) {
|
|
1838
|
-
var filters =
|
|
1991
|
+
var _b = _a === void 0 ? {} : _a, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy;
|
|
1839
1992
|
return __awaiter(this, void 0, void 0, function () {
|
|
1840
|
-
var query, docs, data;
|
|
1993
|
+
var orderByKeys, query, filtersKeysWithUnordered, docs, data;
|
|
1841
1994
|
return __generator(this, function (_a) {
|
|
1842
1995
|
switch (_a.label) {
|
|
1843
1996
|
case 0:
|
|
1844
|
-
|
|
1845
|
-
query = this.
|
|
1846
|
-
|
|
1997
|
+
orderByKeys = Object.keys(orderBy || {});
|
|
1998
|
+
query = this.collection(this.buildCollectionPathForFind(filters || {}));
|
|
1999
|
+
query = this.makeFirestoreWhere(query, filters || {});
|
|
2000
|
+
if (orderByKeys.length) {
|
|
2001
|
+
filtersKeysWithUnordered = Object.keys(filters || {}).filter(function (filterKey) { return !orderByKeys.includes(filterKey); });
|
|
2002
|
+
if (filtersKeysWithUnordered.length)
|
|
2003
|
+
filtersKeysWithUnordered.forEach(function (filterKey) {
|
|
2004
|
+
var _a;
|
|
2005
|
+
return (orderBy = Object.assign((_a = {}, _a[filterKey] = 'asc', _a), orderBy));
|
|
2006
|
+
});
|
|
2007
|
+
Object.keys(orderBy).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderBy[fieldName])); });
|
|
2008
|
+
}
|
|
1847
2009
|
return [4 /*yield*/, this.defineLimits(query, filters, limits)];
|
|
1848
2010
|
case 1:
|
|
1849
2011
|
query = _a.sent();
|
|
@@ -2378,7 +2540,9 @@
|
|
|
2378
2540
|
productIds = chunks_1_1.value;
|
|
2379
2541
|
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
2380
2542
|
return [3 /*break*/, 6];
|
|
2381
|
-
return [4 /*yield*/, this.collection('
|
|
2543
|
+
return [4 /*yield*/, this.collection('productsErpVitrine')
|
|
2544
|
+
.where(publishedField, '==', true)
|
|
2545
|
+
.where('id', 'in', productIds)];
|
|
2382
2546
|
case 3:
|
|
2383
2547
|
query = _b.sent();
|
|
2384
2548
|
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
@@ -2419,11 +2583,12 @@
|
|
|
2419
2583
|
function ProductFirestoreRepository(firestore) {
|
|
2420
2584
|
var _this = _super.call(this) || this;
|
|
2421
2585
|
_this.firestore = firestore;
|
|
2422
|
-
_this.
|
|
2586
|
+
_this.reviews = {};
|
|
2587
|
+
_this.collectionName = 'productsErpVitrine';
|
|
2423
2588
|
_this.model = Product;
|
|
2424
2589
|
return _this;
|
|
2425
2590
|
}
|
|
2426
|
-
ProductFirestoreRepository.prototype.getBySlug = function (slug
|
|
2591
|
+
ProductFirestoreRepository.prototype.getBySlug = function (slug) {
|
|
2427
2592
|
var _a;
|
|
2428
2593
|
return __awaiter(this, void 0, void 0, function () {
|
|
2429
2594
|
var result;
|
|
@@ -2432,7 +2597,6 @@
|
|
|
2432
2597
|
case 0: return [4 /*yield*/, this.find({
|
|
2433
2598
|
filters: {
|
|
2434
2599
|
slug: { operator: exports.Where.EQUALS, value: slug },
|
|
2435
|
-
shopAvailability: { operator: exports.Where.IN, value: [shop] },
|
|
2436
2600
|
},
|
|
2437
2601
|
})];
|
|
2438
2602
|
case 1:
|
|
@@ -2442,6 +2606,41 @@
|
|
|
2442
2606
|
});
|
|
2443
2607
|
});
|
|
2444
2608
|
};
|
|
2609
|
+
ProductFirestoreRepository.prototype.fetchReviews = function (status) {
|
|
2610
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2611
|
+
var products;
|
|
2612
|
+
var _this = this;
|
|
2613
|
+
return __generator(this, function (_b) {
|
|
2614
|
+
switch (_b.label) {
|
|
2615
|
+
case 0: return [4 /*yield*/, this.find()];
|
|
2616
|
+
case 1:
|
|
2617
|
+
products = (_b.sent()).data;
|
|
2618
|
+
products.forEach(function (product) {
|
|
2619
|
+
var _a;
|
|
2620
|
+
if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
|
|
2621
|
+
return;
|
|
2622
|
+
var productInfo = {
|
|
2623
|
+
productId: product.id,
|
|
2624
|
+
productName: product.name,
|
|
2625
|
+
productSku: product.sku,
|
|
2626
|
+
};
|
|
2627
|
+
_this.reviews.pending = [];
|
|
2628
|
+
_this.reviews.approved = [];
|
|
2629
|
+
_this.reviews.rejected = [];
|
|
2630
|
+
product.reviews.forEach(function (review) {
|
|
2631
|
+
if ([null, undefined].includes(review.status))
|
|
2632
|
+
return _this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2633
|
+
if (review.status === false)
|
|
2634
|
+
return _this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2635
|
+
if (!!review.status)
|
|
2636
|
+
return _this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2637
|
+
});
|
|
2638
|
+
});
|
|
2639
|
+
return [2 /*return*/, this.reviews[status]];
|
|
2640
|
+
}
|
|
2641
|
+
});
|
|
2642
|
+
});
|
|
2643
|
+
};
|
|
2445
2644
|
return ProductFirestoreRepository;
|
|
2446
2645
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2447
2646
|
|
|
@@ -2680,7 +2879,7 @@
|
|
|
2680
2879
|
var credentials, user;
|
|
2681
2880
|
return __generator(this, function (_a) {
|
|
2682
2881
|
switch (_a.label) {
|
|
2683
|
-
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default
|
|
2882
|
+
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default["default"].auth.GoogleAuthProvider())];
|
|
2684
2883
|
case 1:
|
|
2685
2884
|
credentials = _a.sent();
|
|
2686
2885
|
user = credentials.user;
|
|
@@ -2761,6 +2960,139 @@
|
|
|
2761
2960
|
return RegisterFirebaseAuthService;
|
|
2762
2961
|
}());
|
|
2763
2962
|
|
|
2963
|
+
var AttributeOptionHelper = /** @class */ (function () {
|
|
2964
|
+
function AttributeOptionHelper() {
|
|
2965
|
+
}
|
|
2966
|
+
return AttributeOptionHelper;
|
|
2967
|
+
}());
|
|
2968
|
+
AttributeOptionHelper.FindByAttribute = function (attributeName, fields) {
|
|
2969
|
+
if (fields.includes(attributeName))
|
|
2970
|
+
return { columnName: attributeName.toString(), attributeName: attributeName };
|
|
2971
|
+
var field = fields.find(function (columnOption) { return lodash.isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()); });
|
|
2972
|
+
var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
2973
|
+
if (lodash.isNil(fieldOption))
|
|
2974
|
+
return { columnName: attributeName.toString(), attributeName: attributeName };
|
|
2975
|
+
if (Array.isArray(fieldOption))
|
|
2976
|
+
return { columnName: attributeName.toString(), attributeName: attributeName, fields: fieldOption };
|
|
2977
|
+
return Object.assign({ attributeName: attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2978
|
+
};
|
|
2979
|
+
AttributeOptionHelper.CheckIsColumnOption = function (fieldValue) { return !!fieldValue.columnName; };
|
|
2980
|
+
AttributeOptionHelper.FindColumnOptionFromList = function (columnName, fields) {
|
|
2981
|
+
if (fields.includes(columnName))
|
|
2982
|
+
return { columnName: columnName, attributeName: columnName };
|
|
2983
|
+
var field = fields.find(function (columnOption) {
|
|
2984
|
+
var _a;
|
|
2985
|
+
return lodash.isObject(columnOption) &&
|
|
2986
|
+
((_a = Object.values(columnOption).find(function (option) { return AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName; })) === null || _a === void 0 ? void 0 : _a.columnName) === columnName;
|
|
2987
|
+
}) || {};
|
|
2988
|
+
var attributeName = Object.keys(field).find(function (fieldOptionFromList) { return AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) ||
|
|
2989
|
+
Array.isArray(field[fieldOptionFromList]); });
|
|
2990
|
+
var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName];
|
|
2991
|
+
if (Array.isArray(fieldOption))
|
|
2992
|
+
return { attributeName: attributeName, fields: fieldOption };
|
|
2993
|
+
return Object.assign({ attributeName: attributeName || columnName, columnName: columnName }, fieldOption);
|
|
2994
|
+
};
|
|
2995
|
+
|
|
2996
|
+
var GraphQLFieldHelper = /** @class */ (function () {
|
|
2997
|
+
function GraphQLFieldHelper() {
|
|
2998
|
+
}
|
|
2999
|
+
return GraphQLFieldHelper;
|
|
3000
|
+
}());
|
|
3001
|
+
GraphQLFieldHelper.CheckIsGraphQLParams = function (params) { return !lodash.isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation; };
|
|
3002
|
+
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = function (fields) {
|
|
3003
|
+
return fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
|
|
3004
|
+
var _b, _c;
|
|
3005
|
+
if (lodash.isString(field))
|
|
3006
|
+
return field.toString();
|
|
3007
|
+
var fieldName = Object.keys(field).shift();
|
|
3008
|
+
var fieldValue = field[fieldName];
|
|
3009
|
+
if (Array.isArray(fieldValue))
|
|
3010
|
+
return _b = {}, _b[fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue), _b;
|
|
3011
|
+
if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
|
|
3012
|
+
return;
|
|
3013
|
+
if (fieldValue.fields)
|
|
3014
|
+
return _c = {},
|
|
3015
|
+
_c[fieldValue.columnName || fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
|
|
3016
|
+
_c;
|
|
3017
|
+
return fieldValue.columnName;
|
|
3018
|
+
}).filter(function (field) { return !!field; });
|
|
3019
|
+
};
|
|
3020
|
+
GraphQLFieldHelper.ConvertFieldValueFrom = function (data, fields) { return Object.keys(data).reduce(function (result, columnName) {
|
|
3021
|
+
var _b, _c, _d, _e;
|
|
3022
|
+
var _f = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields), attributeName = _f.attributeName, attributeFields = _f.fields, from = _f.from;
|
|
3023
|
+
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
3024
|
+
if (Array.isArray(data[columnName]))
|
|
3025
|
+
return Object.assign(Object.assign({}, result), (_b = {}, _b[attributeName] = from
|
|
3026
|
+
? from(data[columnName], data)
|
|
3027
|
+
: data[columnName].map(function (value) { return GraphQLFieldHelper.ConvertFieldValueFrom(value, attributeFields); }), _b));
|
|
3028
|
+
if (lodash.isObject(data[columnName]))
|
|
3029
|
+
return Object.assign(Object.assign({}, result), (_c = {}, _c[attributeName] = !!from
|
|
3030
|
+
? from(data[columnName])
|
|
3031
|
+
: GraphQLFieldHelper.ConvertFieldValueFrom(data[columnName], attributeFields), _c));
|
|
3032
|
+
}
|
|
3033
|
+
if (!!from)
|
|
3034
|
+
return Object.assign(Object.assign({}, result), (_d = {}, _d[attributeName] = from(data[columnName], data), _d));
|
|
3035
|
+
return Object.assign(Object.assign({}, result), (_e = {}, _e[attributeName] = parseDateTime(data[columnName]), _e));
|
|
3036
|
+
}, {}); };
|
|
3037
|
+
GraphQLFieldHelper.ConvertFieldValueTo = function (instance, fields, update) {
|
|
3038
|
+
if (update === void 0) { update = false; }
|
|
3039
|
+
var _a;
|
|
3040
|
+
var data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
|
|
3041
|
+
return Object.keys(data).reduce(function (result, attributeName) {
|
|
3042
|
+
var _b, _c, _d;
|
|
3043
|
+
var _e = AttributeOptionHelper.FindByAttribute(attributeName, fields), columnName = _e.columnName, attributeFields = _e.fields, foreignKeyColumn = _e.foreignKeyColumn, to = _e.to, bindPersistData = _e.bindPersistData;
|
|
3044
|
+
if (bindPersistData)
|
|
3045
|
+
return Object.assign(Object.assign({}, result), bindPersistData(data[attributeName], instance));
|
|
3046
|
+
if (lodash.isNil(columnName))
|
|
3047
|
+
return result;
|
|
3048
|
+
if (!!foreignKeyColumn &&
|
|
3049
|
+
!lodash.isEmpty(foreignKeyColumn) &&
|
|
3050
|
+
!Object.keys(foreignKeyColumn).filter(function (key) { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
|
|
3051
|
+
return Object.keys(foreignKeyColumn).reduce(function (object, current) {
|
|
3052
|
+
var _b;
|
|
3053
|
+
var _a;
|
|
3054
|
+
return (Object.assign(Object.assign({}, object), (_b = {}, _b[foreignKeyColumn[current]] = (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current], _b)));
|
|
3055
|
+
}, Object.assign({}, result));
|
|
3056
|
+
if (update && lodash.isObject(data[attributeName]) && !lodash.isNil(attributeFields) && !lodash.isDate(data[attributeName]))
|
|
3057
|
+
return result;
|
|
3058
|
+
if (!!columnName && Array.isArray(attributeFields) && lodash.isObject(data[attributeName])) {
|
|
3059
|
+
var converted = !lodash.isNil(columnName) && to ? to(instance[attributeName], instance) : data[attributeName];
|
|
3060
|
+
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
3061
|
+
? (_b = {},
|
|
3062
|
+
_b[columnName] = {
|
|
3063
|
+
data: instance[attributeName] instanceof BaseModel
|
|
3064
|
+
? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
|
|
3065
|
+
: converted,
|
|
3066
|
+
},
|
|
3067
|
+
_b) : {}));
|
|
3068
|
+
}
|
|
3069
|
+
if (!!to)
|
|
3070
|
+
return Object.assign(Object.assign({}, result), (_c = {}, _c[columnName] = to(instance[attributeName], instance), _c));
|
|
3071
|
+
return Object.assign(Object.assign({}, result), (_d = {}, _d[columnName] = data[attributeName], _d));
|
|
3072
|
+
}, {});
|
|
3073
|
+
};
|
|
3074
|
+
|
|
3075
|
+
var FilterOptionHelper = /** @class */ (function () {
|
|
3076
|
+
function FilterOptionHelper() {
|
|
3077
|
+
}
|
|
3078
|
+
return FilterOptionHelper;
|
|
3079
|
+
}());
|
|
3080
|
+
FilterOptionHelper.CheckIfIsFilterOption = function (filter) { return !lodash.isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
|
|
3081
|
+
FilterOptionHelper.GetValueFromFilter = function (filter, fieldOption) {
|
|
3082
|
+
if (!FilterOptionHelper.CheckIfIsFilterOption(filter))
|
|
3083
|
+
return filter;
|
|
3084
|
+
if (filter.operator === exports.Where.ISNULL)
|
|
3085
|
+
return true;
|
|
3086
|
+
if (filter.operator === exports.Where.ISNOTNULL)
|
|
3087
|
+
return false;
|
|
3088
|
+
var converter = fieldOption.to
|
|
3089
|
+
? fieldOption.to
|
|
3090
|
+
: function (value) { return (filter.operator === exports.Where.LIKE && value.indexOf('%') < 0 ? "%" + value + "%" : value); };
|
|
3091
|
+
return Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
|
|
3092
|
+
? filter.value.map(function (fieldValue) { return converter(fieldValue); })
|
|
3093
|
+
: converter(filter.value);
|
|
3094
|
+
};
|
|
3095
|
+
|
|
2764
3096
|
var withCreateHasuraGraphQL = function (MixinBase) {
|
|
2765
3097
|
return /** @class */ (function (_super) {
|
|
2766
3098
|
__extends(CreateHasuraGraphQLMixin, _super);
|
|
@@ -2779,11 +3111,11 @@
|
|
|
2779
3111
|
CreateHasuraGraphQLMixin.prototype.create = function (data) {
|
|
2780
3112
|
return __awaiter(this, void 0, void 0, function () {
|
|
2781
3113
|
var newData;
|
|
2782
|
-
return __generator(this, function (
|
|
2783
|
-
switch (
|
|
3114
|
+
return __generator(this, function (_b) {
|
|
3115
|
+
switch (_b.label) {
|
|
2784
3116
|
case 0: return [4 /*yield*/, this.save(this.model.toInstance(data))];
|
|
2785
3117
|
case 1:
|
|
2786
|
-
newData =
|
|
3118
|
+
newData = _b.sent();
|
|
2787
3119
|
return [2 /*return*/, this.model.toInstance(newData)];
|
|
2788
3120
|
}
|
|
2789
3121
|
});
|
|
@@ -2791,14 +3123,34 @@
|
|
|
2791
3123
|
};
|
|
2792
3124
|
CreateHasuraGraphQLMixin.prototype.save = function (data) {
|
|
2793
3125
|
return __awaiter(this, void 0, void 0, function () {
|
|
2794
|
-
var result;
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
})
|
|
3126
|
+
var primaryKeyColumns, foreignKeyColumns, result;
|
|
3127
|
+
var _this = this;
|
|
3128
|
+
return __generator(this, function (_b) {
|
|
3129
|
+
switch (_b.label) {
|
|
3130
|
+
case 0:
|
|
3131
|
+
primaryKeyColumns = this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; });
|
|
3132
|
+
foreignKeyColumns = this.fields
|
|
3133
|
+
.map(function (field) {
|
|
3134
|
+
var _b;
|
|
3135
|
+
var columnOptions = Object.values(field).shift();
|
|
3136
|
+
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
3137
|
+
columnOptions.foreignKeyColumn && __spreadArray(__spreadArray([], __read(Object.values(columnOptions.foreignKeyColumn))), [
|
|
3138
|
+
(_b = {},
|
|
3139
|
+
_b[columnOptions.columnName] = Object.keys(columnOptions.foreignKeyColumn).map(function (foreignKeyField) {
|
|
3140
|
+
var _a;
|
|
3141
|
+
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
|
|
3142
|
+
foreignKeyField;
|
|
3143
|
+
}),
|
|
3144
|
+
_b),
|
|
3145
|
+
]));
|
|
3146
|
+
})
|
|
3147
|
+
.filter(Boolean)
|
|
3148
|
+
.reduce(function (keys, current) { return __spreadArray(__spreadArray([], __read(keys)), __read(current)); }, []);
|
|
3149
|
+
return [4 /*yield*/, this.mutation(this.insertGraphQLOperation, __spreadArray(__spreadArray([], __read(primaryKeyColumns)), __read(foreignKeyColumns)), {
|
|
3150
|
+
object: { type: this.insertGraphQLObjectType, required: true, value: this.convertDataToHasura(data) },
|
|
3151
|
+
})];
|
|
2800
3152
|
case 1:
|
|
2801
|
-
result =
|
|
3153
|
+
result = _b.sent();
|
|
2802
3154
|
return [2 /*return*/, Object.assign(Object.assign({}, data.toPlain()), this.convertDataFromHasura(result[this.insertGraphQLOperation]).toPlain())];
|
|
2803
3155
|
}
|
|
2804
3156
|
});
|
|
@@ -2830,13 +3182,17 @@
|
|
|
2830
3182
|
switch (_a.label) {
|
|
2831
3183
|
case 0:
|
|
2832
3184
|
instance = this.model.toInstance(identifiers);
|
|
2833
|
-
return [4 /*yield*/, this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields
|
|
3185
|
+
return [4 /*yield*/, this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
2834
3186
|
var _a;
|
|
2835
|
-
|
|
2836
|
-
|
|
3187
|
+
if (lodash.isNil(instance[identifier]))
|
|
3188
|
+
return ids;
|
|
3189
|
+
var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
|
|
3190
|
+
var value = columnOption.to(identifiers[identifier.toString()], instance);
|
|
3191
|
+
return Object.assign(Object.assign({}, ids), (_a = {}, _a[columnOption.columnName] = {
|
|
3192
|
+
type: _this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3193
|
+
value: value,
|
|
2837
3194
|
required: true,
|
|
2838
|
-
|
|
2839
|
-
}, _a)));
|
|
3195
|
+
}, _a));
|
|
2840
3196
|
}, {}))];
|
|
2841
3197
|
case 1:
|
|
2842
3198
|
_a.sent();
|
|
@@ -2849,104 +3205,7 @@
|
|
|
2849
3205
|
}(MixinBase));
|
|
2850
3206
|
};
|
|
2851
3207
|
|
|
2852
|
-
var AttributeOptionHelper = /** @class */ (function () {
|
|
2853
|
-
function AttributeOptionHelper() {
|
|
2854
|
-
}
|
|
2855
|
-
return AttributeOptionHelper;
|
|
2856
|
-
}());
|
|
2857
|
-
AttributeOptionHelper.findByAttribute = function (attributeName, fields) {
|
|
2858
|
-
if (fields.includes(attributeName))
|
|
2859
|
-
return { columnName: attributeName.toString(), attributeName: attributeName };
|
|
2860
|
-
var field = fields.find(function (columnOption) { return lodash.isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()); });
|
|
2861
|
-
var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
|
|
2862
|
-
if (lodash.isNil(fieldOption))
|
|
2863
|
-
return { columnName: attributeName.toString(), attributeName: attributeName };
|
|
2864
|
-
if (Array.isArray(fieldOption))
|
|
2865
|
-
return { columnName: attributeName.toString(), attributeName: attributeName, fields: fieldOption };
|
|
2866
|
-
return Object.assign({ attributeName: attributeName, columnName: attributeName.toString() }, fieldOption);
|
|
2867
|
-
};
|
|
2868
|
-
|
|
2869
3208
|
var withHasuraGraphQL = function (MixinBase) {
|
|
2870
|
-
var checkIsGraphQLParams = function (params) { return !lodash.isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation; };
|
|
2871
|
-
var checkIsColumnModelOption = function (fieldValue) { return !!fieldValue.columnName && !!fieldValue.fields; };
|
|
2872
|
-
var checkIsColumnOption = function (fieldValue) { return checkIsColumnModelOption(fieldValue) || !!fieldValue.columnName; };
|
|
2873
|
-
var convertModelFieldsToGraphQLFields = function (fields) {
|
|
2874
|
-
return fields
|
|
2875
|
-
.map(function (field) {
|
|
2876
|
-
var _b, _c;
|
|
2877
|
-
if (lodash.isString(field))
|
|
2878
|
-
return field.toString();
|
|
2879
|
-
var fieldName = Object.keys(field).shift();
|
|
2880
|
-
var fieldValue = field[fieldName];
|
|
2881
|
-
if (Array.isArray(fieldValue))
|
|
2882
|
-
return _b = {}, _b[fieldName] = convertModelFieldsToGraphQLFields(fieldValue), _b;
|
|
2883
|
-
if (checkIsColumnModelOption(fieldValue))
|
|
2884
|
-
return _c = {}, _c[fieldValue.columnName || fieldName] = convertModelFieldsToGraphQLFields(fieldValue.fields), _c;
|
|
2885
|
-
if (checkIsColumnOption(fieldValue))
|
|
2886
|
-
return fieldValue.columnName;
|
|
2887
|
-
return;
|
|
2888
|
-
})
|
|
2889
|
-
.filter(function (field) { return !!field; });
|
|
2890
|
-
};
|
|
2891
|
-
var findColumnOptionFromList = function (columnName, fields) {
|
|
2892
|
-
if (fields.includes(columnName))
|
|
2893
|
-
return { columnName: columnName, attributeName: columnName };
|
|
2894
|
-
var field = fields.find(function (columnOption) {
|
|
2895
|
-
var _a;
|
|
2896
|
-
return lodash.isObject(columnOption) &&
|
|
2897
|
-
((_a = Object.values(columnOption).find(function (option) { return checkIsColumnOption(option) && option.columnName === columnName; })) === null || _a === void 0 ? void 0 : _a.columnName) === columnName;
|
|
2898
|
-
}) || {};
|
|
2899
|
-
var attributeName = Object.keys(field).find(function (fieldOption) { return checkIsColumnOption(field[fieldOption]) || Array.isArray(field[fieldOption]); });
|
|
2900
|
-
var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName];
|
|
2901
|
-
if (Array.isArray(fieldOption))
|
|
2902
|
-
return { attributeName: attributeName, fields: fieldOption };
|
|
2903
|
-
return Object.assign({ attributeName: attributeName || columnName, columnName: columnName }, fieldOption);
|
|
2904
|
-
};
|
|
2905
|
-
var convertFieldValueFrom = function (data, fields) { return Object.keys(data).reduce(function (result, columnName) {
|
|
2906
|
-
var _b, _c, _d, _e;
|
|
2907
|
-
var _f = findColumnOptionFromList(columnName, fields), attributeName = _f.attributeName, attributeFields = _f.fields, from = _f.from;
|
|
2908
|
-
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
2909
|
-
if (Array.isArray(data[columnName]))
|
|
2910
|
-
return Object.assign(Object.assign({}, result), (_b = {}, _b[attributeName] = from
|
|
2911
|
-
? from(data[columnName], data)
|
|
2912
|
-
: data[columnName].map(function (value) { return convertFieldValueFrom(value, attributeFields); }), _b));
|
|
2913
|
-
if (lodash.isObject(data[columnName]))
|
|
2914
|
-
return Object.assign(Object.assign({}, result), (_c = {}, _c[attributeName] = convertFieldValueFrom(data[columnName], attributeFields), _c));
|
|
2915
|
-
}
|
|
2916
|
-
if (!!from)
|
|
2917
|
-
return Object.assign(Object.assign({}, result), (_d = {}, _d[attributeName] = from(data[columnName], data), _d));
|
|
2918
|
-
return Object.assign(Object.assign({}, result), (_e = {}, _e[attributeName] = parseDateTime(data[columnName]), _e));
|
|
2919
|
-
}, {}); };
|
|
2920
|
-
var convertFieldValueTo = function (instance, fields, update) {
|
|
2921
|
-
if (update === void 0) { update = false; }
|
|
2922
|
-
var _a;
|
|
2923
|
-
var data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
|
|
2924
|
-
return Object.keys(data)
|
|
2925
|
-
.filter(function (key) { return !lodash.isNil(data[key]); })
|
|
2926
|
-
.reduce(function (result, attributeName) {
|
|
2927
|
-
var _b, _c, _d;
|
|
2928
|
-
var _e = AttributeOptionHelper.findByAttribute(attributeName, fields), columnName = _e.columnName, attributeFields = _e.fields, foreignKeyColumn = _e.foreignKeyColumn, to = _e.to;
|
|
2929
|
-
if (lodash.isNil(columnName))
|
|
2930
|
-
return result;
|
|
2931
|
-
if (!!foreignKeyColumn &&
|
|
2932
|
-
!lodash.isEmpty(foreignKeyColumn) &&
|
|
2933
|
-
!Object.keys(foreignKeyColumn).filter(function (key) { return !data[attributeName][key]; }).length)
|
|
2934
|
-
return Object.keys(foreignKeyColumn).reduce(function (object, current) {
|
|
2935
|
-
var _b;
|
|
2936
|
-
return (Object.assign(Object.assign({}, object), (_b = {}, _b[foreignKeyColumn[current]] = data[attributeName][current], _b)));
|
|
2937
|
-
}, Object.assign({}, result));
|
|
2938
|
-
if (update && lodash.isObject(data[attributeName]) && !lodash.isDate(data[attributeName]))
|
|
2939
|
-
return result;
|
|
2940
|
-
if (!!columnName && Array.isArray(attributeFields) && lodash.isObject(data[attributeName])) {
|
|
2941
|
-
var converted = !lodash.isNil(columnName) ? to(instance[attributeName], instance) : data[attributeName];
|
|
2942
|
-
return Object.assign(Object.assign({}, result), (converted !== undefined
|
|
2943
|
-
? (_b = {}, _b[columnName] = { data: convertFieldValueTo(data[attributeName], attributeFields) }, _b) : {}));
|
|
2944
|
-
}
|
|
2945
|
-
if (!!to)
|
|
2946
|
-
return Object.assign(Object.assign({}, result), (_c = {}, _c[columnName] = to(instance[attributeName], instance), _c));
|
|
2947
|
-
return Object.assign(Object.assign({}, result), (_d = {}, _d[columnName] = data[attributeName], _d));
|
|
2948
|
-
}, {});
|
|
2949
|
-
};
|
|
2950
3209
|
return /** @class */ (function (_super) {
|
|
2951
3210
|
__extends(HasuraGraphQLMixin, _super);
|
|
2952
3211
|
function HasuraGraphQLMixin() {
|
|
@@ -2976,11 +3235,11 @@
|
|
|
2976
3235
|
HasuraGraphQLMixin.prototype.mutation = function (operation, fields, variables) {
|
|
2977
3236
|
return __awaiter(this, void 0, void 0, function () {
|
|
2978
3237
|
var resultQuery;
|
|
2979
|
-
return __generator(this, function (
|
|
3238
|
+
return __generator(this, function (_a) {
|
|
2980
3239
|
resultQuery = gqlQueryBuilder.mutation({
|
|
2981
3240
|
operation: operation,
|
|
2982
3241
|
variables: variables,
|
|
2983
|
-
fields:
|
|
3242
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
2984
3243
|
});
|
|
2985
3244
|
return [2 /*return*/, this.fetch(resultQuery)];
|
|
2986
3245
|
});
|
|
@@ -2989,17 +3248,17 @@
|
|
|
2989
3248
|
HasuraGraphQLMixin.prototype.query = function (operation, fields, variables) {
|
|
2990
3249
|
return __awaiter(this, void 0, void 0, function () {
|
|
2991
3250
|
var resultQuery;
|
|
2992
|
-
return __generator(this, function (
|
|
2993
|
-
resultQuery =
|
|
3251
|
+
return __generator(this, function (_a) {
|
|
3252
|
+
resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
|
|
2994
3253
|
? gqlQueryBuilder.query(operation.map(function (option) { return ({
|
|
2995
3254
|
operation: option.operation,
|
|
2996
3255
|
variables: option.variables,
|
|
2997
|
-
fields:
|
|
3256
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
|
|
2998
3257
|
}); }))
|
|
2999
3258
|
: gqlQueryBuilder.query({
|
|
3000
3259
|
operation: operation,
|
|
3001
3260
|
variables: variables,
|
|
3002
|
-
fields:
|
|
3261
|
+
fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
|
|
3003
3262
|
});
|
|
3004
3263
|
return [2 /*return*/, this.fetch(resultQuery)];
|
|
3005
3264
|
});
|
|
@@ -3008,8 +3267,8 @@
|
|
|
3008
3267
|
HasuraGraphQLMixin.prototype.fetch = function (params) {
|
|
3009
3268
|
return __awaiter(this, void 0, void 0, function () {
|
|
3010
3269
|
var headers, response, result;
|
|
3011
|
-
return __generator(this, function (
|
|
3012
|
-
switch (
|
|
3270
|
+
return __generator(this, function (_a) {
|
|
3271
|
+
switch (_a.label) {
|
|
3013
3272
|
case 0:
|
|
3014
3273
|
headers = this.headers;
|
|
3015
3274
|
return [4 /*yield*/, fetch__default["default"]("" + this.endpoint, {
|
|
@@ -3018,10 +3277,10 @@
|
|
|
3018
3277
|
headers: headers,
|
|
3019
3278
|
})];
|
|
3020
3279
|
case 1:
|
|
3021
|
-
response =
|
|
3280
|
+
response = _a.sent();
|
|
3022
3281
|
return [4 /*yield*/, response.json()];
|
|
3023
3282
|
case 2:
|
|
3024
|
-
result =
|
|
3283
|
+
result = _a.sent();
|
|
3025
3284
|
if (!lodash.isNil(result.errors))
|
|
3026
3285
|
throw new Error(JSON.stringify(result.errors));
|
|
3027
3286
|
return [2 /*return*/, result.data];
|
|
@@ -3053,12 +3312,12 @@
|
|
|
3053
3312
|
return date;
|
|
3054
3313
|
};
|
|
3055
3314
|
HasuraGraphQLMixin.prototype.convertDataFromHasura = function (data) {
|
|
3056
|
-
var plain =
|
|
3315
|
+
var plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
|
|
3057
3316
|
return this.model.toInstance(plain);
|
|
3058
3317
|
};
|
|
3059
3318
|
HasuraGraphQLMixin.prototype.convertDataToHasura = function (instance, update) {
|
|
3060
3319
|
if (update === void 0) { update = false; }
|
|
3061
|
-
return
|
|
3320
|
+
return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
|
|
3062
3321
|
};
|
|
3063
3322
|
return HasuraGraphQLMixin;
|
|
3064
3323
|
}(MixinBase));
|
|
@@ -3066,9 +3325,11 @@
|
|
|
3066
3325
|
|
|
3067
3326
|
var withUpdateHasuraGraphQL = function (MixinBase) {
|
|
3068
3327
|
var getValueByAction = function (options) {
|
|
3069
|
-
if (
|
|
3328
|
+
if (options instanceof BaseModel)
|
|
3329
|
+
return options.toPlain();
|
|
3330
|
+
if (lodash.isNil(options === null || options === void 0 ? void 0 : options.action))
|
|
3070
3331
|
return options;
|
|
3071
|
-
if (
|
|
3332
|
+
if ([exports.UpdateOptionActions.REMOVE_FIELD.toString(), exports.UpdateOptionActions.NULL.toString()].includes(options.action))
|
|
3072
3333
|
return null;
|
|
3073
3334
|
return options.value;
|
|
3074
3335
|
};
|
|
@@ -3090,11 +3351,12 @@
|
|
|
3090
3351
|
UpdateHasuraGraphQLMixin.prototype.update = function (data) {
|
|
3091
3352
|
return __awaiter(this, void 0, void 0, function () {
|
|
3092
3353
|
var plainData;
|
|
3093
|
-
|
|
3094
|
-
|
|
3354
|
+
var _this = this;
|
|
3355
|
+
return __generator(this, function (_b) {
|
|
3356
|
+
switch (_b.label) {
|
|
3095
3357
|
case 0:
|
|
3096
3358
|
plainData = this.paramsToPlain(data);
|
|
3097
|
-
return [4 /*yield*/, this.mutation(this.updateGraphQLOperation, this.model.identifiersFields, {
|
|
3359
|
+
return [4 /*yield*/, this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), {
|
|
3098
3360
|
_set: {
|
|
3099
3361
|
type: this.updateGraphQLObjectType,
|
|
3100
3362
|
value: this.convertDataToHasura(this.model.toInstance(plainData), true),
|
|
@@ -3103,7 +3365,7 @@
|
|
|
3103
3365
|
pk_columns: { type: this.updateGraphQLPKType, value: this.getUpdateModelKeys(plainData), required: true },
|
|
3104
3366
|
})];
|
|
3105
3367
|
case 1:
|
|
3106
|
-
|
|
3368
|
+
_b.sent();
|
|
3107
3369
|
return [2 /*return*/, this.model.toInstance(plainData)];
|
|
3108
3370
|
}
|
|
3109
3371
|
});
|
|
@@ -3114,14 +3376,21 @@
|
|
|
3114
3376
|
if (model.isModel(params))
|
|
3115
3377
|
return params.toPlain();
|
|
3116
3378
|
return Object.keys(params).reduce(function (data, currentKey) {
|
|
3117
|
-
var
|
|
3118
|
-
return (Object.assign(Object.assign({}, data), (
|
|
3379
|
+
var _b;
|
|
3380
|
+
return (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && (_b = {}, _b[currentKey] = getValueByAction(params[currentKey]), _b))));
|
|
3119
3381
|
}, {});
|
|
3120
3382
|
};
|
|
3121
3383
|
UpdateHasuraGraphQLMixin.prototype.getUpdateModelKeys = function (data) {
|
|
3122
|
-
|
|
3384
|
+
var _this = this;
|
|
3385
|
+
var instance = this.model.toInstance(data);
|
|
3386
|
+
return this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
3387
|
+
var _b;
|
|
3123
3388
|
var _a;
|
|
3124
|
-
|
|
3389
|
+
if (lodash.isNil(instance[identifier]))
|
|
3390
|
+
return ids;
|
|
3391
|
+
var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
|
|
3392
|
+
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];
|
|
3393
|
+
return Object.assign(Object.assign({}, ids), (_b = {}, _b[columnOption.columnName] = value, _b));
|
|
3125
3394
|
}, {});
|
|
3126
3395
|
};
|
|
3127
3396
|
return UpdateHasuraGraphQLMixin;
|
|
@@ -3146,24 +3415,25 @@
|
|
|
3146
3415
|
return __awaiter(this, void 0, void 0, function () {
|
|
3147
3416
|
var instance, result, data;
|
|
3148
3417
|
var _this = this;
|
|
3149
|
-
return __generator(this, function (
|
|
3150
|
-
switch (
|
|
3418
|
+
return __generator(this, function (_b) {
|
|
3419
|
+
switch (_b.label) {
|
|
3151
3420
|
case 0:
|
|
3152
3421
|
instance = this.model.toInstance(identifiers);
|
|
3153
3422
|
return [4 /*yield*/, this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce(function (ids, identifier) {
|
|
3423
|
+
var _b;
|
|
3154
3424
|
var _a;
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3425
|
+
if (lodash.isNil(instance[identifier]))
|
|
3426
|
+
return ids;
|
|
3427
|
+
var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
|
|
3428
|
+
var value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
|
|
3429
|
+
return Object.assign(Object.assign({}, ids), (_b = {}, _b[columnOption.columnName] = {
|
|
3430
|
+
type: _this.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3431
|
+
value: value,
|
|
3432
|
+
required: true,
|
|
3433
|
+
}, _b));
|
|
3164
3434
|
}, {}))];
|
|
3165
3435
|
case 1:
|
|
3166
|
-
result =
|
|
3436
|
+
result = _b.sent();
|
|
3167
3437
|
data = result[this.getGraphQLOperation];
|
|
3168
3438
|
if (lodash.isNil(data))
|
|
3169
3439
|
throw new NotFoundError(instance.constructor.name + " not found");
|
|
@@ -3205,60 +3475,53 @@
|
|
|
3205
3475
|
})(HasuraGraphQLColumnType || (HasuraGraphQLColumnType = {}));
|
|
3206
3476
|
|
|
3207
3477
|
var withFindHasuraGraphQL = function (MixinBase) {
|
|
3208
|
-
var checkIfIsFilterOption = function (filter) { return !lodash.isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
|
|
3209
|
-
var getValueFromFilter = function (filter, fieldOption) {
|
|
3210
|
-
if (!checkIfIsFilterOption(filter))
|
|
3211
|
-
return filter;
|
|
3212
|
-
if (filter.operator === exports.Where.ISNULL)
|
|
3213
|
-
return true;
|
|
3214
|
-
if (filter.operator === exports.Where.ISNOTNULL)
|
|
3215
|
-
return false;
|
|
3216
|
-
var converter = fieldOption.to ? fieldOption.to : function (value) { return value; };
|
|
3217
|
-
return Array.isArray(filter.value) && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
|
|
3218
|
-
? filter.value.map(function (fieldValue) { return converter(fieldValue); })
|
|
3219
|
-
: converter(filter.value);
|
|
3220
|
-
};
|
|
3221
3478
|
return /** @class */ (function (_super) {
|
|
3222
3479
|
__extends(FindHasuraGraphQLMixin, _super);
|
|
3223
3480
|
function FindHasuraGraphQLMixin() {
|
|
3224
3481
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3225
3482
|
_this.makeGraphQLWhere = function (filter, fields) { return Object.keys(filter).reduce(function (variables, fieldName) {
|
|
3226
|
-
var
|
|
3227
|
-
|
|
3228
|
-
|
|
3483
|
+
var _b;
|
|
3484
|
+
var columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
|
|
3485
|
+
if (!columnOption.bindFindFilter)
|
|
3486
|
+
return Object.assign(Object.assign({}, variables), (_b = {}, _b[columnOption.columnName] = _this.buildWhereSentence(fieldName, filter[fieldName], fields), _b));
|
|
3487
|
+
var builtFilter = columnOption.bindFindFilter(filter[fieldName]);
|
|
3488
|
+
return Object.assign(Object.assign({}, variables), Object.keys(builtFilter).reduce(function (variablesList, columnName) {
|
|
3489
|
+
var _b;
|
|
3490
|
+
return (Object.assign(Object.assign({}, variablesList), (_b = {}, _b[columnName] = _this.buildWhereSentence(fieldName, builtFilter[columnName], fields), _b)));
|
|
3491
|
+
}, {}));
|
|
3229
3492
|
}, {}); };
|
|
3230
3493
|
_this.buildWhereSentence = function (field, options, fields) {
|
|
3231
|
-
var
|
|
3232
|
-
var fieldSentenceOptions = AttributeOptionHelper.
|
|
3494
|
+
var _b;
|
|
3495
|
+
var fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
3233
3496
|
if (!Array.isArray(options) &&
|
|
3234
3497
|
lodash.isObject(options) &&
|
|
3235
3498
|
lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) &&
|
|
3236
3499
|
lodash.isNil(options === null || options === void 0 ? void 0 : options.value) &&
|
|
3237
3500
|
lodash.isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
|
|
3238
3501
|
return Object.keys(options).reduce(function (variables, key) {
|
|
3239
|
-
var
|
|
3240
|
-
var fieldOptions = AttributeOptionHelper.
|
|
3502
|
+
var _b;
|
|
3503
|
+
var fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
3241
3504
|
var columnName = fieldOptions.columnName;
|
|
3242
3505
|
var columnFields = fieldOptions.fields;
|
|
3243
|
-
return Object.assign(Object.assign({}, variables), (
|
|
3506
|
+
return Object.assign(Object.assign({}, variables), (_b = {}, _b[columnName] = _this.buildWhereSentence(key, options[key], columnFields || []), _b));
|
|
3244
3507
|
}, {});
|
|
3245
3508
|
if (!Array.isArray(options) && !lodash.isNil(fieldSentenceOptions.fields))
|
|
3246
|
-
return
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
if (lodash.isObject(options) && !
|
|
3509
|
+
return _b = {},
|
|
3510
|
+
_b[fieldSentenceOptions.fields[0]] = _this.buildOperatorSentence(options, fieldSentenceOptions),
|
|
3511
|
+
_b;
|
|
3512
|
+
if (lodash.isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
3250
3513
|
options = Object.values(options)[0];
|
|
3251
3514
|
return Array.isArray(options)
|
|
3252
3515
|
? options.reduce(function (whereSentence, option) { return (Object.assign(Object.assign({}, whereSentence), _this.buildOperatorSentence(option, fieldSentenceOptions))); }, {})
|
|
3253
3516
|
: _this.buildOperatorSentence(options, fieldSentenceOptions);
|
|
3254
3517
|
};
|
|
3255
3518
|
_this.buildOperatorSentence = function (options, fieldOption) {
|
|
3256
|
-
var
|
|
3257
|
-
return (
|
|
3258
|
-
|
|
3259
|
-
|
|
3519
|
+
var _b;
|
|
3520
|
+
return (_b = {},
|
|
3521
|
+
_b[_this.getHasuraOperator(options, fieldOption)] = FilterOptionHelper.GetValueFromFilter(options, fieldOption),
|
|
3522
|
+
_b);
|
|
3260
3523
|
};
|
|
3261
|
-
_this.getHasuraOperator = function (options, fieldOption) { return
|
|
3524
|
+
_this.getHasuraOperator = function (options, fieldOption) { return FilterOptionHelper.CheckIfIsFilterOption(options)
|
|
3262
3525
|
? fieldOption.type === HasuraGraphQLColumnType.Jsonb
|
|
3263
3526
|
? _this.getHasuraJsonbOperator(options)
|
|
3264
3527
|
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find(function (graphQLOperator) { return graphQLOperator === Object.keys(exports.Where).find(function (operator) { return exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator); }); })]
|
|
@@ -3272,12 +3535,12 @@
|
|
|
3272
3535
|
}
|
|
3273
3536
|
FindHasuraGraphQLMixin.prototype.find = function (options) {
|
|
3274
3537
|
return __awaiter(this, void 0, void 0, function () {
|
|
3275
|
-
var
|
|
3538
|
+
var _b, filters, limits, orderBy, variablesCount, variables, result, data, count;
|
|
3276
3539
|
var _this = this;
|
|
3277
|
-
return __generator(this, function (
|
|
3278
|
-
switch (
|
|
3540
|
+
return __generator(this, function (_c) {
|
|
3541
|
+
switch (_c.label) {
|
|
3279
3542
|
case 0:
|
|
3280
|
-
|
|
3543
|
+
_b = options || {}, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy;
|
|
3281
3544
|
variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy) ? {} : { order_by: { type: this.tableName + "_order_by!", list: true, value: orderBy } })), (lodash.isNil(filters)
|
|
3282
3545
|
? {}
|
|
3283
3546
|
: {
|
|
@@ -3288,11 +3551,17 @@
|
|
|
3288
3551
|
},
|
|
3289
3552
|
}));
|
|
3290
3553
|
variables = Object.assign(Object.assign({}, (lodash.isNil(limits) ? {} : limits)), variablesCount);
|
|
3291
|
-
console.log(JSON.stringify(variables));
|
|
3292
3554
|
return [4 /*yield*/, this.query([
|
|
3293
3555
|
{
|
|
3294
3556
|
operation: this.tableName,
|
|
3295
|
-
fields:
|
|
3557
|
+
fields: options.fields
|
|
3558
|
+
? options.fields
|
|
3559
|
+
.map(function (fieldName) {
|
|
3560
|
+
var _a;
|
|
3561
|
+
return (_a = _this.fields.find(function (fieldOption) { return fieldOption === fieldName; })) !== null && _a !== void 0 ? _a : _this.fields.find(function (fieldOption) { return Object.keys(fieldOption).shift() === fieldName; });
|
|
3562
|
+
})
|
|
3563
|
+
.filter(Boolean)
|
|
3564
|
+
: this.fields,
|
|
3296
3565
|
variables: variables,
|
|
3297
3566
|
},
|
|
3298
3567
|
{
|
|
@@ -3302,8 +3571,8 @@
|
|
|
3302
3571
|
},
|
|
3303
3572
|
])];
|
|
3304
3573
|
case 1:
|
|
3305
|
-
result =
|
|
3306
|
-
data = result[this.tableName].map(function (
|
|
3574
|
+
result = _c.sent();
|
|
3575
|
+
data = result[this.tableName].map(function (row) { return _this.convertDataFromHasura(row); });
|
|
3307
3576
|
count = result[this.tableName + "_aggregate"].aggregate.count;
|
|
3308
3577
|
return [2 /*return*/, { count: count, data: data }];
|
|
3309
3578
|
}
|
|
@@ -3324,32 +3593,90 @@
|
|
|
3324
3593
|
}(withUpdateHasuraGraphQL(withGetHasuraGraphQL(withFindHasuraGraphQL(withDeleteHasuraGraphQL(withCreateHasuraGraphQL(MixinBase)))))));
|
|
3325
3594
|
};
|
|
3326
3595
|
|
|
3327
|
-
var
|
|
3328
|
-
__extends(
|
|
3329
|
-
function
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3596
|
+
var CategoryHasuraGraphQL = /** @class */ (function (_super) {
|
|
3597
|
+
__extends(CategoryHasuraGraphQL, _super);
|
|
3598
|
+
function CategoryHasuraGraphQL() {
|
|
3599
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3600
|
+
}
|
|
3601
|
+
return CategoryHasuraGraphQL;
|
|
3602
|
+
}(Category));
|
|
3603
|
+
|
|
3604
|
+
var ProductHasuraGraphQL = /** @class */ (function (_super) {
|
|
3605
|
+
__extends(ProductHasuraGraphQL, _super);
|
|
3606
|
+
function ProductHasuraGraphQL() {
|
|
3607
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3608
|
+
}
|
|
3609
|
+
return ProductHasuraGraphQL;
|
|
3610
|
+
}(Product));
|
|
3611
|
+
__decorate([
|
|
3612
|
+
classTransformer.Type(function () { return KitProductHasuraGraphQL; }),
|
|
3613
|
+
__metadata("design:type", Array)
|
|
3614
|
+
], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
|
|
3615
|
+
|
|
3616
|
+
var KitProductHasuraGraphQL = /** @class */ (function (_super) {
|
|
3617
|
+
__extends(KitProductHasuraGraphQL, _super);
|
|
3618
|
+
function KitProductHasuraGraphQL() {
|
|
3619
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
3620
|
+
}
|
|
3621
|
+
return KitProductHasuraGraphQL;
|
|
3622
|
+
}(KitProduct));
|
|
3623
|
+
__decorate([
|
|
3624
|
+
classTransformer.Type(function () { return ProductHasuraGraphQL; }),
|
|
3625
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
3626
|
+
], KitProductHasuraGraphQL.prototype, "kit", void 0);
|
|
3627
|
+
__decorate([
|
|
3628
|
+
classTransformer.Type(function () { return ProductHasuraGraphQL; }),
|
|
3629
|
+
__metadata("design:type", ProductHasuraGraphQL)
|
|
3630
|
+
], KitProductHasuraGraphQL.prototype, "product", void 0);
|
|
3631
|
+
|
|
3632
|
+
var VariantHasuraGraphQL = /** @class */ (function (_super) {
|
|
3633
|
+
__extends(VariantHasuraGraphQL, _super);
|
|
3634
|
+
function VariantHasuraGraphQL() {
|
|
3635
|
+
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
3636
|
+
_this.name = '';
|
|
3637
|
+
_this.hasVariants = false;
|
|
3638
|
+
return _this;
|
|
3639
|
+
}
|
|
3640
|
+
return VariantHasuraGraphQL;
|
|
3641
|
+
}(Variant));
|
|
3642
|
+
|
|
3643
|
+
var CategoryHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
3644
|
+
__extends(CategoryHasuraGraphQLRepository, _super_1);
|
|
3645
|
+
function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository) {
|
|
3646
|
+
var _this = _super_1.call(this, {
|
|
3647
|
+
tableName: 'category',
|
|
3648
|
+
model: Category,
|
|
3649
|
+
endpoint: endpoint,
|
|
3650
|
+
authOptions: authOptions,
|
|
3651
|
+
fields: [
|
|
3652
|
+
{ id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
|
|
3653
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
3654
|
+
'name',
|
|
3655
|
+
'description',
|
|
3656
|
+
'image',
|
|
3657
|
+
'published',
|
|
3658
|
+
'shop',
|
|
3659
|
+
'slug',
|
|
3344
3660
|
{ brandCategory: { columnName: 'brand_category' } },
|
|
3345
3661
|
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
3346
3662
|
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
3347
3663
|
{ brandLogo: { columnName: 'brand_logo' } },
|
|
3348
|
-
{
|
|
3664
|
+
{ brandCondition: { columnName: 'brand_condition' } },
|
|
3349
3665
|
{
|
|
3350
3666
|
conditions: {
|
|
3351
3667
|
columnName: 'tag_condition',
|
|
3352
|
-
|
|
3668
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
3669
|
+
from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
|
|
3670
|
+
bindPersistData: function (value) {
|
|
3671
|
+
var _a, _b;
|
|
3672
|
+
return {
|
|
3673
|
+
brand_condition: value.brand,
|
|
3674
|
+
tag_condition: "{\"" + (((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || '') + "\"}",
|
|
3675
|
+
};
|
|
3676
|
+
},
|
|
3677
|
+
bindFindFilter: function (sentence) {
|
|
3678
|
+
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
3679
|
+
},
|
|
3353
3680
|
},
|
|
3354
3681
|
},
|
|
3355
3682
|
'filters',
|
|
@@ -3360,6 +3687,9 @@
|
|
|
3360
3687
|
columnName: 'products',
|
|
3361
3688
|
fields: ['product_id'],
|
|
3362
3689
|
from: function (value) { return value.map(function (product) { return product.product_id.toString(); }); },
|
|
3690
|
+
to: function (productIds) { return productIds.map(function (productId) { return ({
|
|
3691
|
+
product_id: +productId,
|
|
3692
|
+
}); }); },
|
|
3363
3693
|
},
|
|
3364
3694
|
},
|
|
3365
3695
|
],
|
|
@@ -3373,34 +3703,34 @@
|
|
|
3373
3703
|
});
|
|
3374
3704
|
var _a;
|
|
3375
3705
|
return __awaiter(this, void 0, void 0, function () {
|
|
3376
|
-
var
|
|
3377
|
-
return __generator(this, function (
|
|
3378
|
-
switch (
|
|
3706
|
+
var _c;
|
|
3707
|
+
return __generator(this, function (_d) {
|
|
3708
|
+
switch (_d.label) {
|
|
3379
3709
|
case 0:
|
|
3380
3710
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
3381
|
-
return [4 /*yield*/, this.find({ filters: {
|
|
3711
|
+
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
3382
3712
|
case 1:
|
|
3383
|
-
|
|
3713
|
+
_c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
3384
3714
|
return [3 /*break*/, 3];
|
|
3385
3715
|
case 2:
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
case 3: return [2 /*return*/,
|
|
3716
|
+
_c = _super.get.call(this, identifiers);
|
|
3717
|
+
_d.label = 3;
|
|
3718
|
+
case 3: return [2 /*return*/, _c];
|
|
3389
3719
|
}
|
|
3390
3720
|
});
|
|
3391
3721
|
});
|
|
3392
3722
|
};
|
|
3393
3723
|
CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
|
|
3394
3724
|
return __awaiter(this, void 0, void 0, function () {
|
|
3395
|
-
var
|
|
3396
|
-
return __generator(this, function (
|
|
3397
|
-
switch (
|
|
3725
|
+
var _c, data, count;
|
|
3726
|
+
return __generator(this, function (_d) {
|
|
3727
|
+
switch (_d.label) {
|
|
3398
3728
|
case 0:
|
|
3399
3729
|
if (!slug)
|
|
3400
3730
|
return [2 /*return*/];
|
|
3401
3731
|
return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
|
|
3402
3732
|
case 1:
|
|
3403
|
-
|
|
3733
|
+
_c = _d.sent(), data = _c.data, count = _c.count;
|
|
3404
3734
|
if (count > 1)
|
|
3405
3735
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3406
3736
|
if (!count)
|
|
@@ -3413,33 +3743,33 @@
|
|
|
3413
3743
|
CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
|
|
3414
3744
|
if (limit === void 0) { limit = 4; }
|
|
3415
3745
|
return __awaiter(this, void 0, void 0, function () {
|
|
3416
|
-
var
|
|
3746
|
+
var _c, categories, count, homeSections;
|
|
3417
3747
|
var _this = this;
|
|
3418
|
-
return __generator(this, function (
|
|
3419
|
-
switch (
|
|
3748
|
+
return __generator(this, function (_d) {
|
|
3749
|
+
switch (_d.label) {
|
|
3420
3750
|
case 0: return [4 /*yield*/, this.find({
|
|
3421
|
-
filters: {
|
|
3751
|
+
filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
|
|
3422
3752
|
})];
|
|
3423
3753
|
case 1:
|
|
3424
|
-
|
|
3754
|
+
_c = _d.sent(), categories = _c.data, count = _c.count;
|
|
3425
3755
|
if (!count)
|
|
3426
3756
|
throw new NotFoundError('Categories not found');
|
|
3427
3757
|
return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
|
|
3428
|
-
var
|
|
3429
|
-
return __generator(this, function (
|
|
3430
|
-
switch (
|
|
3758
|
+
var _c;
|
|
3759
|
+
return __generator(this, function (_d) {
|
|
3760
|
+
switch (_d.label) {
|
|
3431
3761
|
case 0:
|
|
3432
|
-
|
|
3762
|
+
_c = {
|
|
3433
3763
|
category: category
|
|
3434
3764
|
};
|
|
3435
3765
|
return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
|
|
3436
|
-
case 1: return [2 /*return*/, (
|
|
3437
|
-
|
|
3766
|
+
case 1: return [2 /*return*/, (_c.products = _d.sent(),
|
|
3767
|
+
_c)];
|
|
3438
3768
|
}
|
|
3439
3769
|
});
|
|
3440
3770
|
}); }))];
|
|
3441
3771
|
case 2:
|
|
3442
|
-
homeSections =
|
|
3772
|
+
homeSections = _d.sent();
|
|
3443
3773
|
return [2 /*return*/, homeSections];
|
|
3444
3774
|
}
|
|
3445
3775
|
});
|
|
@@ -3448,23 +3778,40 @@
|
|
|
3448
3778
|
CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
|
|
3449
3779
|
return __awaiter(this, void 0, void 0, function () {
|
|
3450
3780
|
var products, publishedField, productsData;
|
|
3451
|
-
var
|
|
3452
|
-
return __generator(this, function (
|
|
3453
|
-
switch (
|
|
3781
|
+
var _c;
|
|
3782
|
+
return __generator(this, function (_d) {
|
|
3783
|
+
switch (_d.label) {
|
|
3454
3784
|
case 0:
|
|
3455
3785
|
if (!category.products)
|
|
3456
3786
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3457
|
-
console.log(category);
|
|
3458
|
-
console.log(category.products);
|
|
3459
3787
|
products = [];
|
|
3460
3788
|
publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
3461
|
-
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: (
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3789
|
+
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
|
|
3790
|
+
'id',
|
|
3791
|
+
'name',
|
|
3792
|
+
'slug',
|
|
3793
|
+
'images',
|
|
3794
|
+
'miniatures',
|
|
3795
|
+
'price',
|
|
3796
|
+
'fullPrice',
|
|
3797
|
+
'subscriberDiscountPercentage',
|
|
3798
|
+
'subscriberPrice',
|
|
3799
|
+
'stock',
|
|
3800
|
+
'published',
|
|
3801
|
+
'publishedGlam',
|
|
3802
|
+
'CEST',
|
|
3803
|
+
'EAN',
|
|
3804
|
+
'NCM',
|
|
3805
|
+
'brand',
|
|
3806
|
+
'costPrice',
|
|
3807
|
+
'hasVariants',
|
|
3808
|
+
'isKit',
|
|
3809
|
+
'shopAvailability',
|
|
3810
|
+
'sku',
|
|
3811
|
+
'rate',
|
|
3812
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
|
|
3466
3813
|
case 1:
|
|
3467
|
-
productsData = (
|
|
3814
|
+
productsData = (_d.sent()).data;
|
|
3468
3815
|
products.push.apply(products, __spreadArray([], __read(productsData)));
|
|
3469
3816
|
return [2 /*return*/, products];
|
|
3470
3817
|
}
|
|
@@ -3474,97 +3821,720 @@
|
|
|
3474
3821
|
return CategoryHasuraGraphQLRepository;
|
|
3475
3822
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3476
3823
|
|
|
3477
|
-
var ProductHasuraGraphQLRepository = /** @class */ (function (
|
|
3478
|
-
__extends(ProductHasuraGraphQLRepository,
|
|
3824
|
+
var ProductHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
3825
|
+
__extends(ProductHasuraGraphQLRepository, _super_1);
|
|
3479
3826
|
function ProductHasuraGraphQLRepository(endpoint, authOptions) {
|
|
3480
|
-
|
|
3827
|
+
var _this = _super_1.call(this, {
|
|
3481
3828
|
tableName: 'product',
|
|
3482
|
-
model:
|
|
3829
|
+
model: ProductHasuraGraphQL,
|
|
3830
|
+
endpoint: endpoint,
|
|
3831
|
+
authOptions: authOptions,
|
|
3832
|
+
fields: [],
|
|
3833
|
+
}) || this;
|
|
3834
|
+
_this.bindReviewToModel = function (plain) { return (Object.assign(Object.assign({}, lodash.omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id })); };
|
|
3835
|
+
_this.bindReviewToHasura = function (review) { return (Object.assign(Object.assign({}, lodash.omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])), { person_id: review.personId, order_id: review.orderId })); };
|
|
3836
|
+
var commonFields = [
|
|
3837
|
+
{ id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
|
|
3838
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
3839
|
+
{ productId: { columnName: 'main_product_id' } },
|
|
3840
|
+
{ CEST: { columnName: 'cest' } },
|
|
3841
|
+
{ EAN: { columnName: 'ean' } },
|
|
3842
|
+
{ NCM: { columnName: 'ncm' } },
|
|
3843
|
+
'brand',
|
|
3844
|
+
{ costPrice: { columnName: 'cost_price' } },
|
|
3845
|
+
{
|
|
3846
|
+
description: {
|
|
3847
|
+
columnName: 'description',
|
|
3848
|
+
from: function (description) { return Object.values(exports.Shops).reduce(function (shops, shop) {
|
|
3849
|
+
var _c;
|
|
3850
|
+
return (Object.assign(Object.assign({}, shops), (_c = {}, _c[shop] = { description: description }, _c)));
|
|
3851
|
+
}, {}); },
|
|
3852
|
+
to: function (value) { return Object.values(value).shift().description; },
|
|
3853
|
+
},
|
|
3854
|
+
},
|
|
3855
|
+
{ hasVariants: { columnName: 'has_variants' } },
|
|
3856
|
+
{ images: { columnName: 'images', to: function (value) { var _a; return "{\"" + (((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, "\",\"")) || '') + "\"}"; } } },
|
|
3857
|
+
{ miniatures: { columnName: 'miniatures', to: function (value) { var _a; return "{\"" + (((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, "\",\"")) || '') + "\"}"; } } },
|
|
3858
|
+
'name',
|
|
3859
|
+
{
|
|
3860
|
+
price: {
|
|
3861
|
+
columnName: 'price',
|
|
3862
|
+
from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
|
|
3863
|
+
var _c;
|
|
3864
|
+
return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
|
|
3865
|
+
price: price,
|
|
3866
|
+
fullPrice: data.full_price,
|
|
3867
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
3868
|
+
subscriberPrice: data.subscriber_price,
|
|
3869
|
+
}, _c)));
|
|
3870
|
+
}, {}); },
|
|
3871
|
+
bindFindFilter: function (sentence) {
|
|
3872
|
+
var filters = Object.values(sentence).shift();
|
|
3873
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
3874
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
3875
|
+
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
3876
|
+
subscriber_price: filters.subscriberPrice,
|
|
3877
|
+
}));
|
|
3878
|
+
},
|
|
3879
|
+
bindPersistData: function (value) {
|
|
3880
|
+
var priceData = Object.values(value).shift();
|
|
3881
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
3882
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3883
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
3884
|
+
},
|
|
3885
|
+
},
|
|
3886
|
+
},
|
|
3887
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
3888
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
3889
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
3890
|
+
'published',
|
|
3891
|
+
{ publishedGlam: { columnName: 'published_glam' } },
|
|
3892
|
+
'sku',
|
|
3893
|
+
{
|
|
3894
|
+
stock: {
|
|
3895
|
+
columnName: 'stock',
|
|
3896
|
+
from: function (quantity) { return ({ quantity: quantity }); },
|
|
3897
|
+
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); },
|
|
3898
|
+
},
|
|
3899
|
+
},
|
|
3900
|
+
'slug',
|
|
3901
|
+
'type',
|
|
3902
|
+
'video',
|
|
3903
|
+
'weight',
|
|
3904
|
+
{
|
|
3905
|
+
shopAvailability: {
|
|
3906
|
+
columnName: 'shop_availabilities',
|
|
3907
|
+
fields: ['shop'],
|
|
3908
|
+
from: function (shop) { return (Array.isArray(shop) ? shop.map(function (row) { return row.shop; }) : []); },
|
|
3909
|
+
bindPersistData: function (shops) { return ({ shop_availabilities: { data: shops.map(function (shop) { return ({ shop: shop }); }) } }); },
|
|
3910
|
+
},
|
|
3911
|
+
},
|
|
3912
|
+
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3913
|
+
{ isKit: { columnName: 'is_kit' } },
|
|
3914
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
3915
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3916
|
+
{
|
|
3917
|
+
rate: {
|
|
3918
|
+
columnName: 'reviews_aggregate',
|
|
3919
|
+
fields: [{ aggregate: [{ avg: ['rate'] }] }],
|
|
3920
|
+
from: function (value) { return value.aggregate.avg.rate; },
|
|
3921
|
+
},
|
|
3922
|
+
},
|
|
3923
|
+
];
|
|
3924
|
+
_this.fields = __spreadArray(__spreadArray([], __read(commonFields)), [
|
|
3925
|
+
{
|
|
3926
|
+
categories: {
|
|
3927
|
+
columnName: 'categories',
|
|
3928
|
+
fields: ['category_id'],
|
|
3929
|
+
bindPersistData: function (value) { return ({
|
|
3930
|
+
categories: { data: value.map(function (category) { return ({ category_id: +category }); }) },
|
|
3931
|
+
}); },
|
|
3932
|
+
to: function (categories) { return categories.map(function (categoryId) { return +categoryId; }); },
|
|
3933
|
+
from: function (categories) { return (categories === null || categories === void 0 ? void 0 : categories.map(function (category) { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || []; },
|
|
3934
|
+
},
|
|
3935
|
+
},
|
|
3936
|
+
{
|
|
3937
|
+
kitProducts: {
|
|
3938
|
+
columnName: 'kit_products',
|
|
3939
|
+
foreignKeyColumn: { productId: 'id' },
|
|
3940
|
+
fields: [
|
|
3941
|
+
{ productId: { columnName: 'product_id' } },
|
|
3942
|
+
{ kitProductId: { columnName: 'kit_product_id' } },
|
|
3943
|
+
'quantity',
|
|
3944
|
+
{ product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
|
|
3945
|
+
],
|
|
3946
|
+
},
|
|
3947
|
+
},
|
|
3948
|
+
]);
|
|
3949
|
+
return _this;
|
|
3950
|
+
}
|
|
3951
|
+
Object.defineProperty(ProductHasuraGraphQLRepository.prototype, "reviewsFields", {
|
|
3952
|
+
get: function () {
|
|
3953
|
+
return [
|
|
3954
|
+
'id',
|
|
3955
|
+
'shop',
|
|
3956
|
+
'rate',
|
|
3957
|
+
'author',
|
|
3958
|
+
'email',
|
|
3959
|
+
'location',
|
|
3960
|
+
'review',
|
|
3961
|
+
'status',
|
|
3962
|
+
'title',
|
|
3963
|
+
'person_id',
|
|
3964
|
+
'points',
|
|
3965
|
+
'order_id',
|
|
3966
|
+
'created_at',
|
|
3967
|
+
'updated_at',
|
|
3968
|
+
];
|
|
3969
|
+
},
|
|
3970
|
+
enumerable: false,
|
|
3971
|
+
configurable: true
|
|
3972
|
+
});
|
|
3973
|
+
ProductHasuraGraphQLRepository.prototype.create = function (data) {
|
|
3974
|
+
var _super = Object.create(null, {
|
|
3975
|
+
create: { get: function () { return _super_1.prototype.create; } }
|
|
3976
|
+
});
|
|
3977
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3978
|
+
var product, _c, error_1;
|
|
3979
|
+
return __generator(this, function (_d) {
|
|
3980
|
+
switch (_d.label) {
|
|
3981
|
+
case 0: return [4 /*yield*/, _super.create.call(this, lodash.omit(data, ['reviews']))];
|
|
3982
|
+
case 1:
|
|
3983
|
+
product = _d.sent();
|
|
3984
|
+
_d.label = 2;
|
|
3985
|
+
case 2:
|
|
3986
|
+
_d.trys.push([2, 4, , 6]);
|
|
3987
|
+
_c = product;
|
|
3988
|
+
return [4 /*yield*/, this.updateReviews(+product.id, data)];
|
|
3989
|
+
case 3:
|
|
3990
|
+
_c.reviews = _d.sent();
|
|
3991
|
+
return [3 /*break*/, 6];
|
|
3992
|
+
case 4:
|
|
3993
|
+
error_1 = _d.sent();
|
|
3994
|
+
return [4 /*yield*/, this.delete({ id: product.id })];
|
|
3995
|
+
case 5:
|
|
3996
|
+
_d.sent();
|
|
3997
|
+
throw error_1;
|
|
3998
|
+
case 6: return [2 /*return*/, product];
|
|
3999
|
+
}
|
|
4000
|
+
});
|
|
4001
|
+
});
|
|
4002
|
+
};
|
|
4003
|
+
ProductHasuraGraphQLRepository.prototype.get = function (identifiers) {
|
|
4004
|
+
var _super = Object.create(null, {
|
|
4005
|
+
get: { get: function () { return _super_1.prototype.get; } }
|
|
4006
|
+
});
|
|
4007
|
+
var _a;
|
|
4008
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4009
|
+
var product, _c, _d;
|
|
4010
|
+
return __generator(this, function (_e) {
|
|
4011
|
+
switch (_e.label) {
|
|
4012
|
+
case 0:
|
|
4013
|
+
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
4014
|
+
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
4015
|
+
case 1:
|
|
4016
|
+
_c = (_a = (_e.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
4017
|
+
return [3 /*break*/, 4];
|
|
4018
|
+
case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
|
|
4019
|
+
case 3:
|
|
4020
|
+
_c = _e.sent();
|
|
4021
|
+
_e.label = 4;
|
|
4022
|
+
case 4:
|
|
4023
|
+
product = _c;
|
|
4024
|
+
_d = product;
|
|
4025
|
+
return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
|
|
4026
|
+
case 5:
|
|
4027
|
+
_d.reviews = _e.sent();
|
|
4028
|
+
return [2 /*return*/, product];
|
|
4029
|
+
}
|
|
4030
|
+
});
|
|
4031
|
+
});
|
|
4032
|
+
};
|
|
4033
|
+
ProductHasuraGraphQLRepository.prototype.find = function (params) {
|
|
4034
|
+
var _super = Object.create(null, {
|
|
4035
|
+
find: { get: function () { return _super_1.prototype.find; } }
|
|
4036
|
+
});
|
|
4037
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4038
|
+
var _a, filters, options;
|
|
4039
|
+
return __generator(this, function (_c) {
|
|
4040
|
+
_a = params || {}, filters = _a.filters, options = __rest(_a, ["filters"]);
|
|
4041
|
+
return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }) }))];
|
|
4042
|
+
});
|
|
4043
|
+
});
|
|
4044
|
+
};
|
|
4045
|
+
ProductHasuraGraphQLRepository.prototype.getBySlug = function (slug) {
|
|
4046
|
+
var _a;
|
|
4047
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4048
|
+
var result, product, _c;
|
|
4049
|
+
return __generator(this, function (_d) {
|
|
4050
|
+
switch (_d.label) {
|
|
4051
|
+
case 0: return [4 /*yield*/, this.find({
|
|
4052
|
+
filters: {
|
|
4053
|
+
slug: slug,
|
|
4054
|
+
},
|
|
4055
|
+
})];
|
|
4056
|
+
case 1:
|
|
4057
|
+
result = _d.sent();
|
|
4058
|
+
product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
4059
|
+
_c = product;
|
|
4060
|
+
return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
|
|
4061
|
+
case 2:
|
|
4062
|
+
_c.reviews = _d.sent();
|
|
4063
|
+
return [2 /*return*/, product];
|
|
4064
|
+
}
|
|
4065
|
+
});
|
|
4066
|
+
});
|
|
4067
|
+
};
|
|
4068
|
+
ProductHasuraGraphQLRepository.prototype.update = function (params) {
|
|
4069
|
+
var _super = Object.create(null, {
|
|
4070
|
+
update: { get: function () { return _super_1.prototype.update; } }
|
|
4071
|
+
});
|
|
4072
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4073
|
+
var categories, kitProducts, reviews, checkId, shopAvailability, rate, data, plainData, id, product, _c, _d, _e, _f, _g, _h;
|
|
4074
|
+
return __generator(this, function (_j) {
|
|
4075
|
+
switch (_j.label) {
|
|
4076
|
+
case 0:
|
|
4077
|
+
categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, shopAvailability = params.shopAvailability, rate = params.rate, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "shopAvailability", "rate"]);
|
|
4078
|
+
plainData = this.paramsToPlain({ id: checkId });
|
|
4079
|
+
return [4 /*yield*/, this.getId(plainData.id)];
|
|
4080
|
+
case 1:
|
|
4081
|
+
id = _j.sent();
|
|
4082
|
+
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
4083
|
+
case 2:
|
|
4084
|
+
product = _j.sent();
|
|
4085
|
+
_c = product;
|
|
4086
|
+
_d = categories;
|
|
4087
|
+
if (!_d) return [3 /*break*/, 4];
|
|
4088
|
+
return [4 /*yield*/, this.updateCategories(+id, { categories: categories })];
|
|
4089
|
+
case 3:
|
|
4090
|
+
_d = (_j.sent());
|
|
4091
|
+
_j.label = 4;
|
|
4092
|
+
case 4:
|
|
4093
|
+
_c.categories = _d;
|
|
4094
|
+
_e = product;
|
|
4095
|
+
_f = kitProducts;
|
|
4096
|
+
if (!_f) return [3 /*break*/, 6];
|
|
4097
|
+
return [4 /*yield*/, this.updateKitProducts(+id, { kitProducts: kitProducts })];
|
|
4098
|
+
case 5:
|
|
4099
|
+
_f = (_j.sent());
|
|
4100
|
+
_j.label = 6;
|
|
4101
|
+
case 6:
|
|
4102
|
+
_e.kitProducts = _f;
|
|
4103
|
+
_g = product;
|
|
4104
|
+
_h = reviews;
|
|
4105
|
+
if (!_h) return [3 /*break*/, 8];
|
|
4106
|
+
return [4 /*yield*/, this.updateReviews(+id, { reviews: reviews })];
|
|
4107
|
+
case 7:
|
|
4108
|
+
_h = (_j.sent());
|
|
4109
|
+
_j.label = 8;
|
|
4110
|
+
case 8:
|
|
4111
|
+
_g.reviews = _h;
|
|
4112
|
+
return [2 /*return*/, product];
|
|
4113
|
+
}
|
|
4114
|
+
});
|
|
4115
|
+
});
|
|
4116
|
+
};
|
|
4117
|
+
ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
|
|
4118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4119
|
+
var reviews, data;
|
|
4120
|
+
var _c, _d;
|
|
4121
|
+
var _this = this;
|
|
4122
|
+
return __generator(this, function (_e) {
|
|
4123
|
+
switch (_e.label) {
|
|
4124
|
+
case 0:
|
|
4125
|
+
reviews = {
|
|
4126
|
+
status: status === 'pending'
|
|
4127
|
+
? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
|
|
4128
|
+
};
|
|
4129
|
+
return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
4130
|
+
where: { value: { reviews: reviews }, type: 'product_bool_exp', required: true },
|
|
4131
|
+
})];
|
|
4132
|
+
case 1:
|
|
4133
|
+
data = (_e.sent()).product;
|
|
4134
|
+
return [2 /*return*/, data.reduce(function (reviews, product) { return __spreadArray(__spreadArray([], __read(reviews)), __read(product.reviews
|
|
4135
|
+
.filter(function (review) { return (status === 'pending' && [undefined, null].includes(review.status)) ||
|
|
4136
|
+
(status === 'approved' && review.status === true) ||
|
|
4137
|
+
(status === 'rejected' && review.status === false); })
|
|
4138
|
+
.map(function (review) { return (Object.assign(Object.assign({}, _this.bindReviewToModel(review)), { productId: product.id, productName: product.name, productSku: product.sku })); }))); }, [])];
|
|
4139
|
+
}
|
|
4140
|
+
});
|
|
4141
|
+
});
|
|
4142
|
+
};
|
|
4143
|
+
ProductHasuraGraphQLRepository.prototype.updateCategories = function (productId, _c) {
|
|
4144
|
+
var categories = _c.categories;
|
|
4145
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4146
|
+
var plainData;
|
|
4147
|
+
return __generator(this, function (_c) {
|
|
4148
|
+
switch (_c.label) {
|
|
4149
|
+
case 0:
|
|
4150
|
+
plainData = this.paramsToPlain({ categories: categories });
|
|
4151
|
+
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
4152
|
+
where: {
|
|
4153
|
+
type: 'category_product_bool_exp',
|
|
4154
|
+
required: true,
|
|
4155
|
+
value: { product_id: { _eq: productId } },
|
|
4156
|
+
},
|
|
4157
|
+
})];
|
|
4158
|
+
case 1:
|
|
4159
|
+
_c.sent();
|
|
4160
|
+
return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
|
|
4161
|
+
objects: {
|
|
4162
|
+
type: '[category_product_insert_input!]',
|
|
4163
|
+
required: true,
|
|
4164
|
+
value: plainData.categories.map(function (categoryId) { return ({ category_id: categoryId, product_id: productId }); }),
|
|
4165
|
+
},
|
|
4166
|
+
})];
|
|
4167
|
+
case 2:
|
|
4168
|
+
_c.sent();
|
|
4169
|
+
return [2 /*return*/, plainData.categories];
|
|
4170
|
+
}
|
|
4171
|
+
});
|
|
4172
|
+
});
|
|
4173
|
+
};
|
|
4174
|
+
ProductHasuraGraphQLRepository.prototype.updateKitProducts = function (productId, _c) {
|
|
4175
|
+
var kitProducts = _c.kitProducts;
|
|
4176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4177
|
+
var plainData;
|
|
4178
|
+
return __generator(this, function (_c) {
|
|
4179
|
+
switch (_c.label) {
|
|
4180
|
+
case 0:
|
|
4181
|
+
plainData = this.paramsToPlain({ kitProducts: kitProducts });
|
|
4182
|
+
return [4 /*yield*/, this.mutation('delete_product_kit', ['affected_rows'], {
|
|
4183
|
+
where: {
|
|
4184
|
+
type: 'product_kit_bool_exp',
|
|
4185
|
+
required: true,
|
|
4186
|
+
value: { product_id: { _eq: productId } },
|
|
4187
|
+
},
|
|
4188
|
+
})];
|
|
4189
|
+
case 1:
|
|
4190
|
+
_c.sent();
|
|
4191
|
+
return [4 /*yield*/, this.mutation('insert_product_kit', ['affected_rows'], {
|
|
4192
|
+
objects: {
|
|
4193
|
+
type: '[product_kit_insert_input!]',
|
|
4194
|
+
required: true,
|
|
4195
|
+
value: plainData.kitProducts.map(function (kitProduct) { return ({
|
|
4196
|
+
kit_product_id: kitProduct.productId || kitProduct.product.id,
|
|
4197
|
+
product_id: productId,
|
|
4198
|
+
quantity: kitProduct.quantity,
|
|
4199
|
+
}); }),
|
|
4200
|
+
},
|
|
4201
|
+
})];
|
|
4202
|
+
case 2:
|
|
4203
|
+
_c.sent();
|
|
4204
|
+
return [2 /*return*/, plainData.kitProducts];
|
|
4205
|
+
}
|
|
4206
|
+
});
|
|
4207
|
+
});
|
|
4208
|
+
};
|
|
4209
|
+
ProductHasuraGraphQLRepository.prototype.updateReviews = function (productId, _c) {
|
|
4210
|
+
var reviews = _c.reviews;
|
|
4211
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4212
|
+
var reviewIds_1, plainData;
|
|
4213
|
+
var _this = this;
|
|
4214
|
+
return __generator(this, function (_c) {
|
|
4215
|
+
switch (_c.label) {
|
|
4216
|
+
case 0:
|
|
4217
|
+
if (!reviews)
|
|
4218
|
+
return [2 /*return*/, []];
|
|
4219
|
+
if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
|
|
4220
|
+
return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4221
|
+
var review;
|
|
4222
|
+
return __generator(this, function (_c) {
|
|
4223
|
+
switch (_c.label) {
|
|
4224
|
+
case 0: return [4 /*yield*/, this.findReview(reviewData, productId)];
|
|
4225
|
+
case 1:
|
|
4226
|
+
review = _c.sent();
|
|
4227
|
+
return [2 /*return*/, review === null || review === void 0 ? void 0 : review.id];
|
|
4228
|
+
}
|
|
4229
|
+
});
|
|
4230
|
+
}); }))];
|
|
4231
|
+
case 1:
|
|
4232
|
+
reviewIds_1 = _c.sent();
|
|
4233
|
+
return [4 /*yield*/, this.mutation('delete_product_review', ['affected_rows'], {
|
|
4234
|
+
where: { value: { id: { _in: reviewIds_1.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
|
|
4235
|
+
})];
|
|
4236
|
+
case 2:
|
|
4237
|
+
_c.sent();
|
|
4238
|
+
return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
|
|
4239
|
+
case 3:
|
|
4240
|
+
plainData = this.paramsToPlain({ reviews: reviews });
|
|
4241
|
+
return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4242
|
+
var review, _c, _d;
|
|
4243
|
+
return __generator(this, function (_e) {
|
|
4244
|
+
switch (_e.label) {
|
|
4245
|
+
case 0: return [4 /*yield*/, this.findReview(reviewData, productId)];
|
|
4246
|
+
case 1:
|
|
4247
|
+
review = _e.sent();
|
|
4248
|
+
if (!review.id) return [3 /*break*/, 3];
|
|
4249
|
+
_c = this.bindReviewToModel;
|
|
4250
|
+
return [4 /*yield*/, this.mutation('update_product_review_by_pk', this.reviewsFields, {
|
|
4251
|
+
pk_columns: {
|
|
4252
|
+
value: { id: review.id },
|
|
4253
|
+
type: 'product_review_pk_columns_input',
|
|
4254
|
+
required: true,
|
|
4255
|
+
},
|
|
4256
|
+
_set: {
|
|
4257
|
+
value: lodash.omit(this.bindReviewToHasura(reviewData), ['id', 'product_id']),
|
|
4258
|
+
type: 'product_review_set_input',
|
|
4259
|
+
required: true,
|
|
4260
|
+
},
|
|
4261
|
+
})];
|
|
4262
|
+
case 2: return [2 /*return*/, _c.apply(this, [(_e.sent()).update_product_review_by_pk])];
|
|
4263
|
+
case 3:
|
|
4264
|
+
_d = this.bindReviewToModel;
|
|
4265
|
+
return [4 /*yield*/, this.mutation('insert_product_review_one', this.reviewsFields, {
|
|
4266
|
+
object: {
|
|
4267
|
+
value: lodash.omit(Object.assign(Object.assign({}, this.bindReviewToHasura(reviewData)), { product_id: productId }), ['id']),
|
|
4268
|
+
type: 'product_review_insert_input',
|
|
4269
|
+
required: true,
|
|
4270
|
+
},
|
|
4271
|
+
})];
|
|
4272
|
+
case 4: return [2 /*return*/, _d.apply(this, [(_e.sent()).insert_product_review_one])];
|
|
4273
|
+
}
|
|
4274
|
+
});
|
|
4275
|
+
}); }))];
|
|
4276
|
+
}
|
|
4277
|
+
});
|
|
4278
|
+
});
|
|
4279
|
+
};
|
|
4280
|
+
ProductHasuraGraphQLRepository.prototype.getId = function (id) {
|
|
4281
|
+
var _a, _b;
|
|
4282
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4283
|
+
var data;
|
|
4284
|
+
return __generator(this, function (_c) {
|
|
4285
|
+
switch (_c.label) {
|
|
4286
|
+
case 0:
|
|
4287
|
+
if (!Number.isNaN(+id))
|
|
4288
|
+
return [2 /*return*/, id];
|
|
4289
|
+
return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
|
|
4290
|
+
case 1:
|
|
4291
|
+
data = (_c.sent()).data;
|
|
4292
|
+
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4293
|
+
return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
|
|
4294
|
+
throw new NotFoundError("Product with id " + id + " not found");
|
|
4295
|
+
}
|
|
4296
|
+
});
|
|
4297
|
+
});
|
|
4298
|
+
};
|
|
4299
|
+
ProductHasuraGraphQLRepository.prototype.findReviewsByProduct = function (productId) {
|
|
4300
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4301
|
+
var data;
|
|
4302
|
+
var _this = this;
|
|
4303
|
+
return __generator(this, function (_c) {
|
|
4304
|
+
switch (_c.label) {
|
|
4305
|
+
case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
|
|
4306
|
+
where: {
|
|
4307
|
+
value: {
|
|
4308
|
+
product_id: { _eq: productId },
|
|
4309
|
+
},
|
|
4310
|
+
type: 'product_review_bool_exp',
|
|
4311
|
+
required: true,
|
|
4312
|
+
},
|
|
4313
|
+
})];
|
|
4314
|
+
case 1:
|
|
4315
|
+
data = (_c.sent()).product_review;
|
|
4316
|
+
return [2 /*return*/, data && data.map(function (review) { return _this.bindReviewToModel(review); })];
|
|
4317
|
+
}
|
|
4318
|
+
});
|
|
4319
|
+
});
|
|
4320
|
+
};
|
|
4321
|
+
ProductHasuraGraphQLRepository.prototype.findReview = function (review, productId) {
|
|
4322
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4323
|
+
var loadedReview;
|
|
4324
|
+
return __generator(this, function (_c) {
|
|
4325
|
+
switch (_c.label) {
|
|
4326
|
+
case 0:
|
|
4327
|
+
if (review.id)
|
|
4328
|
+
return [2 /*return*/, review];
|
|
4329
|
+
if (!review.personId) return [3 /*break*/, 2];
|
|
4330
|
+
return [4 /*yield*/, this.getReviewByPersonId(review.personId, productId)];
|
|
4331
|
+
case 1:
|
|
4332
|
+
loadedReview = _c.sent();
|
|
4333
|
+
_c.label = 2;
|
|
4334
|
+
case 2:
|
|
4335
|
+
if (!(!loadedReview && review.author && review.email)) return [3 /*break*/, 4];
|
|
4336
|
+
return [4 /*yield*/, this.getReviewByAuthorAndEmail(review.author, review.email, productId)];
|
|
4337
|
+
case 3:
|
|
4338
|
+
loadedReview = _c.sent();
|
|
4339
|
+
_c.label = 4;
|
|
4340
|
+
case 4: return [2 /*return*/, loadedReview || review];
|
|
4341
|
+
}
|
|
4342
|
+
});
|
|
4343
|
+
});
|
|
4344
|
+
};
|
|
4345
|
+
ProductHasuraGraphQLRepository.prototype.getReviewByPersonId = function (personId, productId) {
|
|
4346
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4347
|
+
var data;
|
|
4348
|
+
return __generator(this, function (_c) {
|
|
4349
|
+
switch (_c.label) {
|
|
4350
|
+
case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
|
|
4351
|
+
where: {
|
|
4352
|
+
value: {
|
|
4353
|
+
product_id: { _eq: productId },
|
|
4354
|
+
person_id: { _eq: personId },
|
|
4355
|
+
},
|
|
4356
|
+
type: "product_review_bool_exp",
|
|
4357
|
+
required: true,
|
|
4358
|
+
},
|
|
4359
|
+
})];
|
|
4360
|
+
case 1:
|
|
4361
|
+
data = (_c.sent()).product_review;
|
|
4362
|
+
return [2 /*return*/, data && data[0] && this.bindReviewToModel(data[0])];
|
|
4363
|
+
}
|
|
4364
|
+
});
|
|
4365
|
+
});
|
|
4366
|
+
};
|
|
4367
|
+
ProductHasuraGraphQLRepository.prototype.getReviewByAuthorAndEmail = function (author, email, productId) {
|
|
4368
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4369
|
+
var data;
|
|
4370
|
+
return __generator(this, function (_c) {
|
|
4371
|
+
switch (_c.label) {
|
|
4372
|
+
case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
|
|
4373
|
+
where: {
|
|
4374
|
+
value: {
|
|
4375
|
+
product_id: { _eq: productId },
|
|
4376
|
+
author: { _eq: author },
|
|
4377
|
+
email: { _eq: email },
|
|
4378
|
+
},
|
|
4379
|
+
type: "product_review_bool_exp",
|
|
4380
|
+
required: true,
|
|
4381
|
+
},
|
|
4382
|
+
})];
|
|
4383
|
+
case 1:
|
|
4384
|
+
data = (_c.sent()).product_review;
|
|
4385
|
+
return [2 /*return*/, data && data[0] && this.bindReviewToModel(data[0])];
|
|
4386
|
+
}
|
|
4387
|
+
});
|
|
4388
|
+
});
|
|
4389
|
+
};
|
|
4390
|
+
return ProductHasuraGraphQLRepository;
|
|
4391
|
+
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
4392
|
+
|
|
4393
|
+
var VariantHasuraGraphQLRepository = /** @class */ (function (_super_1) {
|
|
4394
|
+
__extends(VariantHasuraGraphQLRepository, _super_1);
|
|
4395
|
+
function VariantHasuraGraphQLRepository(endpoint, authOptions) {
|
|
4396
|
+
return _super_1.call(this, {
|
|
4397
|
+
tableName: 'product',
|
|
4398
|
+
model: VariantHasuraGraphQL,
|
|
3483
4399
|
endpoint: endpoint,
|
|
3484
4400
|
authOptions: authOptions,
|
|
3485
4401
|
fields: [
|
|
3486
4402
|
{ id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
|
|
3487
|
-
{
|
|
4403
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4404
|
+
{ productId: { columnName: 'main_product_id', to: function (value) { return +value; }, from: function (value) { return value === null || value === void 0 ? void 0 : value.toString(); } } },
|
|
3488
4405
|
{ EAN: { columnName: 'ean' } },
|
|
3489
|
-
{ NCM: { columnName: 'ncm' } },
|
|
3490
|
-
'brand',
|
|
3491
4406
|
{ costPrice: { columnName: 'cost_price' } },
|
|
3492
|
-
'description',
|
|
3493
|
-
{ hasVariants: { columnName: 'has_variants' } },
|
|
3494
|
-
'images',
|
|
3495
|
-
'miniatures',
|
|
3496
|
-
'name',
|
|
3497
|
-
{ price: { columnName: 'full_price' } },
|
|
3498
|
-
{ price: { columnName: 'subscriber_discount_percentage' } },
|
|
3499
|
-
{ price: { columnName: 'subscriber_price' } },
|
|
3500
4407
|
{
|
|
3501
4408
|
price: {
|
|
3502
4409
|
columnName: 'price',
|
|
3503
4410
|
from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
|
|
3504
|
-
var
|
|
3505
|
-
return (Object.assign(Object.assign({}, prices), (
|
|
4411
|
+
var _c;
|
|
4412
|
+
return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
|
|
3506
4413
|
price: price,
|
|
3507
4414
|
fullPrice: data.full_price,
|
|
3508
4415
|
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
3509
4416
|
subscriberPrice: data.subscriber_price,
|
|
3510
|
-
},
|
|
4417
|
+
}, _c)));
|
|
3511
4418
|
}, {}); },
|
|
4419
|
+
bindFindFilter: function (sentence) {
|
|
4420
|
+
var filters = Object.values(sentence).shift();
|
|
4421
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
4422
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
4423
|
+
})), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
4424
|
+
subscriber_price: filters.subscriberPrice,
|
|
4425
|
+
}));
|
|
4426
|
+
},
|
|
4427
|
+
bindPersistData: function (value) {
|
|
4428
|
+
var priceData = Object.values(value).shift();
|
|
4429
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
4430
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
4431
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
4432
|
+
},
|
|
3512
4433
|
},
|
|
3513
4434
|
},
|
|
3514
|
-
'
|
|
3515
|
-
{
|
|
4435
|
+
{ fullPrice: { columnName: 'full_price' } },
|
|
4436
|
+
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
4437
|
+
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
3516
4438
|
'sku',
|
|
3517
4439
|
{
|
|
3518
4440
|
stock: {
|
|
3519
4441
|
columnName: 'stock',
|
|
3520
4442
|
from: function (quantity) { return ({ quantity: quantity }); },
|
|
3521
|
-
to: function (value) { return (value === null || value === void 0 ? void 0 : value.quantity) || value; },
|
|
4443
|
+
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); },
|
|
3522
4444
|
},
|
|
3523
4445
|
},
|
|
3524
|
-
'type',
|
|
3525
|
-
'video',
|
|
3526
4446
|
'weight',
|
|
4447
|
+
{ name: { to: function () { return ''; }, from: function () { return undefined; } } },
|
|
4448
|
+
{ hasVariants: { columnName: 'has_variants', to: function () { return false; }, from: function () { return undefined; } } },
|
|
4449
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
4450
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
3527
4451
|
{
|
|
3528
|
-
|
|
3529
|
-
columnName: '
|
|
3530
|
-
|
|
3531
|
-
to: function (category_id) { return +category_id; },
|
|
3532
|
-
from: function (categories) { return (categories === null || categories === void 0 ? void 0 : categories.map(function (category) { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || []; },
|
|
3533
|
-
},
|
|
3534
|
-
},
|
|
3535
|
-
{
|
|
3536
|
-
shopAvailability: {
|
|
3537
|
-
columnName: 'shop_availabilities',
|
|
3538
|
-
fields: ['shop'],
|
|
3539
|
-
from: function (shop) { return (Array.isArray(shop) ? shop.map(function (row) { return row.shop; }) : []); },
|
|
4452
|
+
grade: {
|
|
4453
|
+
columnName: 'grade',
|
|
4454
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
3540
4455
|
},
|
|
3541
4456
|
},
|
|
3542
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3543
|
-
{ createdAt: { columnName: 'created_at' } },
|
|
3544
|
-
{ updatedAt: { columnName: 'updated_at' } },
|
|
3545
4457
|
],
|
|
3546
4458
|
}) || this;
|
|
3547
4459
|
}
|
|
3548
|
-
|
|
4460
|
+
VariantHasuraGraphQLRepository.prototype.get = function (identifiers) {
|
|
4461
|
+
var _super = Object.create(null, {
|
|
4462
|
+
get: { get: function () { return _super_1.prototype.get; } }
|
|
4463
|
+
});
|
|
3549
4464
|
var _a;
|
|
3550
4465
|
return __awaiter(this, void 0, void 0, function () {
|
|
3551
|
-
var
|
|
3552
|
-
return __generator(this, function (
|
|
3553
|
-
switch (
|
|
3554
|
-
case 0:
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
shopAvailability: { operator: exports.Where.IN, value: [shop] },
|
|
3558
|
-
},
|
|
3559
|
-
})];
|
|
4466
|
+
var _c;
|
|
4467
|
+
return __generator(this, function (_d) {
|
|
4468
|
+
switch (_d.label) {
|
|
4469
|
+
case 0:
|
|
4470
|
+
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
4471
|
+
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
3560
4472
|
case 1:
|
|
3561
|
-
|
|
3562
|
-
return [
|
|
4473
|
+
_c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
4474
|
+
return [3 /*break*/, 3];
|
|
4475
|
+
case 2:
|
|
4476
|
+
_c = _super.get.call(this, identifiers);
|
|
4477
|
+
_d.label = 3;
|
|
4478
|
+
case 3: return [2 /*return*/, _c];
|
|
3563
4479
|
}
|
|
3564
4480
|
});
|
|
3565
4481
|
});
|
|
3566
4482
|
};
|
|
3567
|
-
|
|
4483
|
+
VariantHasuraGraphQLRepository.prototype.find = function (params) {
|
|
4484
|
+
var _super = Object.create(null, {
|
|
4485
|
+
find: { get: function () { return _super_1.prototype.find; } }
|
|
4486
|
+
});
|
|
4487
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4488
|
+
var _a, filters, options;
|
|
4489
|
+
return __generator(this, function (_c) {
|
|
4490
|
+
_a = params || {}, filters = _a.filters, options = __rest(_a, ["filters"]);
|
|
4491
|
+
return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNOTNULL } }) }))];
|
|
4492
|
+
});
|
|
4493
|
+
});
|
|
4494
|
+
};
|
|
4495
|
+
VariantHasuraGraphQLRepository.prototype.update = function (params) {
|
|
4496
|
+
var _super = Object.create(null, {
|
|
4497
|
+
update: { get: function () { return _super_1.prototype.update; } }
|
|
4498
|
+
});
|
|
4499
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4500
|
+
var productId, checkId, data, dataWithProductId, id, product;
|
|
4501
|
+
return __generator(this, function (_c) {
|
|
4502
|
+
switch (_c.label) {
|
|
4503
|
+
case 0:
|
|
4504
|
+
productId = params.productId, checkId = params.id, data = __rest(params, ["productId", "id"]);
|
|
4505
|
+
dataWithProductId = this.paramsToPlain({ id: checkId, productId: productId });
|
|
4506
|
+
return [4 /*yield*/, this.getId(dataWithProductId.id)];
|
|
4507
|
+
case 1:
|
|
4508
|
+
id = _c.sent();
|
|
4509
|
+
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
4510
|
+
case 2:
|
|
4511
|
+
product = _c.sent();
|
|
4512
|
+
product.productId = dataWithProductId.productId;
|
|
4513
|
+
return [2 /*return*/, product];
|
|
4514
|
+
}
|
|
4515
|
+
});
|
|
4516
|
+
});
|
|
4517
|
+
};
|
|
4518
|
+
VariantHasuraGraphQLRepository.prototype.getId = function (id) {
|
|
4519
|
+
var _a, _b;
|
|
4520
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
4521
|
+
var data;
|
|
4522
|
+
return __generator(this, function (_c) {
|
|
4523
|
+
switch (_c.label) {
|
|
4524
|
+
case 0:
|
|
4525
|
+
if (!Number.isNaN(+id))
|
|
4526
|
+
return [2 /*return*/, id];
|
|
4527
|
+
return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
|
|
4528
|
+
case 1:
|
|
4529
|
+
data = (_c.sent()).data;
|
|
4530
|
+
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
4531
|
+
return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
|
|
4532
|
+
throw new NotFoundError("Product with id " + id + " not found");
|
|
4533
|
+
}
|
|
4534
|
+
});
|
|
4535
|
+
});
|
|
4536
|
+
};
|
|
4537
|
+
return VariantHasuraGraphQLRepository;
|
|
3568
4538
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3569
4539
|
|
|
3570
4540
|
/**
|
|
@@ -3683,6 +4653,7 @@
|
|
|
3683
4653
|
exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
|
|
3684
4654
|
exports.Category = Category;
|
|
3685
4655
|
exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
|
|
4656
|
+
exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
|
|
3686
4657
|
exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
|
|
3687
4658
|
exports.Checkout = Checkout;
|
|
3688
4659
|
exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
|
|
@@ -3696,6 +4667,8 @@
|
|
|
3696
4667
|
exports.Home = Home;
|
|
3697
4668
|
exports.HomeFirestoreRepository = HomeFirestoreRepository;
|
|
3698
4669
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
4670
|
+
exports.KitProduct = KitProduct;
|
|
4671
|
+
exports.KitProductHasuraGraphQL = KitProductHasuraGraphQL;
|
|
3699
4672
|
exports.Lead = Lead;
|
|
3700
4673
|
exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
3701
4674
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
@@ -3707,6 +4680,7 @@
|
|
|
3707
4680
|
exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
3708
4681
|
exports.Product = Product;
|
|
3709
4682
|
exports.ProductFirestoreRepository = ProductFirestoreRepository;
|
|
4683
|
+
exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
|
|
3710
4684
|
exports.ProductHasuraGraphQLRepository = ProductHasuraGraphQLRepository;
|
|
3711
4685
|
exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
|
|
3712
4686
|
exports.ProductsIndex = ProductsIndex;
|
|
@@ -3737,6 +4711,8 @@
|
|
|
3737
4711
|
exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
|
|
3738
4712
|
exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
|
|
3739
4713
|
exports.Variant = Variant;
|
|
4714
|
+
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
4715
|
+
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|
|
3740
4716
|
exports.WeakPasswordError = WeakPasswordError;
|
|
3741
4717
|
exports.isUUID = isUUID;
|
|
3742
4718
|
exports.parseDateTime = parseDateTime;
|