diff --git a/packages/backend/src/apps/changedetection/dynamic-data/index.js b/packages/backend/src/apps/changedetection/dynamic-data/index.js
new file mode 100644
index 00000000..a7466c57
--- /dev/null
+++ b/packages/backend/src/apps/changedetection/dynamic-data/index.js
@@ -0,0 +1,3 @@
+import listWatches from './list-watches/index.js';
+
+export default [listWatches];
diff --git a/packages/backend/src/apps/changedetection/dynamic-data/list-watches/index.js b/packages/backend/src/apps/changedetection/dynamic-data/list-watches/index.js
new file mode 100644
index 00000000..44c268cd
--- /dev/null
+++ b/packages/backend/src/apps/changedetection/dynamic-data/list-watches/index.js
@@ -0,0 +1,24 @@
+export default {
+ name: 'List watches',
+ key: 'listWatches',
+
+ async run($) {
+ const watches = {
+ data: [],
+ };
+
+ const { data } = await $.http.get('/v1/watch');
+ const watchIds = Object.keys(data);
+
+ if (watchIds?.length) {
+ for (const watchId of watchIds) {
+ watches.data.push({
+ value: watchId,
+ name: data[watchId].url,
+ });
+ }
+ }
+
+ return watches;
+ },
+};
diff --git a/packages/backend/src/apps/changedetection/index.js b/packages/backend/src/apps/changedetection/index.js
index 7ed77fdf..a6dd388f 100644
--- a/packages/backend/src/apps/changedetection/index.js
+++ b/packages/backend/src/apps/changedetection/index.js
@@ -3,6 +3,8 @@ import addAuthHeader from './common/add-auth-header.js';
import auth from './auth/index.js';
import setBaseUrl from './common/set-base-url.js';
import actions from './actions/index.js';
+import dynamicData from './dynamic-data/index.js';
+import triggers from './triggers/index.js';
export default defineApp({
name: 'Changedetection',
@@ -16,4 +18,6 @@ export default defineApp({
beforeRequest: [setBaseUrl, addAuthHeader],
auth,
actions,
+ dynamicData,
+ triggers,
});
diff --git a/packages/backend/src/apps/changedetection/triggers/changed-watch/index.js b/packages/backend/src/apps/changedetection/triggers/changed-watch/index.js
new file mode 100644
index 00000000..335db00f
--- /dev/null
+++ b/packages/backend/src/apps/changedetection/triggers/changed-watch/index.js
@@ -0,0 +1,43 @@
+import defineTrigger from '../../../../helpers/define-trigger.js';
+
+export default defineTrigger({
+ name: 'Changed watch',
+ key: 'changedWatch',
+ pollInterval: 15,
+ description: 'Triggers when any changes detected.',
+ arguments: [
+ {
+ label: 'Watch',
+ key: 'watchId',
+ type: 'dropdown',
+ required: true,
+ description: '',
+ variables: true,
+ source: {
+ type: 'query',
+ name: 'getDynamicData',
+ arguments: [
+ {
+ name: 'key',
+ value: 'listWatches',
+ },
+ ],
+ },
+ },
+ ],
+
+ async run($) {
+ const watchId = $.step.parameters.watchId;
+
+ const { data } = await $.http.get(`v1/watch/${watchId}`);
+
+ if (Object.keys(data).length !== 0) {
+ $.pushTriggerItem({
+ raw: data,
+ meta: {
+ internalId: `${watchId}-${data.last_changed}`,
+ },
+ });
+ }
+ },
+});
diff --git a/packages/backend/src/apps/changedetection/triggers/index.js b/packages/backend/src/apps/changedetection/triggers/index.js
new file mode 100644
index 00000000..eabe35bc
--- /dev/null
+++ b/packages/backend/src/apps/changedetection/triggers/index.js
@@ -0,0 +1,3 @@
+import changedWatch from './changed-watch/index.js';
+
+export default [changedWatch];
diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js
index 64ae87e6..84811442 100644
--- a/packages/docs/pages/.vitepress/config.js
+++ b/packages/docs/pages/.vitepress/config.js
@@ -46,6 +46,8 @@ export default defineConfig({
collapsible: true,
collapsed: true,
items: [
+ { text: 'Triggers', link: '/apps/changedetection/triggers' },
+ { text: 'Actions', link: '/apps/changedetection/actions' },
{ text: 'Connection', link: '/apps/changedetection/connection' },
],
},
diff --git a/packages/docs/pages/apps/changedetection/triggers.md b/packages/docs/pages/apps/changedetection/triggers.md
new file mode 100644
index 00000000..e8c7ef34
--- /dev/null
+++ b/packages/docs/pages/apps/changedetection/triggers.md
@@ -0,0 +1,12 @@
+---
+favicon: /favicons/changedetection.svg
+items:
+ - name: Changed watch
+ desc: Triggers when any changes detected.
+---
+
+
+
+