feat(changedetection): add create watch action

This commit is contained in:
Rıdvan Akca
2024-05-13 16:31:18 +02:00
parent c095d3138b
commit 58c90da385
6 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create a watch',
key: 'createWatch',
description: 'Creates a new change detection watch for a specific website.',
arguments: [
{
label: 'URL',
key: 'url',
type: 'string',
required: true,
variables: true,
description: 'Url you want to monitor',
},
],
async run($) {
const url = $.step.parameters.url;
const body = {
url,
};
const response = await $.http.post('/v1/watch', body);
$.setActionItem({ raw: response.data });
},
});

View File

@@ -0,0 +1,3 @@
import createWatch from './create-watch/index.js';
export default [createWatch];

View File

@@ -2,6 +2,7 @@ import defineApp from '../../helpers/define-app.js';
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';
export default defineApp({
name: 'Changedetection',
@@ -14,4 +15,5 @@ export default defineApp({
primaryColor: '3056d3',
beforeRequest: [setBaseUrl, addAuthHeader],
auth,
actions,
});