@infrab4a/connect 4.10.0 → 4.10.1-beta.1
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/index.cjs.js +102 -52
- package/index.esm.js +102 -52
- package/package.json +1 -1
- package/src/domain/catalog/models/category-base.d.ts +17 -3
- package/src/domain/catalog/models/types/category-images.type.d.ts +8 -0
- package/src/domain/catalog/models/types/category-metadata.type.d.ts +2 -0
- package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +4 -0
- package/src/domain/catalog/models/types/index.d.ts +2 -0
package/index.cjs.js
CHANGED
|
@@ -42,6 +42,21 @@ class BaseModel {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
exports.GenderDestination = void 0;
|
|
46
|
+
(function (GenderDestination) {
|
|
47
|
+
GenderDestination["FEMALE"] = "female";
|
|
48
|
+
GenderDestination["MALE"] = "male";
|
|
49
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
50
|
+
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
51
|
+
|
|
52
|
+
exports.Shops = void 0;
|
|
53
|
+
(function (Shops) {
|
|
54
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
55
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
56
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
57
|
+
Shops["ALL"] = "ALL";
|
|
58
|
+
})(exports.Shops || (exports.Shops = {}));
|
|
59
|
+
|
|
45
60
|
class Filter extends BaseModel {
|
|
46
61
|
static get identifiersFields() {
|
|
47
62
|
return ['id'];
|
|
@@ -56,6 +71,21 @@ class CategoryBase extends BaseModel {
|
|
|
56
71
|
static get identifiersFields() {
|
|
57
72
|
return ['id'];
|
|
58
73
|
}
|
|
74
|
+
get glamImages() {
|
|
75
|
+
return this.images[exports.Shops.GLAMSHOP];
|
|
76
|
+
}
|
|
77
|
+
get mensImages() {
|
|
78
|
+
return this.images[exports.Shops.MENSMARKET];
|
|
79
|
+
}
|
|
80
|
+
get glamMetadata() {
|
|
81
|
+
return this.metadata.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
|
|
82
|
+
}
|
|
83
|
+
get mensMetadata() {
|
|
84
|
+
return this.metadata.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
|
|
85
|
+
}
|
|
86
|
+
getMostRelevantByShop(shop) {
|
|
87
|
+
return this.mostRelevant && this.mostRelevant[shop] ? this.mostRelevant[shop] : [];
|
|
88
|
+
}
|
|
59
89
|
}
|
|
60
90
|
tslib.__decorate([
|
|
61
91
|
classTransformer.Type(() => CategoryBase),
|
|
@@ -164,21 +194,6 @@ tslib.__decorate([
|
|
|
164
194
|
tslib.__metadata("design:type", Category)
|
|
165
195
|
], CategoryFilter.prototype, "category", void 0);
|
|
166
196
|
|
|
167
|
-
exports.GenderDestination = void 0;
|
|
168
|
-
(function (GenderDestination) {
|
|
169
|
-
GenderDestination["FEMALE"] = "female";
|
|
170
|
-
GenderDestination["MALE"] = "male";
|
|
171
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
172
|
-
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
173
|
-
|
|
174
|
-
exports.Shops = void 0;
|
|
175
|
-
(function (Shops) {
|
|
176
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
177
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
178
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
179
|
-
Shops["ALL"] = "ALL";
|
|
180
|
-
})(exports.Shops || (exports.Shops = {}));
|
|
181
|
-
|
|
182
197
|
class FilterOption extends BaseModel {
|
|
183
198
|
static get identifiersFields() {
|
|
184
199
|
return ['id'];
|
|
@@ -4698,6 +4713,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4698
4713
|
'name',
|
|
4699
4714
|
'description',
|
|
4700
4715
|
'image',
|
|
4716
|
+
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4701
4717
|
'published',
|
|
4702
4718
|
'shop',
|
|
4703
4719
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4753,7 +4769,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4753
4769
|
{
|
|
4754
4770
|
metadata: {
|
|
4755
4771
|
columnName: 'metadata',
|
|
4756
|
-
fields: ['title', 'description'],
|
|
4772
|
+
fields: ['shop', 'title', 'description'],
|
|
4757
4773
|
bindPersistData: (value) => ({
|
|
4758
4774
|
metadata: { data: value },
|
|
4759
4775
|
}),
|
|
@@ -4779,8 +4795,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4779
4795
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4780
4796
|
}
|
|
4781
4797
|
async create(params) {
|
|
4782
|
-
const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
|
|
4783
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null }
|
|
4798
|
+
const { mostRelevant, metadata } = params, data = tslib.__rest(params, ["mostRelevant", "metadata"]);
|
|
4799
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }], mostRelevant: mostRelevant || {
|
|
4800
|
+
[exports.Shops.GLAMSHOP]: null,
|
|
4801
|
+
[exports.Shops.MENSMARKET]: null,
|
|
4802
|
+
} }));
|
|
4784
4803
|
}
|
|
4785
4804
|
async get(identifiers) {
|
|
4786
4805
|
var _a;
|
|
@@ -4971,22 +4990,35 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4971
4990
|
return plainData.products;
|
|
4972
4991
|
}
|
|
4973
4992
|
async updateMetadata(categoryId, { metadata }) {
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4993
|
+
if (Array.isArray(metadata) && !metadata.length)
|
|
4994
|
+
return [];
|
|
4995
|
+
if (Array.isArray(metadata) && metadata.length) {
|
|
4996
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
4997
|
+
where: {
|
|
4998
|
+
type: 'category_metadata_bool_exp',
|
|
4999
|
+
required: true,
|
|
5000
|
+
value: { category_id: { _eq: categoryId } },
|
|
5001
|
+
},
|
|
5002
|
+
});
|
|
5003
|
+
await this.mutation('insert_category_metadata', ['affected_rows'], {
|
|
5004
|
+
objects: {
|
|
5005
|
+
type: '[category_metadata_insert_input!]',
|
|
5006
|
+
required: true,
|
|
5007
|
+
value: metadata.map((m) => (Object.assign({ category_id: categoryId }, m))),
|
|
5008
|
+
},
|
|
5009
|
+
});
|
|
5010
|
+
return metadata;
|
|
5011
|
+
}
|
|
5012
|
+
if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
|
|
5013
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5014
|
+
where: {
|
|
5015
|
+
type: 'category_metadata_bool_exp',
|
|
5016
|
+
required: true,
|
|
5017
|
+
value: { category_id: { _eq: categoryId } },
|
|
5018
|
+
},
|
|
5019
|
+
});
|
|
5020
|
+
return [];
|
|
5021
|
+
}
|
|
4990
5022
|
}
|
|
4991
5023
|
async updateFilters(categoryId, { filters }) {
|
|
4992
5024
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5996,7 +6028,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5996
6028
|
{
|
|
5997
6029
|
metadata: {
|
|
5998
6030
|
columnName: 'metadata',
|
|
5999
|
-
fields: ['title', 'description'],
|
|
6031
|
+
fields: ['shop', 'title', 'description'],
|
|
6000
6032
|
bindPersistData: (value) => ({
|
|
6001
6033
|
metadata: { data: value },
|
|
6002
6034
|
}),
|
|
@@ -6026,8 +6058,9 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6026
6058
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6027
6059
|
}
|
|
6028
6060
|
async create(params) {
|
|
6061
|
+
var _a;
|
|
6029
6062
|
const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
|
|
6030
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
6063
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }] }));
|
|
6031
6064
|
}
|
|
6032
6065
|
async get(identifiers) {
|
|
6033
6066
|
const data = await super.get(identifiers);
|
|
@@ -6158,22 +6191,39 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6158
6191
|
return plainData.products;
|
|
6159
6192
|
}
|
|
6160
6193
|
async updateMetadata(categoryId, { metadata }) {
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6194
|
+
if (Array.isArray(metadata) && !metadata.length)
|
|
6195
|
+
return [];
|
|
6196
|
+
if (Array.isArray(metadata) && metadata.length) {
|
|
6197
|
+
const metadataUpdated = [];
|
|
6198
|
+
for (const data of metadata) {
|
|
6199
|
+
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
6200
|
+
pk_columns: {
|
|
6201
|
+
value: { category_id: categoryId, shop: data.shop },
|
|
6202
|
+
type: 'category_metadata_pk_columns_input',
|
|
6203
|
+
required: true,
|
|
6204
|
+
},
|
|
6205
|
+
_set: {
|
|
6206
|
+
value: lodash.omit(data, ['category_id', 'shop']),
|
|
6207
|
+
type: 'category_metadata_set_input',
|
|
6208
|
+
required: true,
|
|
6209
|
+
},
|
|
6210
|
+
});
|
|
6211
|
+
metadataUpdated.push(update);
|
|
6212
|
+
}
|
|
6213
|
+
return metadataUpdated;
|
|
6214
|
+
}
|
|
6215
|
+
if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
|
|
6216
|
+
for (let i = 0; i < metadata.value.length; i++) {
|
|
6217
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6218
|
+
where: {
|
|
6219
|
+
type: 'category_metadata_bool_exp',
|
|
6220
|
+
required: true,
|
|
6221
|
+
value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
|
|
6222
|
+
},
|
|
6223
|
+
});
|
|
6224
|
+
}
|
|
6225
|
+
return [];
|
|
6226
|
+
}
|
|
6177
6227
|
}
|
|
6178
6228
|
}
|
|
6179
6229
|
tslib.__decorate([
|
package/index.esm.js
CHANGED
|
@@ -36,6 +36,21 @@ class BaseModel {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
var GenderDestination;
|
|
40
|
+
(function (GenderDestination) {
|
|
41
|
+
GenderDestination["FEMALE"] = "female";
|
|
42
|
+
GenderDestination["MALE"] = "male";
|
|
43
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
44
|
+
})(GenderDestination || (GenderDestination = {}));
|
|
45
|
+
|
|
46
|
+
var Shops;
|
|
47
|
+
(function (Shops) {
|
|
48
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
49
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
50
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
51
|
+
Shops["ALL"] = "ALL";
|
|
52
|
+
})(Shops || (Shops = {}));
|
|
53
|
+
|
|
39
54
|
class Filter extends BaseModel {
|
|
40
55
|
static get identifiersFields() {
|
|
41
56
|
return ['id'];
|
|
@@ -50,6 +65,21 @@ class CategoryBase extends BaseModel {
|
|
|
50
65
|
static get identifiersFields() {
|
|
51
66
|
return ['id'];
|
|
52
67
|
}
|
|
68
|
+
get glamImages() {
|
|
69
|
+
return this.images[Shops.GLAMSHOP];
|
|
70
|
+
}
|
|
71
|
+
get mensImages() {
|
|
72
|
+
return this.images[Shops.MENSMARKET];
|
|
73
|
+
}
|
|
74
|
+
get glamMetadata() {
|
|
75
|
+
return this.metadata.find((metadata) => metadata.shop === Shops.GLAMSHOP);
|
|
76
|
+
}
|
|
77
|
+
get mensMetadata() {
|
|
78
|
+
return this.metadata.find((metadata) => metadata.shop === Shops.MENSMARKET);
|
|
79
|
+
}
|
|
80
|
+
getMostRelevantByShop(shop) {
|
|
81
|
+
return this.mostRelevant && this.mostRelevant[shop] ? this.mostRelevant[shop] : [];
|
|
82
|
+
}
|
|
53
83
|
}
|
|
54
84
|
__decorate([
|
|
55
85
|
Type(() => CategoryBase),
|
|
@@ -158,21 +188,6 @@ __decorate([
|
|
|
158
188
|
__metadata("design:type", Category)
|
|
159
189
|
], CategoryFilter.prototype, "category", void 0);
|
|
160
190
|
|
|
161
|
-
var GenderDestination;
|
|
162
|
-
(function (GenderDestination) {
|
|
163
|
-
GenderDestination["FEMALE"] = "female";
|
|
164
|
-
GenderDestination["MALE"] = "male";
|
|
165
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
166
|
-
})(GenderDestination || (GenderDestination = {}));
|
|
167
|
-
|
|
168
|
-
var Shops;
|
|
169
|
-
(function (Shops) {
|
|
170
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
171
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
172
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
173
|
-
Shops["ALL"] = "ALL";
|
|
174
|
-
})(Shops || (Shops = {}));
|
|
175
|
-
|
|
176
191
|
class FilterOption extends BaseModel {
|
|
177
192
|
static get identifiersFields() {
|
|
178
193
|
return ['id'];
|
|
@@ -4692,6 +4707,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4692
4707
|
'name',
|
|
4693
4708
|
'description',
|
|
4694
4709
|
'image',
|
|
4710
|
+
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4695
4711
|
'published',
|
|
4696
4712
|
'shop',
|
|
4697
4713
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4747,7 +4763,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4747
4763
|
{
|
|
4748
4764
|
metadata: {
|
|
4749
4765
|
columnName: 'metadata',
|
|
4750
|
-
fields: ['title', 'description'],
|
|
4766
|
+
fields: ['shop', 'title', 'description'],
|
|
4751
4767
|
bindPersistData: (value) => ({
|
|
4752
4768
|
metadata: { data: value },
|
|
4753
4769
|
}),
|
|
@@ -4773,8 +4789,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4773
4789
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4774
4790
|
}
|
|
4775
4791
|
async create(params) {
|
|
4776
|
-
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4777
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null }
|
|
4792
|
+
const { mostRelevant, metadata } = params, data = __rest(params, ["mostRelevant", "metadata"]);
|
|
4793
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }], mostRelevant: mostRelevant || {
|
|
4794
|
+
[Shops.GLAMSHOP]: null,
|
|
4795
|
+
[Shops.MENSMARKET]: null,
|
|
4796
|
+
} }));
|
|
4778
4797
|
}
|
|
4779
4798
|
async get(identifiers) {
|
|
4780
4799
|
var _a;
|
|
@@ -4965,22 +4984,35 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4965
4984
|
return plainData.products;
|
|
4966
4985
|
}
|
|
4967
4986
|
async updateMetadata(categoryId, { metadata }) {
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4987
|
+
if (Array.isArray(metadata) && !metadata.length)
|
|
4988
|
+
return [];
|
|
4989
|
+
if (Array.isArray(metadata) && metadata.length) {
|
|
4990
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
4991
|
+
where: {
|
|
4992
|
+
type: 'category_metadata_bool_exp',
|
|
4993
|
+
required: true,
|
|
4994
|
+
value: { category_id: { _eq: categoryId } },
|
|
4995
|
+
},
|
|
4996
|
+
});
|
|
4997
|
+
await this.mutation('insert_category_metadata', ['affected_rows'], {
|
|
4998
|
+
objects: {
|
|
4999
|
+
type: '[category_metadata_insert_input!]',
|
|
5000
|
+
required: true,
|
|
5001
|
+
value: metadata.map((m) => (Object.assign({ category_id: categoryId }, m))),
|
|
5002
|
+
},
|
|
5003
|
+
});
|
|
5004
|
+
return metadata;
|
|
5005
|
+
}
|
|
5006
|
+
if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
|
|
5007
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5008
|
+
where: {
|
|
5009
|
+
type: 'category_metadata_bool_exp',
|
|
5010
|
+
required: true,
|
|
5011
|
+
value: { category_id: { _eq: categoryId } },
|
|
5012
|
+
},
|
|
5013
|
+
});
|
|
5014
|
+
return [];
|
|
5015
|
+
}
|
|
4984
5016
|
}
|
|
4985
5017
|
async updateFilters(categoryId, { filters }) {
|
|
4986
5018
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5990,7 +6022,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5990
6022
|
{
|
|
5991
6023
|
metadata: {
|
|
5992
6024
|
columnName: 'metadata',
|
|
5993
|
-
fields: ['title', 'description'],
|
|
6025
|
+
fields: ['shop', 'title', 'description'],
|
|
5994
6026
|
bindPersistData: (value) => ({
|
|
5995
6027
|
metadata: { data: value },
|
|
5996
6028
|
}),
|
|
@@ -6020,8 +6052,9 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6020
6052
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6021
6053
|
}
|
|
6022
6054
|
async create(params) {
|
|
6055
|
+
var _a;
|
|
6023
6056
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
6024
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
6057
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }] }));
|
|
6025
6058
|
}
|
|
6026
6059
|
async get(identifiers) {
|
|
6027
6060
|
const data = await super.get(identifiers);
|
|
@@ -6152,22 +6185,39 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6152
6185
|
return plainData.products;
|
|
6153
6186
|
}
|
|
6154
6187
|
async updateMetadata(categoryId, { metadata }) {
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
6188
|
+
if (Array.isArray(metadata) && !metadata.length)
|
|
6189
|
+
return [];
|
|
6190
|
+
if (Array.isArray(metadata) && metadata.length) {
|
|
6191
|
+
const metadataUpdated = [];
|
|
6192
|
+
for (const data of metadata) {
|
|
6193
|
+
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
6194
|
+
pk_columns: {
|
|
6195
|
+
value: { category_id: categoryId, shop: data.shop },
|
|
6196
|
+
type: 'category_metadata_pk_columns_input',
|
|
6197
|
+
required: true,
|
|
6198
|
+
},
|
|
6199
|
+
_set: {
|
|
6200
|
+
value: omit(data, ['category_id', 'shop']),
|
|
6201
|
+
type: 'category_metadata_set_input',
|
|
6202
|
+
required: true,
|
|
6203
|
+
},
|
|
6204
|
+
});
|
|
6205
|
+
metadataUpdated.push(update);
|
|
6206
|
+
}
|
|
6207
|
+
return metadataUpdated;
|
|
6208
|
+
}
|
|
6209
|
+
if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
|
|
6210
|
+
for (let i = 0; i < metadata.value.length; i++) {
|
|
6211
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6212
|
+
where: {
|
|
6213
|
+
type: 'category_metadata_bool_exp',
|
|
6214
|
+
required: true,
|
|
6215
|
+
value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
|
|
6216
|
+
},
|
|
6217
|
+
});
|
|
6218
|
+
}
|
|
6219
|
+
return [];
|
|
6220
|
+
}
|
|
6171
6221
|
}
|
|
6172
6222
|
}
|
|
6173
6223
|
__decorate([
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseModel, GenericIdentifier, ModelBaseStructure } from '../../generic/model';
|
|
2
2
|
import { Shops } from './enums';
|
|
3
3
|
import { Filter } from './filter';
|
|
4
|
-
import { CategoryCondition, CategoryMetadata } from './types';
|
|
4
|
+
import { CategoryCondition, CategoryImages, CategoryMetadata, CategoryMostRelevant } from './types';
|
|
5
5
|
export declare class CategoryBase<ChildCategory extends ModelBaseStructure<ChildCategory, Identifiers> = ModelBaseStructure<any, any>, Identifiers = ChildCategory['identifiersFields']> extends BaseModel<ChildCategory, Identifiers> {
|
|
6
6
|
id: string;
|
|
7
7
|
brandCategory: boolean;
|
|
@@ -9,6 +9,7 @@ export declare class CategoryBase<ChildCategory extends ModelBaseStructure<Child
|
|
|
9
9
|
name: string;
|
|
10
10
|
slug: string;
|
|
11
11
|
image?: string;
|
|
12
|
+
images?: CategoryImages;
|
|
12
13
|
brandCategoryBanner?: string;
|
|
13
14
|
brandCategoryBannerMobile?: string;
|
|
14
15
|
description: string;
|
|
@@ -19,15 +20,28 @@ export declare class CategoryBase<ChildCategory extends ModelBaseStructure<Child
|
|
|
19
20
|
shop?: Shops;
|
|
20
21
|
shops?: string[];
|
|
21
22
|
published: boolean;
|
|
22
|
-
metadata: CategoryMetadata;
|
|
23
|
+
metadata: CategoryMetadata[];
|
|
23
24
|
isCollection?: boolean;
|
|
24
25
|
isWishlist?: boolean;
|
|
25
26
|
reference?: string;
|
|
26
27
|
parentId?: number;
|
|
27
28
|
theme?: string;
|
|
28
29
|
bannerUrl?: string;
|
|
29
|
-
mostRelevant?:
|
|
30
|
+
mostRelevant?: CategoryMostRelevant;
|
|
30
31
|
parent?: CategoryBase;
|
|
31
32
|
filters?: Filter[];
|
|
32
33
|
static get identifiersFields(): GenericIdentifier[];
|
|
34
|
+
get glamImages(): {
|
|
35
|
+
image: string;
|
|
36
|
+
brandBanner: string;
|
|
37
|
+
brandBannerMobile: string;
|
|
38
|
+
};
|
|
39
|
+
get mensImages(): {
|
|
40
|
+
image: string;
|
|
41
|
+
brandBanner: string;
|
|
42
|
+
brandBannerMobile: string;
|
|
43
|
+
};
|
|
44
|
+
get glamMetadata(): CategoryMetadata;
|
|
45
|
+
get mensMetadata(): CategoryMetadata;
|
|
46
|
+
getMostRelevantByShop(shop: Shops): string[];
|
|
33
47
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './category-condition.type';
|
|
2
|
+
export * from './category-images.type';
|
|
2
3
|
export * from './category-metadata.type';
|
|
4
|
+
export * from './category-most-relevant.type';
|
|
3
5
|
export * from './category-product';
|
|
4
6
|
export * from './product-evaluation.type';
|
|
5
7
|
export * from './product-gender.type';
|