@infrab4a/connect 4.9.7-beta.14 → 4.9.7-beta.16

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 CHANGED
@@ -42,21 +42,6 @@ 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
-
60
45
  class Filter extends BaseModel {
61
46
  static get identifiersFields() {
62
47
  return ['id'];
@@ -71,21 +56,6 @@ class CategoryBase extends BaseModel {
71
56
  static get identifiersFields() {
72
57
  return ['id'];
73
58
  }
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
- }
89
59
  }
90
60
  tslib.__decorate([
91
61
  classTransformer.Type(() => CategoryBase),
@@ -194,6 +164,21 @@ tslib.__decorate([
194
164
  tslib.__metadata("design:type", Category)
195
165
  ], CategoryFilter.prototype, "category", void 0);
196
166
 
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
+
197
182
  class FilterOption extends BaseModel {
198
183
  static get identifiersFields() {
199
184
  return ['id'];
@@ -4760,7 +4745,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4760
4745
  'name',
4761
4746
  'description',
4762
4747
  'image',
4763
- { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4764
4748
  'published',
4765
4749
  'shop',
4766
4750
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4816,7 +4800,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4816
4800
  {
4817
4801
  metadata: {
4818
4802
  columnName: 'metadata',
4819
- fields: ['shop', 'title', 'description'],
4803
+ fields: ['title', 'description'],
4820
4804
  bindPersistData: (value) => ({
4821
4805
  metadata: { data: value },
4822
4806
  }),
@@ -4842,11 +4826,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4842
4826
  this.categoryFilterRepository = categoryFilterRepository;
4843
4827
  }
4844
4828
  async create(params) {
4845
- const { mostRelevant, metadata } = params, data = tslib.__rest(params, ["mostRelevant", "metadata"]);
4846
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }], mostRelevant: mostRelevant || {
4847
- [exports.Shops.GLAMSHOP]: null,
4848
- [exports.Shops.MENSMARKET]: null,
4849
- } }));
4829
+ const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
4830
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4850
4831
  }
4851
4832
  async get(identifiers) {
4852
4833
  var _a;
@@ -5037,35 +5018,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5037
5018
  return plainData.products;
5038
5019
  }
5039
5020
  async updateMetadata(categoryId, { metadata }) {
5040
- if (Array.isArray(metadata) && !metadata.length)
5041
- return [];
5042
- if (Array.isArray(metadata) && metadata.length) {
5043
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5044
- where: {
5045
- type: 'category_metadata_bool_exp',
5046
- required: true,
5047
- value: { category_id: { _eq: categoryId } },
5048
- },
5049
- });
5050
- await this.mutation('insert_category_metadata', ['affected_rows'], {
5051
- objects: {
5052
- type: '[category_metadata_insert_input!]',
5053
- required: true,
5054
- value: metadata.map((m) => (Object.assign({ category_id: categoryId }, m))),
5055
- },
5056
- });
5057
- return metadata;
5058
- }
5059
- if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
5060
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5061
- where: {
5062
- type: 'category_metadata_bool_exp',
5063
- required: true,
5064
- value: { category_id: { _eq: categoryId } },
5065
- },
5066
- });
5067
- return [];
5068
- }
5021
+ const plainData = this.paramsToPlain({ metadata });
5022
+ if (!plainData.metadata)
5023
+ return null;
5024
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
5025
+ pk_columns: {
5026
+ value: { category_id: categoryId },
5027
+ type: 'category_metadata_pk_columns_input',
5028
+ required: true,
5029
+ },
5030
+ _set: {
5031
+ value: lodash.omit(metadata, ['category_id']),
5032
+ type: 'category_metadata_set_input',
5033
+ required: true,
5034
+ },
5035
+ });
5036
+ return plainData.metadata;
5069
5037
  }
5070
5038
  async updateFilters(categoryId, { filters }) {
5071
5039
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5900,7 +5868,7 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5900
5868
  });
5901
5869
  }
5902
5870
  async getNotificationsReport(params, orderBy, pagination) {
5903
- const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
5871
+ const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.productId && { product_id: { _eq: params.productId } })), (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.categoryId && { category_id: { _eq: params.categoryId } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
5904
5872
  const orderByField = {
5905
5873
  [orderBy.field]: orderBy.direction,
5906
5874
  };
@@ -5916,10 +5884,11 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5916
5884
  required: true,
5917
5885
  },
5918
5886
  });
