@vario-software/vario-app-framework-backend 2025.45.0 → 2025.46.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.
@@ -35,9 +35,7 @@ const Eav = class
35
35
 
36
36
  changeGroup = async function (groupKey, callback)
37
37
  {
38
- let { data: eavGroup } = await this.ApiAdapter.fetch(`/cmn/eav-groups/by-key/${groupKey}`, {
39
- method: 'GET',
40
- });
38
+ let eavGroup = await this.getGroup(groupKey);
41
39
 
42
40
  eavGroup = callback(eavGroup);
43
41
 
@@ -51,7 +49,7 @@ const Eav = class
51
49
 
52
50
  deleteGroup = async function (groupKey)
53
51
  {
54
- const { data: eavGroup } = await this.ApiAdapter.fetch(`/cmn/eav-groups/by-key/${groupKey}`);
52
+ const eavGroup = await this.getGroup(groupKey);
55
53
 
56
54
  await this.ApiAdapter.fetch(`/cmn/eav-groups/${eavGroup.id}/remove-data`, {
57
55
  method: 'POST',
@@ -65,11 +63,27 @@ const Eav = class
65
63
  return true;
66
64
  };
67
65
 
66
+ removeDataFromGroup = async function (groupKey, attributeKeys = [])
67
+ {
68
+ const eavGroup = await this.getGroup(groupKey);
69
+
70
+ const attributeId = attributeKeys
71
+ .map(attrKey => eavGroup.attributes?.find(({ key }) => key === attrKey)?.id)
72
+ .filter(id => id !== null || id !== undefined);
73
+
74
+ await this.ApiAdapter.fetch(`/cmn/eav-groups/${eavGroup.id}/remove-data`, {
75
+ method: 'POST',
76
+ body: JSON.stringify({ entities: eavGroup.entities, attributeId }),
77
+ });
78
+
79
+ return true;
80
+ };
81
+
68
82
  getGroupIdByKey = async function(groupKey)
69
83
  {
70
84
  try
71
85
  {
72
- const { data: eavGroup } = await this.ApiAdapter.fetch(`/cmn/eav-groups/by-key/${groupKey}`);
86
+ const eavGroup = await this.getGroup(groupKey);
73
87
 
74
88
  return eavGroup.id;
75
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vario-software/vario-app-framework-backend",
3
- "version": "2025.45.0",
3
+ "version": "2025.46.0",
4
4
  "repository": "https://github.com/vario-software/vario-app-framework",
5
5
  "author": "VARIO Software AG",
6
6
  "homepage": "https://www.vario.ag",
package/utils/migrator.js CHANGED
@@ -53,6 +53,26 @@ const Migrator = class
53
53
  }
54
54
  };
55
55
 
56
+ always = async function (key, callback)
57
+ {
58
+ const migration = `${this.key}.${key}`;
59
+
60
+ const context = getContext();
61
+
62
+ context.migration = migration;
63
+
64
+ try
65
+ {
66
+ await callback(this.methods, this.migrationResults);
67
+ }
68
+ catch (error)
69
+ {
70
+ await this.app.onMigrationError(error);
71
+
72
+ await this.methods.log(`Migration "${migration}" failed\n\n${error.message}`, 'ERROR', error.message);
73
+ }
74
+ };
75
+
56
76
  methods = {
57
77
  log: async (message, level = 'INFO') =>
58
78
  {
@@ -101,6 +121,20 @@ const Migrator = class
101
121
  return eavGroup;
102
122
  },
103
123
 
124
+ removeDataFromEavGroup: async (groupKey, attributeKeys) =>
125
+ {
126
+ const eavGroup = await this.ApiAdapter.eav.removeDataFromGroup(groupKey, attributeKeys);
127
+
128
+ const hasAttributeKeys = Array.isArray(attributeKeys) && attributeKeys.length > 0;
129
+ const logMessage = hasAttributeKeys
130
+ ? `Data for the specified attributes (${attributeKeys.join(', ')}) in EAV group "${groupKey}" was successfully removed.\n`
131
+ : `All data from EAV group "${groupKey}" was successfully removed.\n`;
132
+
133
+ await this.methods.log(logMessage);
134
+
135
+ return eavGroup;
136
+ },
137
+
104
138
  createTextEnumGroup: async textEnumGroup =>
105
139
  {
106
140
  textEnumGroup = await this.ApiAdapter.textenum.setGroup(textEnumGroup);