瀏覽代碼

feat: 新增触发节点及循环结束节点

jiaxing.liao 1 周之前
父節點
當前提交
0432243974

+ 1 - 1
.gitignore

@@ -9,7 +9,7 @@ node_modules
 .idea/workspace.xml
 
 # Local env files
-.env
+# .env
 .env.local
 .env.development.local
 .env.test.local

+ 1 - 0
apps/web/.env

@@ -0,0 +1 @@
+VITE_BASE_URL=shalu-componenttesting-admin-dev.shalu.com

+ 7 - 1
apps/web/src/nodes/src/index.ts

@@ -14,6 +14,9 @@ import { codeNode } from './code'
 import { iterationNode } from './iteration'
 import { loopNode } from './loop'
 import { listNode } from './list'
+import { loopEndNode } from './loop-end'
+import { triggerScheduleNode } from './schedule'
+import { webhookNode } from './webhook'
 import type { INodeType } from '../Interface'
 
 const loopStartNode = {
@@ -53,7 +56,10 @@ const nodes = [
 	loopNode,
 	listNode,
 	loopStartNode,
-	iterationStartNode
+	iterationStartNode,
+	loopEndNode,
+	triggerScheduleNode,
+	webhookNode
 ]
 
 const nodeMap = nodes.reduce(

+ 32 - 0
apps/web/src/nodes/src/loop-end/index.ts

@@ -0,0 +1,32 @@
+import { NodeConnectionTypes, type INodeType, type INodeDataBaseSchema } from '../../Interface'
+import Setter from './setter.vue'
+
+export type EndData = INodeDataBaseSchema
+
+export const loopEndNode: INodeType = {
+	version: ['1'],
+	displayName: '退出循环',
+	name: 'loop-end',
+	Setter,
+	description: '用于退出迭代或者循环',
+	group: '业务逻辑',
+	icon: 'lucide:rotate-ccw',
+	iconColor: '#f79009',
+	inputs: [NodeConnectionTypes.main],
+	outputs: [],
+	// 业务数据
+	schema: {
+		appAgentId: '',
+		parentId: '',
+		position: {
+			x: 20,
+			y: 30
+		},
+		width: 96,
+		height: 96,
+		selected: false,
+		nodeType: 'loop-end',
+		zIndex: 1,
+		data: {}
+	}
+}

+ 29 - 0
apps/web/src/nodes/src/loop-end/setter.vue

@@ -0,0 +1,29 @@
+<script setup lang="ts">
+import { ref, watch } from 'vue'
+import OutputVariables from '@/nodes/_base/OutputVariables.vue'
+
+import type { EndData } from './index'
+
+const props = defineProps<{
+	data: EndData
+}>()
+
+const emit = defineEmits<{
+	(e: 'update', data: EndData): void
+}>()
+
+const formData = ref<EndData>(props.data)
+
+watch(
+	() => formData.value,
+	(newVal) => {
+		emit('update', newVal)
+	}
+)
+</script>
+
+<template>
+	<el-scrollbar class="box-border p-12px">
+		<OutputVariables v-model="formData.outputs" :set-type="false" :set-value="true" />
+	</el-scrollbar>
+</template>

+ 40 - 0
apps/web/src/nodes/src/schedule/index.ts

@@ -0,0 +1,40 @@
+import { NodeConnectionTypes, type INodeType, type INodeDataBaseSchema } from '../../Interface'
+
+export type ScheduleData = INodeDataBaseSchema & {
+	frequency: 'daily' // 频率,hourly/daily/weekly/monthly  mode仅限visual使用
+	mode: 'visual' // 调度模式 cron/visual,
+	cron_expression: '' // cron表达式
+	visual_config: {
+		minute: string // 时分值 仅限frequency为daily使用
+		time: string // 仅限frequency为daily使用
+		weekdays: ('sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat')[] // 每周几列表 仅限frequency为weekly使用
+		monthly_days: (number | 'last')[] // 每月日列表 last: 最后一天,仅限frequency为monthly使用
+	}
+}
+
+export const triggerScheduleNode: INodeType = {
+	version: ['1'],
+	displayName: '定时触发',
+	name: 'trigger-schedule',
+	description: '基于时间的触发节点',
+	group: '开始',
+	icon: 'lucide:clock',
+	iconColor: '#875bf7',
+	inputs: [],
+	outputs: [NodeConnectionTypes.main],
+	// 业务数据
+	schema: {
+		appAgentId: '',
+		parentId: '',
+		position: {
+			x: 20,
+			y: 30
+		},
+		width: 96,
+		height: 96,
+		selected: false,
+		nodeType: 'trigger-schedule',
+		zIndex: 1,
+		data: {}
+	}
+}

+ 3 - 3
apps/web/src/nodes/src/start/index.ts

@@ -2,10 +2,10 @@ import { NodeConnectionTypes, type INodeType } from '../../Interface'
 
 export const startNode: INodeType = {
 	version: ['1'],
-	displayName: '开始',
+	displayName: '用户输入',
 	name: 'start',
-	description: '流程开始节点',
-	group: '业务逻辑',
+	description: '用户输入节点,用于接收用户输入',
+	group: '开始',
 	icon: 'lucide:play',
 	iconColor: '#296dff',
 	inputs: [],

+ 109 - 0
apps/web/src/nodes/src/webhook/index.ts

@@ -0,0 +1,109 @@
+import { NodeConnectionTypes, type INodeType, type INodeDataBaseSchema } from '../../Interface'
+
+export type WebhookData = INodeDataBaseSchema & {
+	/**
+	 * 异步模式
+	 */
+	async_mode: boolean
+
+	/**
+	 * webhook地址,系统自动获取
+	 */
+	webhook_url: string
+
+	/**
+	 * webhook的调试地址,系统自动获取
+	 */
+	webhook_debug_url: string
+
+	/**
+	 * 内容类型
+	 * 可选值: application/json, application/x-www-form-urlencoded, text/plain, multipart/form-data
+	 */
+	content_type:
+		| 'application/json'
+		| 'application/x-www-form-urlencoded'
+		| 'text/plain'
+		| 'multipart/form-data'
+
+	/**
+	 * 请求头配置
+	 */
+	headers: Array<{
+		name: string
+		required: boolean
+	}>
+
+	/**
+	 * URL参数配置
+	 */
+	params: Array<{
+		name: string
+		type: 'string' | 'number' | 'boolean'
+		required: boolean
+	}>
+
+	/**
+	 * body参数配置
+	 */
+	body: Array<{
+		name: string
+		type:
+			| 'string'
+			| 'number'
+			| 'boolean'
+			| 'object'
+			| 'array[string]'
+			| 'array[number]'
+			| 'array[boolean]'
+			| 'array[object]'
+		required: boolean
+	}>
+
+	/**
+	 * 响应内容类型
+	 * 可选值: application/json, application/x-www-form-urlencoded, text/plain, multipart/form-data
+	 */
+	response_content_type:
+		| 'application/json'
+		| 'application/x-www-form-urlencoded'
+		| 'text/plain'
+		| 'multipart/form-data'
+
+	/**
+	 * 响应内容
+	 */
+	response_body: string
+
+	/**
+	 * 响应码
+	 */
+	response_status_code: number
+}
+
+export const webhookNode: INodeType = {
+	version: ['1'],
+	displayName: 'Webhook触发',
+	name: 'trigger-webhook',
+	description: '可用于第三方系统http推送请求触发',
+	group: '开始',
+	icon: 'lucide:webhook',
+	iconColor: '#2e90fa',
+	inputs: [],
+	outputs: [NodeConnectionTypes.main],
+	// 业务数据
+	schema: {
+		appAgentId: '',
+		parentId: '',
+		position: {
+			x: 20,
+			y: 30
+		},
+		width: 96,
+		height: 96,
+		selected: false,
+		nodeType: 'trigger-webhook',
+		zIndex: 1,
+		data: {}
+	}
+}