5887
+ const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5888
+ ? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, (pagination === null || pagination === void 0 ? void 0 : pagination.offset) + (pagination === null || pagination === void 0 ? void 0 : pagination.limit))
5889
+ : report_stock_notification;
5919
5890
  return {
5920
- data: (pagination === null || pagination === void 0 ? void 0 : pagination.offset) && (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5921
- ? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5922
- : report_stock_notification,
5891
+ data,
5923
5892
  count: report_stock_notification.length,
5924
5893
  };
5925
5894
  }
@@ -6099,7 +6068,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6099
6068
  {
6100
6069
  metadata: {
6101
6070
  columnName: 'metadata',
6102
- fields: ['shop', 'title', 'description'],
6071
+ fields: ['title', 'description'],
6103
6072
  bindPersistData: (value) => ({
6104
6073
  metadata: { data: value },
6105
6074
  }),
@@ -6129,9 +6098,8 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6129
6098
  this.categoryFilterRepository = categoryFilterRepository;
6130
6099
  }
6131
6100
  async create(params) {
6132
- var _a;
6133
6101
  const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
6134
- 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 }] }));
6102
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
6135
6103
  }
6136
6104
  async get(identifiers) {
6137
6105
  const data = await super.get(identifiers);
@@ -6262,39 +6230,22 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6262
6230
  return plainData.products;
6263
6231
  }
6264
6232
  async updateMetadata(categoryId, { metadata }) {
6265
- if (Array.isArray(metadata) && !metadata.length)
6266
- return [];
6267
- if (Array.isArray(metadata) && metadata.length) {
6268
- const metadataUpdated = [];
6269
- for (const data of metadata) {
6270
- const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6271
- pk_columns: {
6272
- value: { category_id: categoryId, shop: data.shop },
6273
- type: 'category_metadata_pk_columns_input',
6274
- required: true,
6275
- },
6276
- _set: {
6277
- value: lodash.omit(data, ['category_id', 'shop']),
6278
- type: 'category_metadata_set_input',
6279
- required: true,
6280
- },
6281
- });
6282
- metadataUpdated.push(update);
6283
- }
6284
- return metadataUpdated;
6285
- }
6286
- if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
6287
- for (let i = 0; i < metadata.value.length; i++) {
6288
- await this.mutation('delete_category_metadata', ['affected_rows'], {
6289
- where: {
6290
- type: 'category_metadata_bool_exp',
6291
- required: true,
6292
- value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
6293
- },
6294
- });
6295
- }
6296
- return [];
6297
- }
6233
+ const plainData = this.paramsToPlain({ metadata });
6234
+ if (!plainData.metadata)
6235
+ return;
6236
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
6237
+ pk_columns: {
6238
+ value: { category_id: categoryId },
6239
+ type: 'category_metadata_pk_columns_input',
6240
+ required: true,
6241
+ },
6242
+ _set: {
6243
+ value: lodash.omit(metadata, ['category_id']),
6244
+ type: 'category_metadata_set_input',
6245
+ required: true,
6246
+ },
6247
+ });
6248
+ return plainData.metadata;
6298
6249
  }
6299
6250
  }
