index.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import z from 'zod';
  6. import { ValidationResult } from '@runtime/index';
  7. import { FlowGramAPIDefine } from '@api/type';
  8. import { FlowGramAPIMethod, FlowGramAPIModule, FlowGramAPIName } from '@api/constant';
  9. export interface ValidationReq {
  10. schema: string;
  11. }
  12. export interface ValidationRes extends ValidationResult {}
  13. export const ValidationDefine: FlowGramAPIDefine = {
  14. name: FlowGramAPIName.Validation,
  15. method: FlowGramAPIMethod.POST,
  16. path: '/validation',
  17. module: FlowGramAPIModule.Validation,
  18. schema: {
  19. input: z.object({
  20. schema: z.string(),
  21. }),
  22. output: z.object({
  23. valid: z.boolean(),
  24. nodeErrors: z.array(
  25. z.object({
  26. message: z.string(),
  27. nodeID: z.string(),
  28. })
  29. ),
  30. edgeErrors: z.array(
  31. z.object({
  32. message: z.string(),
  33. edge: z.object({
  34. sourceNodeID: z.string(),
  35. targetNodeID: z.string(),
  36. sourcePortID: z.string().optional(),
  37. targetPortID: z.string().optional(),
  38. }),
  39. })
  40. ),
  41. }),
  42. },
  43. };