@vario-software/vario-app-framework-backend 2026.22.0 → 2026.22.2
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 +108 -17
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
|
|
|
@@ -331,10 +346,10 @@ const Migrator = class
|
|
|
331
346
|
children: [
|
|
332
347
|
{
|
|
333
348
|
type: 'FILTER',
|
|
334
|
-
property: '
|
|
349
|
+
property: 'appId',
|
|
335
350
|
operator: 'EQUALS',
|
|
336
351
|
values: [
|
|
337
|
-
|
|
352
|
+
this.app.client.appIdentifier,
|
|
338
353
|
],
|
|
339
354
|
},
|
|
340
355
|
],
|
|
@@ -350,17 +365,28 @@ const Migrator = class
|
|
|
350
365
|
},
|
|
351
366
|
);
|
|
352
367
|
|
|
353
|
-
const
|
|
368
|
+
const id = financeBackend?.data?.[0]?.id;
|
|
369
|
+
|
|
370
|
+
if (!id)
|
|
371
|
+
{
|
|
372
|
+
await this.methods.log(`No Finance Backend found for label "${label}"\n`, 'ERROR');
|
|
373
|
+
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const { data: existingFinanceBackend } = await this.ApiAdapter.fetch(`/erp/finance/backend/${id}`, {
|
|
378
|
+
method: 'GET',
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const { data: finance } = await this.ApiAdapter.fetch(`/erp/finance/backend/${id}`, {
|
|
354
382
|
method: 'PUT',
|
|
355
383
|
body: JSON.stringify({
|
|
356
|
-
|
|
384
|
+
...existingFinanceBackend,
|
|
357
385
|
description,
|
|
358
|
-
usePerformanceDate: false,
|
|
359
|
-
appId: this.app.client.appIdentifier,
|
|
360
386
|
}),
|
|
361
387
|
});
|
|
362
388
|
|
|
363
|
-
await this.methods.log(`Finance Backend with id "${finance.id}" successfully
|
|
389
|
+
await this.methods.log(`Finance Backend with id "${finance.id}" successfully updated\n`);
|
|
364
390
|
|
|
365
391
|
return finance;
|
|
366
392
|
},
|
|
@@ -617,23 +643,88 @@ const Migrator = class
|
|
|
617
643
|
}
|
|
618
644
|
|
|
619
645
|
const scriptGroup = await this.methods.getOrCreateScriptModuleGroup();
|
|
646
|
+
const scriptContent = typeof script === 'string' ? script : JSON.stringify(script);
|
|
620
647
|
|
|
621
|
-
const { data:
|
|
622
|
-
'/cmn/scripting/modules
|
|
648
|
+
const { data: existingModules } = await this.ApiAdapter.fetch(
|
|
649
|
+
'/cmn/computed-queries/scripting/script-modules',
|
|
623
650
|
{
|
|
624
651
|
method: 'POST',
|
|
625
652
|
body: {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
653
|
+
adhocPreset: {
|
|
654
|
+
queryPredicate: {
|
|
655
|
+
type: 'JUNCTION',
|
|
656
|
+
operator: 'AND',
|
|
657
|
+
children: [
|
|
658
|
+
{
|
|
659
|
+
type: 'FILTER',
|
|
660
|
+
operator: 'EQUALS',
|
|
661
|
+
property: 'name',
|
|
662
|
+
values: [triggerId],
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
type: 'FILTER',
|
|
666
|
+
operator: 'EQUALS',
|
|
667
|
+
property: 'group.id',
|
|
668
|
+
values: [scriptGroup.id],
|
|
669
|
+
},
|
|
670
|
+
],
|
|
671
|
+
},
|
|
672
|
+
results: [
|
|
673
|
+
{ property: 'id' },
|
|
674
|
+
{ property: 'name' },
|
|
675
|
+
],
|
|
632
676
|
},
|
|
633
677
|
},
|
|
634
678
|
},
|
|
635
679
|
);
|
|
636
680
|
|
|
681
|
+
let scriptModuleRef;
|
|
682
|
+
|
|
683
|
+
if (existingModules?.data?.length > 0)
|
|
684
|
+
{
|
|
685
|
+
const moduleId = existingModules.data[0].id;
|
|
686
|
+
|
|
687
|
+
const { data: existingPresetting } = await this.ApiAdapter.fetch(
|
|
688
|
+
`/cmn/scripting/modules/${moduleId}/presettings`,
|
|
689
|
+
{ method: 'GET' },
|
|
690
|
+
);
|
|
691
|
+
|
|
692
|
+
await this.ApiAdapter.fetch(
|
|
693
|
+
`/cmn/scripting/modules/${moduleId}/presettings`,
|
|
694
|
+
{
|
|
695
|
+
method: 'PUT',
|
|
696
|
+
body: {
|
|
697
|
+
...existingPresetting,
|
|
698
|
+
script: scriptContent,
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
);
|
|
702
|
+
|
|
703
|
+
await this.methods.log(`Script-Module-Presetting "${triggerId}" already existed, updated (ID: ${moduleId})\n`);
|
|
704
|
+
|
|
705
|
+
scriptModuleRef = { id: moduleId };
|
|
706
|
+
}
|
|
707
|
+
else
|
|
708
|
+
{
|
|
709
|
+
const { data: scriptModule } = await this.ApiAdapter.fetch(
|
|
710
|
+
'/cmn/scripting/modules/presettings',
|
|
711
|
+
{
|
|
712
|
+
method: 'POST',
|
|
713
|
+
body: {
|
|
714
|
+
name: triggerId,
|
|
715
|
+
script: scriptContent,
|
|
716
|
+
domain: 'APP',
|
|
717
|
+
groupRef: { id: scriptGroup.id },
|
|
718
|
+
permissionAggregation: {
|
|
719
|
+
operationForAllUsers: 'READ_AND_EDIT',
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
);
|
|
724
|
+
|
|
725
|
+
scriptModuleRef = { id: scriptModule.id };
|
|
726
|
+
}
|
|
727
|
+
|
|
637
728
|
await this.ApiAdapter.fetch(
|
|
638
729
|
`/community/${this.app.version}/cmn/system/app-scripting-proxy`,
|
|
639
730
|
{
|
|
@@ -641,7 +732,7 @@ const Migrator = class
|
|
|
641
732
|
body: {
|
|
642
733
|
appIdentifier: this.app.client.appIdentifier,
|
|
643
734
|
triggerId,
|
|
644
|
-
scriptModuleRef
|
|
735
|
+
scriptModuleRef,
|
|
645
736
|
},
|
|
646
737
|
},
|
|
647
738
|
);
|