@vario-software/vario-app-framework-backend 2025.45.0 → 2025.46.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.
@@ -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.1",
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);
@@ -315,6 +349,15 @@ const Migrator = class
315
349
 
316
350
  addAppScriptingTrigger: async (triggerId, script) =>
317
351
  {
352
+ const existingProxyId = await this.methods.getAppScriptingTriggerId(triggerId);
353
+
354
+ if (existingProxyId)
355
+ {
356
+ this.methods.updateAppScriptingTrigger(triggerId, script, existingProxyId);
357
+
358
+ return;
359
+ }
360
+
318
361
  await this.ApiAdapter.fetch(
319
362
  '/community/latest/cmn/system/app-scripting-proxy',
320
363
  {
@@ -327,8 +370,44 @@ const Migrator = class
327
370
  }),
328
371
  });
329
372
 
373
+ await this.methods.log(`App-Script-Trigger with id "${triggerId}" successfully created\n`);
374
+ },
375
+
376
+ updateAppScriptingTrigger: async (triggerId, script, id) =>
377
+ {
378
+ if (!id)
379
+ {
380
+ id = await this.getAppScriptingTriggerId(triggerId);
381
+ }
382
+
383
+ await this.ApiAdapter.fetch(
384
+ `/community/latest/cmn/system/app-scripting-proxy/${id}`,
385
+ {
386
+ useInternalApi: true,
387
+ method: 'PUT',
388
+ body: JSON.stringify({
389
+ appIdentifier: this.app.client.appIdentifier,
390
+ triggerId,
391
+ script,
392
+ }),
393
+ });
394
+
330
395
  await this.methods.log(`App-Script-Trigger with id "${triggerId}" successfully updated\n`);
331
396
  },
397
+
398
+ getAppScriptingTriggerId: async triggerId =>
399
+ {
400
+ const { data: existingProxy } = await this.ApiAdapter.vql({
401
+ statement: `
402
+ SELECT id
403
+ FROM system.queryAppScriptingProxies
404
+ WHERE appIdentifier = '${this.app.client.appIdentifier}'
405
+ AND triggerId = '${triggerId}'
406
+ `,
407
+ });
408
+
409
+ return existingProxy[0]?.id;
410
+ },
332
411
  };
333
412
  };
334
413