@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.
- package/package.json +1 -1
- package/utils/migrator.js +90 -10
package/package.json
CHANGED
package/utils/migrator.js
CHANGED
|
@@ -88,7 +88,22 @@ const Migrator = class
|
|
|
88
88
|
|
|
89
89
|
getEavGroup: async groupKey =>
|
|
90
90
|
{
|
|
91
|
-
|
|
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:
|
|
622
|
-
'/cmn/scripting/modules
|
|
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
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
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
|
|
724
|
+
scriptModuleRef,
|
|
645
725
|
},
|
|
646
726
|
},
|
|
647
727
|
);
|