index.ts 1.1 KB

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