@vario-software/vario-app-framework-backend 2026.22.0 → 2026.22.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/migrator.js +90 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vario-software/vario-app-framework-backend",
3
- "version": "2026.22.0",
3
+ "version": "2026.22.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
@@ -88,7 +88,22 @@ const Migrator = class
88
88
 
89
89
  getEavGroup: async groupKey =>
90
90
  {
91
- const eavGroup = await this.ApiAdapter.eav.getGroup(groupKey);
91
+ let eavGroup;
92
+
93
+ try
94
+ {
95
+ eavGroup = await this.ApiAdapter.eav.getGroup(groupKey);
96
+ }
97
+ catch (error)
98
+ {
99
+ const message = error.statusCode === 404
100
+ ? `EAV-Group with key "${groupKey}" could not be read because it does not exist (HTTP 404). It must be created by an earlier migration before it can be read or changed.`
101
+ : `EAV-Group with key "${groupKey}" could not be read (HTTP ${error.statusCode ?? 'unknown'}): ${error.message}`;
102
+
103
+ await this.methods.log(message, 'ERROR');
104
+
105
+ throw error;
106
+ }
92
107
 
93
108
  await this.methods.log(`EAV-Group "${eavGroup.label}" with id "${eavGroup.id}" successfully read\n`);
94
109
 
@@ -617,23 +632,88 @@ const Migrator = class
617
632
  }
618
633
 
619
634
  const scriptGroup = await this.methods.getOrCreateScriptModuleGroup();
635
+ const scriptContent = typeof script === 'string' ? script : JSON.stringify(script);
620
636
 
621
- const { data: scriptModule } = await this.ApiAdapter.fetch(
622
- '/cmn/scripting/modules/presettings',
637
+ const { data: existingModules } = await this.ApiAdapter.fetch(
638
+ '/cmn/computed-queries/scripting/script-modules',
623
639
  {
624
640
  method: 'POST',
625
641
  body: {
626
- name: triggerId,
627
- script: typeof script === 'string' ? script : JSON.stringify(script),
628
- domain: 'APP',
629
- groupRef: { id: scriptGroup.id },
630
- permissionAggregation: {
631
- operationForAllUsers: 'READ_AND_EDIT',
642
+ adhocPreset: {
643
+ queryPredicate: {
644
+ type: 'JUNCTION',
645
+ operator: 'AND',
646
+ children: [
647
+ {
648
+ type: 'FILTER',
649
+ operator: 'EQUALS',
650
+ property: 'name',
651
+ values: [triggerId],
652
+ },
653
+ {
654
+ type: 'FILTER',
655
+ operator: 'EQUALS',
656
+ property: 'group.id',
657
+ values: [scriptGroup.id],
658
+ },
659
+ ],
660
+ },
661
+ results: [
662
+ { property: 'id' },
663
+ { property: 'name' },
664
+ ],
632
665
  },
633
666
  },
634
667
  },
635
668
  );
636
669
 
670
+ let scriptModuleRef;
671
+
672
+ if (existingModules?.data?.length > 0)
673
+ {
674
+ const moduleId = existingModules.data[0].id;
675
+
676
+ const { data: existingPresetting } = await this.ApiAdapter.fetch(
677
+ `/cmn/scripting/modules/${moduleId}/presettings`,
678
+ { method: 'GET' },
679
+ );
680
+
681
+ await this.ApiAdapter.fetch(
682
+ `/cmn/scripting/modules/${moduleId}/presettings`,
683
+ {
684
+ method: 'PUT',
685
+ body: {
686
+ ...existingPresetting,
687
+ script: scriptContent,
688
+ },
689
+ },
690
+ );
691
+
692
+ await this.methods.log(`Script-Module-Presetting "${triggerId}" already existed, updated (ID: ${moduleId})\n`);
693
+
694
+ scriptModuleRef = { id: moduleId };
695
+ }
696
+ else
697
+ {
698
+ const { data: scriptModule } = await this.ApiAdapter.fetch(
699
+ '/cmn/scripting/modules/presettings',
700
+ {
701
+ method: 'POST',
702
+ body: {
703
+ name: triggerId,
704
+ script: scriptContent,
705
+ domain: 'APP',
706
+ groupRef: { id: scriptGroup.id },
707
+ permissionAggregation: {
708
+ operationForAllUsers: 'READ_AND_EDIT',
709
+ },
710
+ },
711
+ },
712
+ );
713
+
714
+ scriptModuleRef = { id: scriptModule.id };
715
+ }
716
+
637
717
  await this.ApiAdapter.fetch(
638
718
  `/community/${this.app.version}/cmn/system/app-scripting-proxy`,
639
719
  {
@@ -641,7 +721,7 @@ const Migrator = class
641
721
  body: {
642
722
  appIdentifier: this.app.client.appIdentifier,
643
723
  triggerId,
644
- scriptModuleRef: { id: scriptModule.id },
724
+ scriptModuleRef,
645
725
  },
646
726
  },
647
727
  );