@nvent-addon/app 0.4.5 → 0.5.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/dist/module.d.mts +19 -1
- package/dist/module.mjs +20 -8
- package/dist/runtime/app/components/{nhealth/component-router.d.vue.ts → ComponentRouter.d.vue.ts} +1 -5
- package/dist/runtime/app/components/{nhealth/component-router.vue.d.ts → ComponentRouter.vue.d.ts} +1 -5
- package/dist/runtime/app/components/{nhealth/component-shell.d.vue.ts → ComponentShell.d.vue.ts} +4 -9
- package/dist/runtime/app/components/ComponentShell.vue +87 -0
- package/dist/runtime/app/components/{nhealth/component-shell.vue.d.ts → ComponentShell.vue.d.ts} +4 -9
- package/dist/runtime/app/components/ConfirmDialog.d.vue.ts +1 -6
- package/dist/runtime/app/components/ConfirmDialog.vue.d.ts +1 -6
- package/dist/runtime/app/components/ListItem.d.vue.ts +3 -6
- package/dist/runtime/app/components/ListItem.vue.d.ts +3 -6
- package/dist/runtime/app/components/LiveIndicator.d.vue.ts +7 -0
- package/dist/runtime/app/components/LiveIndicator.vue +30 -0
- package/dist/runtime/app/components/LiveIndicator.vue.d.ts +7 -0
- package/dist/runtime/app/components/{QueueConfigDetails.d.vue.ts → QueueConfiguration.d.vue.ts} +1 -10
- package/dist/runtime/app/components/QueueConfiguration.vue +387 -0
- package/dist/runtime/app/components/{QueueConfigDetails.vue.d.ts → QueueConfiguration.vue.d.ts} +1 -10
- package/dist/runtime/app/components/StatCard.d.vue.ts +9 -0
- package/dist/runtime/app/components/StatCard.vue +57 -0
- package/dist/runtime/app/components/StatCard.vue.d.ts +9 -0
- package/dist/runtime/app/components/TimelineList.vue +67 -0
- package/dist/runtime/app/components/flow/AwaitNode.d.vue.ts +18 -0
- package/dist/runtime/app/components/flow/AwaitNode.vue +91 -0
- package/dist/runtime/app/components/flow/AwaitNode.vue.d.ts +18 -0
- package/dist/runtime/app/components/{FlowDiagram.d.vue.ts → flow/Diagram.d.vue.ts} +12 -1
- package/dist/runtime/app/components/{FlowDiagram.vue → flow/Diagram.vue} +92 -11
- package/dist/runtime/app/components/{FlowDiagram.vue.d.ts → flow/Diagram.vue.d.ts} +12 -1
- package/dist/runtime/app/components/{FlowRunOverview.d.vue.ts → flow/RunOverview.d.vue.ts} +3 -0
- package/dist/runtime/app/components/{FlowRunOverview.vue → flow/RunOverview.vue} +94 -8
- package/dist/runtime/app/components/{FlowRunOverview.vue.d.ts → flow/RunOverview.vue.d.ts} +3 -0
- package/dist/runtime/app/components/{FlowRunStatusBadge.d.vue.ts → flow/RunStatusBadge.d.vue.ts} +2 -8
- package/dist/runtime/app/components/{FlowRunStatusBadge.vue → flow/RunStatusBadge.vue} +8 -1
- package/dist/runtime/app/components/{FlowRunStatusBadge.vue.d.ts → flow/RunStatusBadge.vue.d.ts} +2 -8
- package/dist/runtime/app/components/{FlowRunTimeline.vue → flow/RunTimeline.vue} +1 -1
- package/dist/runtime/app/components/{FlowStepSelector.d.vue.ts → flow/StepSelector.d.vue.ts} +1 -0
- package/dist/runtime/app/components/flow/StepSelector.vue +553 -0
- package/dist/runtime/app/components/{FlowStepSelector.vue.d.ts → flow/StepSelector.vue.d.ts} +1 -0
- package/dist/runtime/app/components/trigger/BasicInfoCard.d.vue.ts +33 -0
- package/dist/runtime/app/components/trigger/BasicInfoCard.vue +168 -0
- package/dist/runtime/app/components/trigger/BasicInfoCard.vue.d.ts +33 -0
- package/dist/runtime/app/components/{FlowSchedulesList.d.vue.ts → trigger/DangerZone.d.vue.ts} +4 -6
- package/dist/runtime/app/components/trigger/DangerZone.vue +46 -0
- package/dist/runtime/app/components/{FlowSchedulesList.vue.d.ts → trigger/DangerZone.vue.d.ts} +4 -6
- package/dist/runtime/app/components/trigger/EditHeader.d.vue.ts +15 -0
- package/dist/runtime/app/components/trigger/EditHeader.vue +55 -0
- package/dist/runtime/app/components/trigger/EditHeader.vue.d.ts +15 -0
- package/dist/runtime/app/components/trigger/EventConfig.d.vue.ts +24 -0
- package/dist/runtime/app/components/trigger/EventConfig.vue +68 -0
- package/dist/runtime/app/components/trigger/EventConfig.vue.d.ts +24 -0
- package/dist/runtime/app/components/trigger/FlowSubscriptions.d.vue.ts +14 -0
- package/dist/runtime/app/components/trigger/FlowSubscriptions.vue +128 -0
- package/dist/runtime/app/components/trigger/FlowSubscriptions.vue.d.ts +14 -0
- package/dist/runtime/app/components/trigger/ScheduleConfig.d.vue.ts +27 -0
- package/dist/runtime/app/components/trigger/ScheduleConfig.vue +375 -0
- package/dist/runtime/app/components/trigger/ScheduleConfig.vue.d.ts +27 -0
- package/dist/runtime/app/components/{FlowScheduleDialog.d.vue.ts → trigger/StatusConfig.d.vue.ts} +6 -6
- package/dist/runtime/app/components/trigger/StatusConfig.vue +78 -0
- package/dist/runtime/app/components/{FlowScheduleDialog.vue.d.ts → trigger/StatusConfig.vue.d.ts} +6 -6
- package/dist/runtime/app/components/trigger/WebhookConfig.d.vue.ts +30 -0
- package/dist/runtime/app/components/trigger/WebhookConfig.vue +97 -0
- package/dist/runtime/app/components/trigger/WebhookConfig.vue.d.ts +30 -0
- package/dist/runtime/app/composables/useAnalyzedFlows.d.ts +5 -0
- package/dist/runtime/app/composables/useAnalyzedFlows.js +15 -1
- package/dist/runtime/app/composables/useComponentRouter.d.ts +8 -0
- package/dist/runtime/app/composables/useComponentRouter.js +10 -2
- package/dist/runtime/app/composables/useFlowRunsInfinite.d.ts +1 -1
- package/dist/runtime/app/composables/useFlowState.js +65 -0
- package/dist/runtime/app/composables/useFlowWebSocket.d.ts +11 -2
- package/dist/runtime/app/composables/useFlowWebSocket.js +181 -65
- package/dist/runtime/app/composables/useQueueJobs.d.ts +12 -1
- package/dist/runtime/app/composables/useQueueJobs.js +13 -7
- package/dist/runtime/app/composables/useTrigger.d.ts +137 -0
- package/dist/runtime/app/composables/useTrigger.js +116 -0
- package/dist/runtime/app/composables/useTriggerWebSocket.d.ts +35 -0
- package/dist/runtime/app/composables/useTriggerWebSocket.js +333 -0
- package/dist/runtime/app/pages/dashboard.d.vue.ts +3 -0
- package/dist/runtime/app/pages/dashboard.vue +738 -0
- package/dist/runtime/app/pages/dashboard.vue.d.ts +3 -0
- package/dist/runtime/app/pages/flows/[name].d.vue.ts +3 -0
- package/dist/runtime/app/pages/flows/[name].vue +680 -0
- package/dist/runtime/app/pages/flows/[name].vue.d.ts +3 -0
- package/dist/runtime/app/pages/flows/index.vue +321 -620
- package/dist/runtime/app/pages/index.vue +39 -9
- package/dist/runtime/app/pages/queues/index.vue +202 -194
- package/dist/runtime/app/pages/queues/jobs.vue +534 -207
- package/dist/runtime/app/pages/settings/scheduler.d.vue.ts +3 -0
- package/dist/runtime/app/pages/settings/scheduler.vue +310 -0
- package/dist/runtime/app/pages/settings/scheduler.vue.d.ts +3 -0
- package/dist/runtime/app/pages/triggers/[name]/edit.d.vue.ts +3 -0
- package/dist/runtime/app/pages/triggers/[name]/edit.vue +429 -0
- package/dist/runtime/app/pages/triggers/[name]/edit.vue.d.ts +3 -0
- package/dist/runtime/app/pages/triggers/[name].d.vue.ts +3 -0
- package/dist/runtime/app/pages/triggers/[name].vue +898 -0
- package/dist/runtime/app/pages/triggers/[name].vue.d.ts +3 -0
- package/dist/runtime/app/pages/triggers/index.d.vue.ts +3 -0
- package/dist/runtime/app/pages/triggers/index.vue +528 -0
- package/dist/runtime/app/pages/triggers/index.vue.d.ts +3 -0
- package/dist/runtime/app/pages/triggers/new.d.vue.ts +3 -0
- package/dist/runtime/app/pages/triggers/new.vue +610 -0
- package/dist/runtime/app/pages/triggers/new.vue.d.ts +3 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.d.ts +10 -0
- package/dist/runtime/server/api/_flows/[name]/clear-history.delete.js +49 -0
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.d.ts +2 -0
- package/dist/runtime/server/api/_flows/[name]/runs/[runId]/cancel.post.js +21 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.d.ts +17 -0
- package/dist/runtime/server/api/_flows/[name]/runs.get.js +64 -0
- package/dist/runtime/server/api/_flows/[name]/start.post.d.ts +2 -0
- package/dist/runtime/server/api/_flows/[name]/start.post.js +9 -0
- package/dist/runtime/server/api/_flows/index.get.d.ts +7 -0
- package/dist/runtime/server/api/_flows/index.get.js +5 -0
- package/dist/runtime/server/api/_flows/recent-runs.get.d.ts +15 -0
- package/dist/runtime/server/api/_flows/recent-runs.get.js +67 -0
- package/dist/runtime/server/api/_flows/ws.d.ts +80 -0
- package/dist/runtime/server/api/_flows/ws.js +309 -0
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.d.ts +2 -0
- package/dist/runtime/server/api/_queues/[name]/job/[id].get.js +14 -0
- package/dist/runtime/server/api/_queues/[name]/job/index.get.d.ts +2 -0
- package/dist/runtime/server/api/_queues/[name]/job/index.get.js +39 -0
- package/dist/runtime/server/api/_queues/index.get.d.ts +2 -0
- package/dist/runtime/server/api/_queues/index.get.js +106 -0
- package/dist/runtime/server/api/_queues/ws.d.ts +48 -0
- package/dist/runtime/server/api/_queues/ws.js +215 -0
- package/dist/runtime/server/api/_scheduler/jobs.get.d.ts +19 -0
- package/dist/runtime/server/api/_scheduler/jobs.get.js +36 -0
- package/dist/runtime/server/api/_triggers/[name]/events.get.d.ts +6 -0
- package/dist/runtime/server/api/_triggers/[name]/events.get.js +43 -0
- package/dist/runtime/server/api/_triggers/[name]/index.get.d.ts +6 -0
- package/dist/runtime/server/api/_triggers/[name]/index.get.js +76 -0
- package/dist/runtime/server/api/_triggers/[name].delete.d.ts +7 -0
- package/dist/runtime/server/api/_triggers/[name].delete.js +37 -0
- package/dist/runtime/server/api/_triggers/[name].patch.d.ts +7 -0
- package/dist/runtime/server/api/_triggers/[name].patch.js +117 -0
- package/dist/runtime/server/api/_triggers/index.get.d.ts +6 -0
- package/dist/runtime/server/api/_triggers/index.get.js +44 -0
- package/dist/runtime/server/api/_triggers/index.post.d.ts +7 -0
- package/dist/runtime/server/api/_triggers/index.post.js +124 -0
- package/dist/runtime/server/api/_triggers/stats.get.d.ts +6 -0
- package/dist/runtime/server/api/_triggers/stats.get.js +41 -0
- package/dist/runtime/server/api/_triggers/ws.d.ts +74 -0
- package/dist/runtime/server/api/_triggers/ws.js +315 -0
- package/dist/runtime/server/tsconfig.json +7 -0
- package/package.json +8 -8
- package/dist/runtime/app/components/FlowScheduleDialog.vue +0 -226
- package/dist/runtime/app/components/FlowSchedulesList.vue +0 -99
- package/dist/runtime/app/components/FlowStepSelector.vue +0 -238
- package/dist/runtime/app/components/QueueConfigDetails.vue +0 -412
- package/dist/runtime/app/components/nhealth/component-shell.vue +0 -89
- /package/dist/runtime/app/components/{nhealth/component-router.vue → ComponentRouter.vue} +0 -0
- /package/dist/runtime/app/components/{FlowNodeCard.d.vue.ts → flow/NodeCard.d.vue.ts} +0 -0
- /package/dist/runtime/app/components/{FlowNodeCard.vue → flow/NodeCard.vue} +0 -0
- /package/dist/runtime/app/components/{FlowNodeCard.vue.d.ts → flow/NodeCard.vue.d.ts} +0 -0
- /package/dist/runtime/app/components/{FlowRunTimeline.d.vue.ts → flow/RunTimeline.d.vue.ts} +0 -0
- /package/dist/runtime/app/components/{FlowRunTimeline.vue.d.ts → flow/RunTimeline.vue.d.ts} +0 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ClientOnly>
|
|
3
|
+
<template #fallback>
|
|
4
|
+
<div class="h-full flex items-center justify-center">
|
|
5
|
+
<div class="text-center">
|
|
6
|
+
<UIcon
|
|
7
|
+
name="i-lucide-loader-2"
|
|
8
|
+
class="w-8 h-8 animate-spin mx-auto mb-3 text-gray-400"
|
|
9
|
+
/>
|
|
10
|
+
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
11
|
+
Loading...
|
|
12
|
+
</p>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
<div class="h-full flex flex-col overflow-hidden bg-gray-50 dark:bg-gray-950">
|
|
17
|
+
<!-- Header -->
|
|
18
|
+
<NventTriggerEditHeader
|
|
19
|
+
:is-saving="isSaving"
|
|
20
|
+
:has-changes="hasChanges"
|
|
21
|
+
@back="goBack"
|
|
22
|
+
@cancel="goBack"
|
|
23
|
+
@save="handleSave"
|
|
24
|
+
/>
|
|
25
|
+
|
|
26
|
+
<!-- Loading State -->
|
|
27
|
+
<div
|
|
28
|
+
v-if="status === 'pending' && !trigger"
|
|
29
|
+
class="flex-1 flex items-center justify-center"
|
|
30
|
+
>
|
|
31
|
+
<div class="text-center">
|
|
32
|
+
<UIcon
|
|
33
|
+
name="i-lucide-loader-2"
|
|
34
|
+
class="w-8 h-8 animate-spin mx-auto mb-3 text-gray-400"
|
|
35
|
+
/>
|
|
36
|
+
<p class="text-sm text-gray-500 dark:text-gray-400">
|
|
37
|
+
Loading trigger...
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
<!-- Error State -->
|
|
43
|
+
<div
|
|
44
|
+
v-else-if="!trigger"
|
|
45
|
+
class="flex-1 flex items-center justify-center"
|
|
46
|
+
>
|
|
47
|
+
<div class="text-center">
|
|
48
|
+
<UIcon
|
|
49
|
+
name="i-lucide-alert-circle"
|
|
50
|
+
class="w-12 h-12 mx-auto mb-3 text-red-400"
|
|
51
|
+
/>
|
|
52
|
+
<h2 class="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-1">
|
|
53
|
+
Trigger not found
|
|
54
|
+
</h2>
|
|
55
|
+
<p class="text-sm text-gray-500 dark:text-gray-400 mb-4">
|
|
56
|
+
The trigger you're looking for doesn't exist.
|
|
57
|
+
</p>
|
|
58
|
+
<UButton
|
|
59
|
+
color="neutral"
|
|
60
|
+
@click="goBack"
|
|
61
|
+
>
|
|
62
|
+
Go Back
|
|
63
|
+
</UButton>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<!-- Main Content -->
|
|
68
|
+
<div
|
|
69
|
+
v-else
|
|
70
|
+
class="flex-1 overflow-y-auto p-6"
|
|
71
|
+
>
|
|
72
|
+
<div class="max-w-4xl mx-auto">
|
|
73
|
+
<!-- Error Alert -->
|
|
74
|
+
<UAlert
|
|
75
|
+
v-if="saveError"
|
|
76
|
+
color="error"
|
|
77
|
+
variant="subtle"
|
|
78
|
+
:title="saveError"
|
|
79
|
+
:close-button="{ icon: 'i-lucide-x' }"
|
|
80
|
+
@close="saveError = null"
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
<!-- Success Alert -->
|
|
84
|
+
<UAlert
|
|
85
|
+
v-if="saveSuccess"
|
|
86
|
+
color="success"
|
|
87
|
+
variant="subtle"
|
|
88
|
+
title="Trigger updated successfully"
|
|
89
|
+
:close-button="{ icon: 'i-lucide-x' }"
|
|
90
|
+
@close="saveSuccess = false"
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
<!-- Main Form -->
|
|
94
|
+
<UForm
|
|
95
|
+
ref="form"
|
|
96
|
+
:schema="currentSchema"
|
|
97
|
+
:state="formState"
|
|
98
|
+
class="space-y-6"
|
|
99
|
+
@submit="onSubmit"
|
|
100
|
+
@error="onError"
|
|
101
|
+
>
|
|
102
|
+
<!-- Basic Information -->
|
|
103
|
+
<NventTriggerBasicInfoCard
|
|
104
|
+
v-model="formState"
|
|
105
|
+
is-edit
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
<!-- Status Control -->
|
|
109
|
+
<NventTriggerStatusConfig
|
|
110
|
+
v-model="formState.status"
|
|
111
|
+
nested
|
|
112
|
+
/>
|
|
113
|
+
|
|
114
|
+
<!-- Type-Specific Configuration -->
|
|
115
|
+
<NventTriggerWebhookConfig
|
|
116
|
+
v-if="formState.type === 'webhook'"
|
|
117
|
+
v-model="formState.webhook"
|
|
118
|
+
name="webhook"
|
|
119
|
+
/>
|
|
120
|
+
|
|
121
|
+
<NventTriggerScheduleConfig
|
|
122
|
+
v-if="formState.type === 'schedule'"
|
|
123
|
+
v-model="formState.schedule"
|
|
124
|
+
name="schedule"
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<NventTriggerEventConfig
|
|
128
|
+
v-if="formState.type === 'event'"
|
|
129
|
+
v-model="formState.config"
|
|
130
|
+
name="config"
|
|
131
|
+
/>
|
|
132
|
+
|
|
133
|
+
<!-- Flow Subscriptions -->
|
|
134
|
+
<NventTriggerFlowSubscriptions
|
|
135
|
+
:subscriptions="formState.subscriptions"
|
|
136
|
+
:flows="flows"
|
|
137
|
+
@toggle="toggleFlowSubscription"
|
|
138
|
+
/>
|
|
139
|
+
</UForm>
|
|
140
|
+
|
|
141
|
+
<!-- Danger Zone -->
|
|
142
|
+
<NventTriggerDangerZone
|
|
143
|
+
class="mt-6"
|
|
144
|
+
:is-deleting="isDeleting"
|
|
145
|
+
@delete="handleDelete"
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
|
|
151
|
+
<!-- Delete Confirmation Dialog -->
|
|
152
|
+
<ConfirmDialog
|
|
153
|
+
v-model:open="showDeleteDialog"
|
|
154
|
+
title="Delete Trigger"
|
|
155
|
+
:description="`Are you sure you want to delete the trigger '${trigger?.displayName || trigger?.name}'?`"
|
|
156
|
+
:items="[
|
|
157
|
+
'All subscriptions will be removed',
|
|
158
|
+
'Event history will be preserved',
|
|
159
|
+
'This action cannot be undone'
|
|
160
|
+
]"
|
|
161
|
+
warning="This is a permanent action."
|
|
162
|
+
confirm-label="Delete Trigger"
|
|
163
|
+
confirm-color="error"
|
|
164
|
+
icon="i-lucide-alert-triangle"
|
|
165
|
+
icon-color="error"
|
|
166
|
+
:loading="isDeleting"
|
|
167
|
+
@confirm="confirmDelete"
|
|
168
|
+
@cancel="showDeleteDialog = false"
|
|
169
|
+
/>
|
|
170
|
+
</ClientOnly>
|
|
171
|
+
</template>
|
|
172
|
+
|
|
173
|
+
<script setup>
|
|
174
|
+
import { ref, computed, watch, useToast } from "#imports";
|
|
175
|
+
import { useTrigger } from "../../../composables/useTrigger";
|
|
176
|
+
import { useAnalyzedFlows } from "../../../composables/useAnalyzedFlows";
|
|
177
|
+
import { useComponentRouter } from "../../../composables/useComponentRouter";
|
|
178
|
+
import ConfirmDialog from "../../../components/ConfirmDialog.vue";
|
|
179
|
+
import { z } from "zod";
|
|
180
|
+
const router = useComponentRouter();
|
|
181
|
+
const toast = useToast();
|
|
182
|
+
const route = computed(() => {
|
|
183
|
+
if (!router.route?.value?.path) return null;
|
|
184
|
+
const path = router.route.value.path;
|
|
185
|
+
const match = path.match(/\/triggers\/([^/]+)\/edit/);
|
|
186
|
+
return match && match[1] ? decodeURIComponent(match[1]) : null;
|
|
187
|
+
});
|
|
188
|
+
const triggerName = computed(() => route.value);
|
|
189
|
+
const { trigger, status, refresh } = useTrigger(triggerName);
|
|
190
|
+
const flows = useAnalyzedFlows();
|
|
191
|
+
const baseSchema = z.object({
|
|
192
|
+
name: z.string().min(1, "Name is required"),
|
|
193
|
+
displayName: z.string().min(1, "Display name is required"),
|
|
194
|
+
description: z.string(),
|
|
195
|
+
type: z.enum(["event", "webhook", "schedule", "manual"]),
|
|
196
|
+
scope: z.enum(["flow", "run"]),
|
|
197
|
+
subscriptions: z.array(z.string())
|
|
198
|
+
});
|
|
199
|
+
const webhookSchema = baseSchema.extend({
|
|
200
|
+
webhook: z.object({
|
|
201
|
+
path: z.string().min(1, "Webhook path is required"),
|
|
202
|
+
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]),
|
|
203
|
+
requireAuth: z.boolean(),
|
|
204
|
+
authHeader: z.string().min(1, "Auth header is required").optional()
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
const scheduleSchema = baseSchema.extend({
|
|
208
|
+
schedule: z.object({
|
|
209
|
+
cron: z.string().optional(),
|
|
210
|
+
interval: z.number().min(1, "Interval must be at least 1 second").optional(),
|
|
211
|
+
timezone: z.string().min(1, "Timezone is required"),
|
|
212
|
+
enabled: z.boolean()
|
|
213
|
+
}).refine(
|
|
214
|
+
(data) => data.cron || data.interval,
|
|
215
|
+
{ message: "Either cron expression or interval is required", path: ["cron"] }
|
|
216
|
+
)
|
|
217
|
+
});
|
|
218
|
+
const eventSchema = baseSchema.extend({
|
|
219
|
+
config: z.object({
|
|
220
|
+
event: z.string().min(1, "Event name is required"),
|
|
221
|
+
filter: z.string().optional()
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
const manualSchema = baseSchema;
|
|
225
|
+
const currentSchema = computed(() => {
|
|
226
|
+
switch (formState.value.type) {
|
|
227
|
+
case "webhook":
|
|
228
|
+
return webhookSchema;
|
|
229
|
+
case "schedule":
|
|
230
|
+
return scheduleSchema;
|
|
231
|
+
case "event":
|
|
232
|
+
return eventSchema;
|
|
233
|
+
default:
|
|
234
|
+
return manualSchema;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
const formState = ref({
|
|
238
|
+
name: "",
|
|
239
|
+
displayName: "",
|
|
240
|
+
description: "",
|
|
241
|
+
type: "event",
|
|
242
|
+
scope: "flow",
|
|
243
|
+
status: "active",
|
|
244
|
+
webhook: {
|
|
245
|
+
path: "",
|
|
246
|
+
method: "POST",
|
|
247
|
+
requireAuth: false,
|
|
248
|
+
authHeader: "X-API-Key"
|
|
249
|
+
},
|
|
250
|
+
schedule: {
|
|
251
|
+
cron: "",
|
|
252
|
+
interval: void 0,
|
|
253
|
+
timezone: "UTC",
|
|
254
|
+
enabled: true
|
|
255
|
+
},
|
|
256
|
+
config: {
|
|
257
|
+
event: "",
|
|
258
|
+
filter: ""
|
|
259
|
+
},
|
|
260
|
+
subscriptions: []
|
|
261
|
+
});
|
|
262
|
+
const form = ref();
|
|
263
|
+
const isSaving = ref(false);
|
|
264
|
+
watch(trigger, (newTrigger) => {
|
|
265
|
+
if (newTrigger && !isSaving.value) {
|
|
266
|
+
formState.value.name = newTrigger.name;
|
|
267
|
+
formState.value.displayName = newTrigger.displayName || newTrigger.name;
|
|
268
|
+
formState.value.description = newTrigger.description || "";
|
|
269
|
+
formState.value.type = newTrigger.type;
|
|
270
|
+
formState.value.scope = newTrigger.scope;
|
|
271
|
+
formState.value.status = newTrigger.status || "active";
|
|
272
|
+
if (newTrigger.webhook) {
|
|
273
|
+
formState.value.webhook = {
|
|
274
|
+
path: newTrigger.webhook.path || "",
|
|
275
|
+
method: newTrigger.webhook.method || "POST",
|
|
276
|
+
requireAuth: !!newTrigger.webhook.auth,
|
|
277
|
+
authHeader: newTrigger.webhook.auth?.header || "X-API-Key"
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
if (newTrigger.schedule) {
|
|
281
|
+
formState.value.schedule = {
|
|
282
|
+
cron: newTrigger.schedule.cron || "",
|
|
283
|
+
interval: newTrigger.schedule.interval,
|
|
284
|
+
timezone: newTrigger.schedule.timezone || "UTC",
|
|
285
|
+
enabled: newTrigger.schedule.enabled ?? true
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (newTrigger.config) {
|
|
289
|
+
formState.value.config = {
|
|
290
|
+
event: newTrigger.config.event || "",
|
|
291
|
+
filter: newTrigger.config.filter ? JSON.stringify(newTrigger.config.filter, null, 2) : ""
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
formState.value.subscriptions = Array.from(new Set(newTrigger.subscribedFlows || []));
|
|
295
|
+
}
|
|
296
|
+
}, { immediate: true });
|
|
297
|
+
const toggleFlowSubscription = (flowName) => {
|
|
298
|
+
const index = formState.value.subscriptions.indexOf(flowName);
|
|
299
|
+
if (index === -1) {
|
|
300
|
+
formState.value.subscriptions.push(flowName);
|
|
301
|
+
} else {
|
|
302
|
+
formState.value.subscriptions.splice(index, 1);
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const manualDirty = ref(false);
|
|
306
|
+
watch(() => formState.value.subscriptions, () => {
|
|
307
|
+
manualDirty.value = true;
|
|
308
|
+
}, { deep: true });
|
|
309
|
+
const hasChanges = computed(() => {
|
|
310
|
+
if (form.value?.dirty || manualDirty.value) return true;
|
|
311
|
+
if (!trigger.value) return false;
|
|
312
|
+
return formState.value.displayName !== (trigger.value.displayName || trigger.value.name) || formState.value.description !== (trigger.value.description || "") || formState.value.status !== (trigger.value.status || "active") || JSON.stringify([...formState.value.subscriptions].sort()) !== JSON.stringify([...trigger.value.subscribedFlows || []].sort()) || trigger.value.type === "webhook" && (formState.value.webhook.path !== (trigger.value.webhook?.path || "") || formState.value.webhook.method !== (trigger.value.webhook?.method || "POST")) || trigger.value.type === "schedule" && (formState.value.schedule.cron !== (trigger.value.schedule?.cron || "") || formState.value.schedule.interval !== trigger.value.schedule?.interval || formState.value.schedule.timezone !== (trigger.value.schedule?.timezone || "UTC") || formState.value.schedule.enabled !== (trigger.value.schedule?.enabled ?? true)) || trigger.value.type === "event" && (formState.value.config.event !== (trigger.value.config?.event || "") || formState.value.config.filter !== (trigger.value.config?.filter ? JSON.stringify(trigger.value.config.filter, null, 2) : ""));
|
|
313
|
+
});
|
|
314
|
+
const saveError = ref(null);
|
|
315
|
+
const saveSuccess = ref(false);
|
|
316
|
+
const onSubmit = async (event) => {
|
|
317
|
+
if (!trigger.value) return;
|
|
318
|
+
isSaving.value = true;
|
|
319
|
+
saveError.value = null;
|
|
320
|
+
saveSuccess.value = false;
|
|
321
|
+
try {
|
|
322
|
+
const data = event.data;
|
|
323
|
+
const payload = {
|
|
324
|
+
displayName: data.displayName,
|
|
325
|
+
description: data.description,
|
|
326
|
+
status: formState.value.status,
|
|
327
|
+
subscriptions: formState.value.subscriptions
|
|
328
|
+
// Use formState directly for subscriptions
|
|
329
|
+
};
|
|
330
|
+
if (formState.value.type === "webhook") {
|
|
331
|
+
payload.config = {
|
|
332
|
+
path: formState.value.webhook.path,
|
|
333
|
+
method: formState.value.webhook.method,
|
|
334
|
+
requireAuth: formState.value.webhook.requireAuth,
|
|
335
|
+
authHeader: formState.value.webhook.authHeader
|
|
336
|
+
};
|
|
337
|
+
} else if (formState.value.type === "schedule") {
|
|
338
|
+
payload.config = {
|
|
339
|
+
cron: formState.value.schedule.cron || void 0,
|
|
340
|
+
interval: formState.value.schedule.interval,
|
|
341
|
+
timezone: formState.value.schedule.timezone,
|
|
342
|
+
enabled: formState.value.schedule.enabled
|
|
343
|
+
};
|
|
344
|
+
} else if (formState.value.type === "event") {
|
|
345
|
+
payload.config = {
|
|
346
|
+
event: formState.value.config.event,
|
|
347
|
+
filter: formState.value.config.filter || void 0
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
const response = await $fetch(`/api/_triggers/${encodeURIComponent(trigger.value.name)}`, {
|
|
351
|
+
method: "PATCH",
|
|
352
|
+
body: payload
|
|
353
|
+
});
|
|
354
|
+
if (response.error) {
|
|
355
|
+
saveError.value = response.error;
|
|
356
|
+
toast.add({ title: "Error", description: response.error, color: "error" });
|
|
357
|
+
} else {
|
|
358
|
+
saveSuccess.value = true;
|
|
359
|
+
toast.add({ title: "Success", description: "Trigger updated successfully", color: "success" });
|
|
360
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
361
|
+
isSaving.value = false;
|
|
362
|
+
await refresh();
|
|
363
|
+
manualDirty.value = false;
|
|
364
|
+
if (form.value) {
|
|
365
|
+
form.value.clear();
|
|
366
|
+
}
|
|
367
|
+
setTimeout(() => {
|
|
368
|
+
saveSuccess.value = false;
|
|
369
|
+
}, 3e3);
|
|
370
|
+
}
|
|
371
|
+
} catch (err) {
|
|
372
|
+
const message = err instanceof Error ? err.message : "Failed to update trigger";
|
|
373
|
+
saveError.value = message;
|
|
374
|
+
toast.add({ title: "Error", description: message, color: "error" });
|
|
375
|
+
isSaving.value = false;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
const onError = (event) => {
|
|
379
|
+
if (event?.errors?.[0]) {
|
|
380
|
+
const error = event.errors[0];
|
|
381
|
+
toast.add({
|
|
382
|
+
title: "Validation Error",
|
|
383
|
+
description: error.message || "Please check your form inputs",
|
|
384
|
+
color: "error"
|
|
385
|
+
});
|
|
386
|
+
if (error.id) {
|
|
387
|
+
const element = document.getElementById(error.id);
|
|
388
|
+
element?.focus();
|
|
389
|
+
element?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
const handleSave = () => {
|
|
394
|
+
form.value?.submit();
|
|
395
|
+
};
|
|
396
|
+
const isDeleting = ref(false);
|
|
397
|
+
const showDeleteDialog = ref(false);
|
|
398
|
+
const handleDelete = () => {
|
|
399
|
+
showDeleteDialog.value = true;
|
|
400
|
+
};
|
|
401
|
+
const confirmDelete = async () => {
|
|
402
|
+
if (!trigger.value) return;
|
|
403
|
+
isDeleting.value = true;
|
|
404
|
+
saveError.value = null;
|
|
405
|
+
try {
|
|
406
|
+
const response = await $fetch(`/api/_triggers/${encodeURIComponent(trigger.value.name)}`, {
|
|
407
|
+
method: "DELETE"
|
|
408
|
+
});
|
|
409
|
+
if (response.error) {
|
|
410
|
+
saveError.value = response.error;
|
|
411
|
+
showDeleteDialog.value = false;
|
|
412
|
+
} else {
|
|
413
|
+
toast.add({ title: "Success", description: "Trigger deleted successfully", color: "success" });
|
|
414
|
+
showDeleteDialog.value = false;
|
|
415
|
+
setTimeout(() => {
|
|
416
|
+
router.push("/triggers");
|
|
417
|
+
}, 500);
|
|
418
|
+
}
|
|
419
|
+
} catch (err) {
|
|
420
|
+
saveError.value = err instanceof Error ? err.message : "Failed to delete trigger";
|
|
421
|
+
showDeleteDialog.value = false;
|
|
422
|
+
} finally {
|
|
423
|
+
isDeleting.value = false;
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
const goBack = () => {
|
|
427
|
+
router.push(`/triggers/${encodeURIComponent(trigger.value?.name || "")}`);
|
|
428
|
+
};
|
|
429
|
+
</script>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|