@vario-software/vario-app-framework-backend 2026.21.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/api/helpers/vql.js +4 -2
- package/api/modules/webhook.js +4 -4
- package/package.json +1 -1
- package/utils/context.js +8 -0
- package/utils/migrator.js +117 -23
package/api/helpers/vql.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function vql({ statement, variableSubstitutions = [], limit = null, offset = null })
|
|
1
|
+
async function vql({ statement, variableSubstitutions = [], limit = null, offset = null, mapDisplayNames = true })
|
|
2
2
|
{
|
|
3
3
|
const payload = {
|
|
4
4
|
statement,
|
|
@@ -24,7 +24,9 @@ async function vql({ statement, variableSubstitutions = [], limit = null, offset
|
|
|
24
24
|
|
|
25
25
|
return {
|
|
26
26
|
...result.data,
|
|
27
|
-
data:
|
|
27
|
+
data: mapDisplayNames
|
|
28
|
+
? mapDisplayName(result.data.definition, result.data.data)
|
|
29
|
+
: result.data.data,
|
|
28
30
|
moreElements: result.response.headers['x-query-more-elements'],
|
|
29
31
|
nextOffset: result.response.headers['x-query-next-offset'],
|
|
30
32
|
};
|
package/api/modules/webhook.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { getAppDomain } = require('#backend/utils/context.js');
|
|
2
2
|
const { getApp } = require('#backend/utils/context.js');
|
|
3
3
|
|
|
4
4
|
const Webhook = class
|
|
@@ -10,7 +10,7 @@ const Webhook = class
|
|
|
10
10
|
|
|
11
11
|
register = async function(destinationQueue, url, destinationOwner)
|
|
12
12
|
{
|
|
13
|
-
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${
|
|
13
|
+
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${getAppDomain()}`}`;
|
|
14
14
|
|
|
15
15
|
const app = getApp();
|
|
16
16
|
|
|
@@ -27,7 +27,7 @@ const Webhook = class
|
|
|
27
27
|
|
|
28
28
|
deregister = async function(destinationQueue, url, destinationOwner)
|
|
29
29
|
{
|
|
30
|
-
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${
|
|
30
|
+
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${getAppDomain()}`}`;
|
|
31
31
|
|
|
32
32
|
const app = getApp();
|
|
33
33
|
|
|
@@ -59,7 +59,7 @@ const Webhook = class
|
|
|
59
59
|
|
|
60
60
|
isRegistered = async function(destinationQueue, url)
|
|
61
61
|
{
|
|
62
|
-
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${
|
|
62
|
+
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${getAppDomain()}`}`;
|
|
63
63
|
const fullUrl = `${apiUrl}${url}`;
|
|
64
64
|
|
|
65
65
|
const registeredWebhooks = await this.getRegistered();
|
package/package.json
CHANGED
package/utils/context.js
CHANGED
|
@@ -33,6 +33,13 @@ function getTenant()
|
|
|
33
33
|
return tenant;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
function getAppDomain()
|
|
37
|
+
{
|
|
38
|
+
const appDomain = getAccessToken()?.appDomain;
|
|
39
|
+
|
|
40
|
+
return appDomain;
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
function getExternalUserId()
|
|
37
44
|
{
|
|
38
45
|
const externalUserId = getAccessToken()?.sub;
|
|
@@ -72,6 +79,7 @@ module.exports = {
|
|
|
72
79
|
getContext,
|
|
73
80
|
getAppToken,
|
|
74
81
|
getAccessToken,
|
|
82
|
+
getAppDomain,
|
|
75
83
|
getTenant,
|
|
76
84
|
getExternalUserId,
|
|
77
85
|
getRequest,
|
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
|
|
|
@@ -211,21 +226,35 @@ const Migrator = class
|
|
|
211
226
|
|
|
212
227
|
createSalesChannel: async (salesChannelBackend, label, description, channelType = 'ECOMMERCE') =>
|
|
213
228
|
{
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
try
|
|
230
|
+
{
|
|
231
|
+
const { data: salesChannel } = await this.ApiAdapter.fetch(`/community/${this.app.version}/erp/sales-channels`, {
|
|
232
|
+
method: 'POST',
|
|
233
|
+
body: JSON.stringify({
|
|
234
|
+
label,
|
|
235
|
+
description,
|
|
236
|
+
active: true,
|
|
237
|
+
channelType,
|
|
238
|
+
channelBackend: { id: salesChannelBackend.id },
|
|
239
|
+
externalRef: '',
|
|
240
|
+
}),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
await this.methods.log(`Sales-Channel with id "${salesChannel.id}" successfully created\n`);
|
|
225
244
|
|
|
226
|
-
|
|
245
|
+
return salesChannel;
|
|
246
|
+
}
|
|
247
|
+
catch (error)
|
|
248
|
+
{
|
|
249
|
+
if (error.statusCode === 402)
|
|
250
|
+
{
|
|
251
|
+
await this.methods.log('Missing Sales-Channel license\n', 'WARNING');
|
|
227
252
|
|
|
228
|
-
|
|
253
|
+
return {};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
229
258
|
},
|
|
230
259
|
|
|
231
260
|
getSalesChannels: async () =>
|
|
@@ -603,23 +632,88 @@ const Migrator = class
|
|
|
603
632
|
}
|
|
604
633
|
|
|
605
634
|
const scriptGroup = await this.methods.getOrCreateScriptModuleGroup();
|
|
635
|
+
const scriptContent = typeof script === 'string' ? script : JSON.stringify(script);
|
|
606
636
|
|
|
607
|
-
const { data:
|
|
608
|
-
'/cmn/scripting/modules
|
|
637
|
+
const { data: existingModules } = await this.ApiAdapter.fetch(
|
|
638
|
+
'/cmn/computed-queries/scripting/script-modules',
|
|
609
639
|
{
|
|
610
640
|
method: 'POST',
|
|
611
641
|
body: {
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
+
],
|
|
618
665
|
},
|
|
619
666
|
},
|
|
620
667
|
},
|
|
621
668
|
);
|
|
622
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
|
+
|
|
623
717
|
await this.ApiAdapter.fetch(
|
|
624
718
|
`/community/${this.app.version}/cmn/system/app-scripting-proxy`,
|
|
625
719
|
{
|
|
@@ -627,7 +721,7 @@ const Migrator = class
|
|
|
627
721
|
body: {
|
|
628
722
|
appIdentifier: this.app.client.appIdentifier,
|
|
629
723
|
triggerId,
|
|
630
|
-
scriptModuleRef
|
|
724
|
+
scriptModuleRef,
|
|
631
725
|
},
|
|
632
726
|
},
|
|
633
727
|
);
|