service-config.interface.ts 524 B

123456789101112131415161718192021
  1. export interface ServiceConfig {
  2. id: number;
  3. type: 'http';
  4. serverId?: number;
  5. title: string;
  6. params: Array<{
  7. type: ParamType;
  8. key: string;
  9. value: string | string[] | number;
  10. }>;
  11. }
  12. export const ParamTypes = ['text', 'number', 'check'] as const;
  13. export type ParamType = typeof ParamTypes[number];
  14. export function validateParamType(input: string): ParamType {
  15. const found = ParamTypes.find(k => k === input);
  16. if (!found) throw new Error(`'${input}' is not a valid param type`);
  17. return found;
  18. }