@vario-software/vario-app-framework-backend 2026.14.1 → 2026.15.0
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/modules/webhook.js +27 -0
- package/package.json +1 -1
- package/utils/migrator.js +20 -0
package/api/modules/webhook.js
CHANGED
|
@@ -41,6 +41,33 @@ const Webhook = class
|
|
|
41
41
|
}),
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
+
|
|
45
|
+
getRegistered = async function()
|
|
46
|
+
{
|
|
47
|
+
const app = getApp();
|
|
48
|
+
|
|
49
|
+
const { data } = await this.ApiAdapter.vql({
|
|
50
|
+
statement: `
|
|
51
|
+
SELECT destinationQueue, url
|
|
52
|
+
FROM system.queryAppMessageWebhook
|
|
53
|
+
WHERE appIdentifier = '${app.client.appIdentifier}'
|
|
54
|
+
`,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return data || [];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
isRegistered = async function(destinationQueue, url)
|
|
61
|
+
{
|
|
62
|
+
const apiUrl = `${process.env.WEBHOOK_HOST ?? `https://${getRequest().get('host')}`}`;
|
|
63
|
+
const fullUrl = `${apiUrl}${url}`;
|
|
64
|
+
|
|
65
|
+
const registeredWebhooks = await this.getRegistered();
|
|
66
|
+
|
|
67
|
+
return registeredWebhooks.some(
|
|
68
|
+
webhook => webhook.destinationQueue === destinationQueue && webhook.url === fullUrl,
|
|
69
|
+
);
|
|
70
|
+
};
|
|
44
71
|
};
|
|
45
72
|
|
|
46
73
|
module.exports = Webhook;
|
package/package.json
CHANGED
package/utils/migrator.js
CHANGED
|
@@ -158,6 +158,26 @@ const Migrator = class
|
|
|
158
158
|
await this.methods.log(`Webhook for destination "${destinationQueue}" deregistered\n`);
|
|
159
159
|
},
|
|
160
160
|
|
|
161
|
+
isWebhookRegistered: async (destinationQueue, url) => this.ApiAdapter.webhook.isRegistered(destinationQueue, url),
|
|
162
|
+
|
|
163
|
+
registerWebhookIfNotExists: async (destinationQueue, url) =>
|
|
164
|
+
{
|
|
165
|
+
const isRegistered = await this.ApiAdapter.webhook.isRegistered(destinationQueue, url);
|
|
166
|
+
|
|
167
|
+
if (isRegistered)
|
|
168
|
+
{
|
|
169
|
+
await this.methods.log(`Webhook for destination "${destinationQueue}" already registered, skipping\n`);
|
|
170
|
+
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
await this.ApiAdapter.webhook.register(destinationQueue, url);
|
|
175
|
+
|
|
176
|
+
await this.methods.log(`Webhook for destination "${destinationQueue}" registered\n`);
|
|
177
|
+
|
|
178
|
+
return true;
|
|
179
|
+
},
|
|
180
|
+
|
|
161
181
|
createSalesChannelBackend: async (label, validChannelTypes) =>
|
|
162
182
|
{
|
|
163
183
|
const { data: salesChannelBackend } = await this.ApiAdapter.fetch(`/community/${this.app.version}/erp/sales-channels/backend`, {
|