6300
6251
  tslib.__decorate([
package/index.esm.js CHANGED
@@ -36,21 +36,6 @@ 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
-
54
39
  class Filter extends BaseModel {
55
40
  static get identifiersFields() {
56
41
  return ['id'];
@@ -65,21 +50,6 @@ class CategoryBase extends BaseModel {
65
50
  static get identifiersFields() {
66
51
  return ['id'];
67
52
  }
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
- }
83
53
  }
84
54
  __decorate([
85
55
  Type(() => CategoryBase),
@@ -188,6 +158,21 @@ __decorate([
188
158
  __metadata("design:type", Category)
189
159
  ], CategoryFilter.prototype, "category", void 0);
190
160
 
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
+
191
176
  class FilterOption extends BaseModel {
192
177
  static get identifiersFields() {
193
178
  return ['id'];
@@ -4754,7 +4739,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4754
4739
  'name',
4755
4740
  'description',
4756
4741
  'image',
4757
- { images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
4758
4742
  'published',
4759
4743
  'shop',
4760
4744
  { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
@@ -4810,7 +4794,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4810
4794
  {
4811
4795
  metadata: {
4812
4796
  columnName: 'metadata',
4813
- fields: ['shop', 'title', 'description'],
4797
+ fields: ['title', 'description'],
4814
4798
  bindPersistData: (value) => ({
4815
4799
  metadata: { data: value },
4816
4800
  }),
@@ -4836,11 +4820,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4836
4820
  this.categoryFilterRepository = categoryFilterRepository;
4837
4821
  }
4838
4822
  async create(params) {
4839
- const { mostRelevant, metadata } = params, data = __rest(params, ["mostRelevant", "metadata"]);
4840
- return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }], mostRelevant: mostRelevant || {
4841
- [Shops.GLAMSHOP]: null,
4842
- [Shops.MENSMARKET]: null,
4843
- } }));
4823
+ const { metadata } = params, data = __rest(params, ["metadata"]);
4824
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4844
4825
  }
4845
4826
  async get(identifiers) {
4846
4827
  var _a;
@@ -5031,35 +5012,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5031
5012
  return plainData.products;
5032
5013
  }
5033
5014
  async updateMetadata(categoryId, { metadata }) {
5034
- if (Array.isArray(metadata) && !metadata.length)
5035
- return [];
5036
- if (Array.isArray(metadata) && metadata.length) {
5037
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5038
- where: {
5039
- type: 'category_metadata_bool_exp',
5040
- required: true,
5041
- value: { category_id: { _eq: categoryId } },
5042
- },
5043
- });
5044
- await this.mutation('insert_category_metadata', ['affected_rows'], {
5045
- objects: {
5046
- type: '[category_metadata_insert_input!]',
5047
- required: true,
5048
- value: metadata.map((m) => (Object.assign({ category_id: categoryId }, m))),
5049
- },
5050
- });
5051
- return metadata;
5052
- }
5053
- if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
5054
- await this.mutation('delete_category_metadata', ['affected_rows'], {
5055
- where: {
5056
- type: 'category_metadata_bool_exp',
5057
- required: true,
5058
- value: { category_id: { _eq: categoryId } },
5059
- },
5060
- });
5061
- return [];
5062
- }
5015
+ const plainData = this.paramsToPlain({ metadata });
5016
+ if (!plainData.metadata)
5017
+ return null;
5018
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
5019
+ pk_columns: {
5020
+ value: { category_id: categoryId },
5021
+ type: 'category_metadata_pk_columns_input',
5022
+ required: true,
5023
+ },
5024
+ _set: {
5025
+ value: omit(metadata, ['category_id']),
5026
+ type: 'category_metadata_set_input',
5027
+ required: true,
5028
+ },
5029
+ });
5030
+ return plainData.metadata;
5063
5031
  }
5064
5032
  async updateFilters(categoryId, { filters }) {
5065
5033
  if ('action' in filters && filters.action === 'remove' && filters.value.length) {
@@ -5894,7 +5862,7 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5894
5862
  });
5895
5863
  }
5896
5864
  async getNotificationsReport(params, orderBy, pagination) {
5897
- const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
5865
+ const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.productId && { product_id: { _eq: params.productId } })), (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.categoryId && { category_id: { _eq: params.categoryId } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
5898
5866
  const orderByField = {
5899
5867
  [orderBy.field]: orderBy.direction,
5900
5868
  };
@@ -5910,10 +5878,11 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
5910
5878
  required: true,
5911
5879
  },
5912
5880
  });
5881
+ const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5882
+ ? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, (pagination === null || pagination === void 0 ? void 0 : pagination.offset) + (pagination === null || pagination === void 0 ? void 0 : pagination.limit))
5883
+ : report_stock_notification;
5913
5884
  return {
5914
- data: (pagination === null || pagination === void 0 ? void 0 : pagination.offset) && (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5915
- ? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, pagination === null || pagination === void 0 ? void 0 : pagination.limit)
5916
- : report_stock_notification,
5885
+ data,
5917
5886
  count: report_stock_notification.length,
5918
5887
  };
5919
5888
  }
@@ -6093,7 +6062,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6093
6062
  {
6094
6063
  metadata: {
6095
6064
  columnName: 'metadata',
6096
- fields: ['shop', 'title', 'description'],
6065
+ fields: ['title', 'description'],
6097
6066
  bindPersistData: (value) => ({
6098
6067
  metadata: { data: value },
6099
6068
  }),
@@ -6123,9 +6092,8 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6123
6092
  this.categoryFilterRepository = categoryFilterRepository;
6124
6093
  }
6125
6094
  async create(params) {
6126
- var _a;
6127
6095
  const { metadata } = params, data = __rest(params, ["metadata"]);
6128
- 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 }] }));
6096
+ return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
6129
6097
  }
6130
6098
  async get(identifiers) {
6131
6099
  const data = await super.get(identifiers);
@@ -6256,39 +6224,22 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6256
6224
  return plainData.products;
6257
6225
  }
