@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/migrator.js +108 -17
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.2",
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
 
@@ -331,10 +346,10 @@ const Migrator = class
331
346
  children: [
332
347
  {
333
348
  type: 'FILTER',
334
- property: 'label',
349
+ property: 'appId',
335
350
  operator: 'EQUALS',
336
351
  values: [
337
- label,
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 { data: finance } = await this.ApiAdapter.fetch(`/community/${this.app.version}/erp/finance/backend/${financeBackend?.data?.[0].id}`, {
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
- label,
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 created\n`);
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: scriptModule } = await this.ApiAdapter.fetch(
622
- '/cmn/scripting/modules/presettings',
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
- 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',
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: { id: scriptModule.id },
735
+ scriptModuleRef,
645
736
  },
646
737
  },
647
738
  );