6258
6226
  async updateMetadata(categoryId, { metadata }) {
6259
- if (Array.isArray(metadata) && !metadata.length)
6260
- return [];
6261
- if (Array.isArray(metadata) && metadata.length) {
6262
- const metadataUpdated = [];
6263
- for (const data of metadata) {
6264
- const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
6265
- pk_columns: {
6266
- value: { category_id: categoryId, shop: data.shop },
6267
- type: 'category_metadata_pk_columns_input',
6268
- required: true,
6269
- },
6270
- _set: {
6271
- value: omit(data, ['category_id', 'shop']),
6272
- type: 'category_metadata_set_input',
6273
- required: true,
6274
- },
6275
- });
6276
- metadataUpdated.push(update);
6277
- }
6278
- return metadataUpdated;
6279
- }
6280
- if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
6281
- for (let i = 0; i < metadata.value.length; i++) {
6282
- await this.mutation('delete_category_metadata', ['affected_rows'], {
6283
- where: {
6284
- type: 'category_metadata_bool_exp',
6285
- required: true,
6286
- value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
6287
- },
6288
- });
6289
- }
6290
- return [];
6291
- }
6227
+ const plainData = this.paramsToPlain({ metadata });
6228
+ if (!plainData.metadata)
6229
+ return;
6230
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
6231
+ pk_columns: {
6232
+ value: { category_id: categoryId },
6233
+ type: 'category_metadata_pk_columns_input',
6234
+ required: true,
6235
+ },
6236
+ _set: {
6237
+ value: omit(metadata, ['category_id']),
6238
+ type: 'category_metadata_set_input',
6239
+ required: true,
6240
+ },
6241
+ });
6242
+ return plainData.metadata;
6292
6243
  }
6293
6244
  }
6294
6245
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.9.7-beta.14",
3
+ "version": "4.9.7-beta.16",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -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, CategoryImages, CategoryMetadata, CategoryMostRelevant } from './types';
4
+ import { CategoryCondition, CategoryMetadata } 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,7 +9,6 @@ export declare class CategoryBase<ChildCategory extends ModelBaseStructure<Child
9
9
  name: string;
10
10
  slug: string;
11
11
  image?: string;
12
- images?: CategoryImages;
13
12
  brandCategoryBanner?: string;
14
13
  brandCategoryBannerMobile?: string;
15
14
  description: string;
@@ -20,28 +19,15 @@ export declare class CategoryBase<ChildCategory extends ModelBaseStructure<Child
20
19
  shop?: Shops;
21
20
  shops?: string[];
22
21
  published: boolean;
23
- metadata: CategoryMetadata[];
22
+ metadata: CategoryMetadata;
24
23
  isCollection?: boolean;
25
24
  isWishlist?: boolean;
26
25
  reference?: string;
27
26
  parentId?: number;
28
27
  theme?: string;
29
28
  bannerUrl?: string;
30
- mostRelevant?: CategoryMostRelevant;
29
+ mostRelevant?: string[];
31
30
  parent?: CategoryBase;
32
31
  filters?: Filter[];
33
32
  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[];
47
33
  }
@@ -1,6 +1,4 @@
1
- import { Shops } from '../enums';
2
1
  export type CategoryMetadata = {
3
- shop: Shops;
4
2
  title?: string;
5
3
  description?: string;
6
4
  };
@@ -1,7 +1,5 @@
1
1
  export * from './category-condition.type';
2
- export * from './category-images.type';
3
2
  export * from './category-metadata.type';
4
- export * from './category-most-relevant.type';
5
3
  export * from './category-product';
6
4
  export * from './product-evaluation.type';
7
5
  export * from './product-gender.type';
@@ -1,17 +1,21 @@
1
1
  export type ReportStockNotification = {
2
+ product_id: string;
2
3
  ean: string;
3
4
  sku: string;
4
5
  name: string;
5
6
  stock: number;
6
7
  category: string;
8
+ category_id: string;
7
9
  category_reference: string;
8
10
  emails_registered: number;
9
11
  };
10
12
  export type ReportStockNotificationInput = {
13
+ productId?: string;
11
14
  ean?: string;
12
15
  sku?: string;
13
16
  name?: string;
14
17
  category?: string;
18
+ categoryId?: string;
15
19
  reference?: string;
16
20
  emailsCount?: number;
17
21
  };
@@ -1,8 +0,0 @@
1
- import { Shops } from '../enums';
2
- export type CategoryImages = {
3
- [shop in Shops]?: {
4
- image: string;
5
- brandBanner: string;
6
- brandBannerMobile: string;
7
- };
8
- };
@@ -1,4 +0,0 @@
1
- import { Shops } from '../enums';
2
- export type CategoryMostRelevant = {
3
- [shop in Shops]?: string[];
4
- };