GitFOSS
.ts
TypeScript
(application/typescript)
// 3rd-party
import type { FastifySchema } from "fastify";
// generated via script[generate:prisma]
import type { ResourceVisibility } from "@prisma/client";
// app
import type { AppThemeScheme } from "./types";
// app islands DTO's
import { PullRequestFormState } from "./islands/RepositoryPullRequestCreateForm";

export enum AppRoute {
  HOME = "home",
  SSH_AUTH = "ssh.auth_helper",
  THEME_SET_SCHEME_ACTION = "theme.set_scheme.action",
  AUTH_REGISTER = "auth.register",
  AUTH_REGISTER_ACTION = "auth.register.action",
  AUTH_LOGIN = "auth.login",
  AUTH_LOGIN_ACTION = "auth.login.action",
  AUTH_LOGOUT_ACTION = "auth.logout.action",
  ORGANIZATION_DETAILS = "organization.details",
  REPOSITORY_COUNTERS_API = "repository.counters.api",
  REPOSITORY_BROWSER = "repository.browser",
  REPOSITORY_BROWSER_WITH_PATH = "repository.browser.with_path",
  REPOSITORY_COMMITS_LOG = "repository.commits_log",
  REPOSITORY_COMPARE = "repository.compare",
  REPOSITORY_CREATE = "repository.create",
  REPOSITORY_CREATE_ACTION = "repository.create.action",
  REPOSITORY_DETAILS = "repository.details",
  REPOSITORY_DETAILS_WITH_TRAILING_SLASH = "repository.details.with_trailing_slash",
  REPOSITORY_EXPLORE = "repository.explore",
  REPOSITORY_SHOW_OBJECT = "repository.show_object",
  REPOSITORY_FORK = "repository.fork",
  REPOSITORY_FORK_ACTION = "repository.fork.action",
  REPOSITORY_PULL_REQUESTS = "repository.pull_requests",
  REPOSITORY_PULL_REQUEST_CLOSE_ACTION = "repository.pull_request.close.action",
  REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION = "repository.pull_request.comment.create.action",
  REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION = "repository.pull_request.comment.delete.action",
  REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION = "repository.pull_request.comment.update.action",
  REPOSITORY_PULL_REQUEST_CREATE = "repository.pull_request.create",
  REPOSITORY_PULL_REQUEST_CREATE_ACTION = "repository.pull_request.create.action",
  REPOSITORY_PULL_REQUEST_DELETE_ACTION = "repository.pull_request.delete.action",
  REPOSITORY_PULL_REQUEST_DETAILS = "repository.pull_request.details",
  REPOSITORY_PULL_REQUEST_MERGE_ACTION = "repository.pull_request.merge.action",
  REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION = "repository.pull_request.delete_source_branch.action",
  REPOSITORY_PULL_REQUEST_UPDATE_ACTION = "repository.pull_request.update.action",
  REPOSITORY_PIPELINES = "repository.pipelines",
  REPOSITORY_PIPELINE_DETAILS = "repository.pipeline_details",
  REPOSITORY_PIPELINE_STAGES = "repository.pipeline.stages",
  REPOSITORY_PIPELINE_STAGE_DETAILS = "repository.pipeline.stages.details",
  REPOSITORY_PIPELINE_ARTEFACTS = "repository.pipeline.artefacts",
  REPOSITORY_PIPELINE_TRIGGER_ACTION = "repository.pipeline.trigger.action",
  SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION = "syntax_highlight.highlight_code.action",
  SETTINGS = "settings.home",
  SETTINGS_KEYS = "settings.keys.list",
  SETTINGS_KEY_ADD = "settings.keys.add",
  SETTINGS_KEY_ADD_ACTION = "settings.keys.add.action",
  SETTINGS_KEY_UPDATE = "settings.keys.update",
  SETTINGS_KEY_UPDATE_ACTION = "settings.keys.update.action",
  USER_DASHBOARD = "user.dashboard",
  USER_DETAILS = "user.details",
}

export const AppRoutePaths: Record<AppRoute, string> = {
  [AppRoute.HOME]: "/",
  [AppRoute.SSH_AUTH]: "/_ssh/auth",
  [AppRoute.THEME_SET_SCHEME_ACTION]: "/theme/:themeScheme",
  [AppRoute.AUTH_REGISTER]: "/auth/register",
  [AppRoute.AUTH_REGISTER_ACTION]: "/auth/register",
  [AppRoute.AUTH_LOGIN]: "/auth/login",
  [AppRoute.AUTH_LOGIN_ACTION]: "/auth/login",
  [AppRoute.AUTH_LOGOUT_ACTION]: "/auth/logout",
  [AppRoute.ORGANIZATION_DETAILS]: "/:orgSlug",
  [AppRoute.REPOSITORY_COUNTERS_API]: "/api/repos/:orgSlug/:repoSlug/counters",
  [AppRoute.REPOSITORY_BROWSER]: "/:orgSlug/:repoSlug/:currentRef/tree",
  [AppRoute.REPOSITORY_BROWSER_WITH_PATH]:
    "/:orgSlug/:repoSlug/:currentRef/tree/*",
  [AppRoute.REPOSITORY_COMMITS_LOG]: "/:orgSlug/:repoSlug/:currentRef/commits",
  [AppRoute.REPOSITORY_COMPARE]: "/:orgSlug/:repoSlug/compare/:refA..:refB",
  [AppRoute.REPOSITORY_CREATE]: "/repo/new",
  [AppRoute.REPOSITORY_CREATE_ACTION]: "/repo/new",
  [AppRoute.REPOSITORY_DETAILS]: "/:orgSlug/:repoSlug",
  [AppRoute.REPOSITORY_DETAILS_WITH_TRAILING_SLASH]: "/:orgSlug/:repoSlug/",
  [AppRoute.REPOSITORY_EXPLORE]: "/repo/explore",
  [AppRoute.REPOSITORY_SHOW_OBJECT]: "/:orgSlug/:repoSlug/show/:objectId",
  [AppRoute.REPOSITORY_FORK]: "/:orgSlug/:repoSlug/fork",
  [AppRoute.REPOSITORY_FORK_ACTION]: "/:orgSlug/:repoSlug/fork",
  [AppRoute.REPOSITORY_PULL_REQUESTS]: "/:orgSlug/:repoSlug/pulls",
  [AppRoute.REPOSITORY_PULL_REQUEST_CLOSE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/close",
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/comment",
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/comment/delete",
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/comment/edit",
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE]: "/:orgSlug/:repoSlug/pulls/new",
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/new",
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/delete",
  [AppRoute.REPOSITORY_PULL_REQUEST_DETAILS]:
    "/:orgSlug/:repoSlug/pulls/:pullUid",
  [AppRoute.REPOSITORY_PULL_REQUEST_MERGE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/merge",
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/delete-source-branch",
  [AppRoute.REPOSITORY_PULL_REQUEST_UPDATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/edit",
  [AppRoute.REPOSITORY_PIPELINES]: "/:orgSlug/:repoSlug/pipelines",
  [AppRoute.REPOSITORY_PIPELINE_DETAILS]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId",
  [AppRoute.REPOSITORY_PIPELINE_STAGES]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/stages",
  [AppRoute.REPOSITORY_PIPELINE_STAGE_DETAILS]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/stages/:stageId",
  [AppRoute.REPOSITORY_PIPELINE_ARTEFACTS]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/artefacts",
  [AppRoute.REPOSITORY_PIPELINE_TRIGGER_ACTION]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/trigger",
  [AppRoute.SETTINGS]: "/@:username/settings",
  [AppRoute.SETTINGS_KEYS]: "/@:username/settings/keys",
  [AppRoute.SETTINGS_KEY_ADD]: "/@:username/settings/keys/add",
  [AppRoute.SETTINGS_KEY_ADD_ACTION]: "/@:username/settings/keys/add",
  [AppRoute.SETTINGS_KEY_UPDATE]: "/@:username/settings/keys/:keyId/edit",
  [AppRoute.SETTINGS_KEY_UPDATE_ACTION]:
    "/@:username/settings/keys/:keyId/edit",
  [AppRoute.SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION]:
    "/api/syntax/highlight/:outputFormat",
  [AppRoute.USER_DASHBOARD]: "/dashboard",
  [AppRoute.USER_DETAILS]: "/@:username",
};

export interface AppRouteParams {
  [x: string]: any;
  [AppRoute.HOME]: undefined;
  [AppRoute.SSH_AUTH]: {
    body: {
      // git-receive-pack: push, git-upload-pack: clone, pull, fetch
      command: "git-receive-pack" | "git-upload-pack";
      repoSlug: string;
      username: string;
      publicKey: string;
    };
  };
  [AppRoute.REPOSITORY_COUNTERS_API]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.THEME_SET_SCHEME_ACTION]: {
    params: {
      themeScheme: AppThemeScheme;
    };
  };
  [AppRoute.AUTH_REGISTER]: undefined;
  [AppRoute.AUTH_REGISTER_ACTION]: {
    body: {
      email_address: string;
      username: string;
      password: string;
    };
  };
  [AppRoute.AUTH_LOGIN]: {
    querystring: {
      after_login_goto?: string;
    };
  };
  [AppRoute.AUTH_LOGIN_ACTION]: {
    body: {
      email_address: string;
      password: string;
    };
  };
  [AppRoute.AUTH_LOGOUT_ACTION]: undefined;
  [AppRoute.ORGANIZATION_DETAILS]: {
    params: {
      orgSlug: string;
    };
  };
  [AppRoute.REPOSITORY_BROWSER]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      currentRef: string;
      "*": string;
    };
  };
  [AppRoute.REPOSITORY_BROWSER_WITH_PATH]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      currentRef: string;
      "*": string;
    };
  };
  [AppRoute.REPOSITORY_COMMITS_LOG]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      currentRef: string;
    };
  };
  [AppRoute.REPOSITORY_COMPARE]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      refA: string;
      refB: string;
    };
  };
  [AppRoute.REPOSITORY_CREATE]: undefined;
  [AppRoute.REPOSITORY_CREATE_ACTION]: {
    body: {
      parent_org_slug: string;
      repo_display_name: string;
      repo_init_license_file: "on" | "off";
      repo_init_license_kind: string;
      repo_init_readme_file: "on" | "off";
      repo_keywords: string;
      repo_keywords_add: string;
      repo_short_description: string;
      repo_slug: string;
      repo_visibility: ResourceVisibility;
      repo_website_url: string;
    };
  };
  [AppRoute.REPOSITORY_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_DETAILS_WITH_TRAILING_SLASH]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_EXPLORE]: undefined;
  [AppRoute.REPOSITORY_SHOW_OBJECT]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      objectId: string;
    };
  };
  [AppRoute.REPOSITORY_FORK]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_FORK_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
    body: {
      target_org_slug: string;
      target_repo_display_name: string;
      target_repo_slug: string;
      target_repo_visibility: ResourceVisibility;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUESTS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_CLOSE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {
      reason_message: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {}; // TODO: define this object shape
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
      commentId: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
      commentId: string;
    };
    body: {}; // TODO: define this object shape
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
    querystring: {
      from_branch?: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
    body: {
      state_from: PullRequestFormState;
      state_dest: PullRequestFormState;
      summary: string;
      description: string;
      source_parent_org_slug: string;
      source_repository_slug: string;
      source_repository_from_branch: string;
      target_parent_org_slug: string;
      target_repository_slug: string;
      target_repository_dest_branch: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_MERGE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {
      merge_summary: string;
      merge_message: string;
      delete_source_branch?: boolean;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_UPDATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {}; // TODO: define this object shape
  };
  [AppRoute.REPOSITORY_PIPELINES]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_STAGES]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_STAGE_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
      stageId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_ARTEFACTS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_TRIGGER_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.SETTINGS]: undefined;
  [AppRoute.SETTINGS_KEYS]: undefined;
  [AppRoute.SETTINGS_KEY_ADD]: {
    params: {
      username: string;
    };
  };
  [AppRoute.SETTINGS_KEY_ADD_ACTION]: {
    params: {
      username: string;
    };
    body: {
      name: string;
      key: string;
    };
  };
  [AppRoute.SETTINGS_KEY_UPDATE]: {
    params: {
      username: string;
      keyId: string;
    };
  };
  [AppRoute.SETTINGS_KEY_UPDATE_ACTION]: {
    params: {
      username: string;
      keyId: string;
    };
    body: {
      name: string;
      key: string;
    };
  };
  [AppRoute.SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION]: {
    params: {
      outputFormat?: "html" | "json";
    };
    body: {
      code: string;
      language: string;
      theme_scheme: AppThemeScheme;
    };
  };
  [AppRoute.USER_DASHBOARD]: undefined;
  [AppRoute.USER_DETAILS]: {
    params: {
      username: string;
    };
  };
}

export const AppRouteSchemas: Record<AppRoute, undefined | FastifySchema> = {
  [AppRoute.HOME]: undefined,
  [AppRoute.SSH_AUTH]: {
    body: {
      type: "object",
      required: ["command", "repoSlug", "username", "publicKey"],
      additionalProperties: false,
      properties: {
        command: {
          type: "string",
          enum: ["git-receive-pack", "git-upload-pack"],
        },
        repoSlug: {
          type: "string",
        },
        username: {
          type: "string",
        },
        publicKey: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_COUNTERS_API]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: { type: "string" },
        repoSlug: { type: "string" },
      },
    },
  },
  [AppRoute.THEME_SET_SCHEME_ACTION]: {
    params: {
      type: "object",
      required: ["themeScheme"],
      additionalProperties: false,
      properties: {
        themeScheme: {
          type: "string",
          enum: ["light", "dark"],
        },
      },
    },
  },
  [AppRoute.AUTH_REGISTER]: undefined,
  [AppRoute.AUTH_REGISTER_ACTION]: {
    body: {
      type: "object",
      required: ["email_address", "username", "password"],
      additionalProperties: false,
      properties: {
        email_address: { type: "string" },
        username: { type: "string" },
        password: { type: "string" },
      },
    },
  },
  [AppRoute.AUTH_LOGIN]: {
    querystring: {
      type: "object",
      required: [],
      additionalProperties: false,
      properties: {
        after_login_goto: { type: "string" },
      },
    },
  },
  [AppRoute.AUTH_LOGIN_ACTION]: {
    body: {
      type: "object",
      required: ["email_address", "password"],
      additionalProperties: false,
      properties: {
        email_address: { type: "string" },
        password: { type: "string" },
      },
    },
  },
  [AppRoute.AUTH_LOGOUT_ACTION]: undefined,
  [AppRoute.ORGANIZATION_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_BROWSER]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "currentRef", "*"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        currentRef: {
          type: "string",
        },
        "*": {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_BROWSER_WITH_PATH]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "currentRef", "*"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        currentRef: {
          type: "string",
        },
        "*": {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_COMMITS_LOG]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "currentRef"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        currentRef: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_COMPARE]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "refA", "refB"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        refA: {
          type: "string",
        },
        refB: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_CREATE]: undefined,
  [AppRoute.REPOSITORY_CREATE_ACTION]: {
    body: {
      type: "object",
      required: [
        "parent_org_slug",
        "repo_display_name",
        // "repo_init_license_file",
        // "repo_init_license_kind",
        // "repo_init_readme_file",
        "repo_keywords",
        "repo_keywords_add",
        // "repo_short_description",
        "repo_slug",
        // "repo_visibility",
        // "repo_website_url",
      ],
      additionalProperties: false,
      properties: {
        parent_org_slug: {
          type: "string",
        },
        repo_display_name: {
          type: "string",
          minLength: 3,
          maxLength: 64,
        },
        repo_init_license_file: {
          type: "string",
          enum: ["on", "off"],
        },
        repo_init_license_kind: {
          type: "string",
        },
        repo_init_readme_file: {
          type: "string",
          enum: ["on", "off"],
        },
        repo_keywords: {
          type: "string",
        },
        repo_keywords_add: {
          type: "string",
        },
        repo_short_description: {
          type: "string",
          minLength: 10,
          maxLength: 140,
        },
        repo_slug: {
          type: "string",
          minLength: 3,
          maxLength: 64,
        },
        repo_visibility: {
          type: "string",
          enum: ["PUBLIC", "UNLISTED", "PRIVATE"],
        },
        repo_website_url: {
          type: "string",
          format: "uri",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_DETAILS_WITH_TRAILING_SLASH]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_EXPLORE]: undefined,
  [AppRoute.REPOSITORY_SHOW_OBJECT]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "objectId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        objectId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_FORK]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: [
        "target_org_slug",
        "target_repo_display_name",
        "target_repo_slug",
        "target_repo_visibility",
      ],
      additionalProperties: false,
      properties: {
        target_org_slug: {
          type: "string",
        },
        target_repo_display_name: {
          type: "string",
        },
        target_repo_slug: {
          type: "string",
        },
        target_repo_visibility: {
          type: "string",
          enum: ["PUBLIC", "UNLISTED", "PRIVATE"],
        },
      },
    },
  },
  [AppRoute.REPOSITORY_FORK_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUESTS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_CLOSE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
    // body: {}, // TODO: define this object shape
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
    // body: {}, // TODO: define this object shape
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
    querystring: {
      type: "object",
      required: [],
      additionalProperties: false,
      properties: {
        from_branch: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: [
        "state_from",
        "state_dest",
        // --
        "summary",
        "source_parent_org_slug",
        "source_repository_slug",
        "source_repository_from_branch",
        "target_parent_org_slug",
        "target_repository_slug",
        "target_repository_dest_branch",
      ],
      additionalProperties: false,
      properties: {
        state_from: {
          type: "string",
        },
        state_dest: {
          type: "string",
        },
        summary: {
          type: "string",
        },
        description: {
          type: "string",
        },
        source_parent_org_slug: {
          type: "string",
        },
        source_repository_slug: {
          type: "string",
        },
        source_repository_from_branch: {
          type: "string",
        },
        target_parent_org_slug: {
          type: "string",
        },
        target_repository_slug: {
          type: "string",
        },
        target_repository_dest_branch: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_MERGE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
    body: {
      type: "object",
      required: ["merge_summary"],
      additionalProperties: false,
      properties: {
        merge_summary: {
          type: "string",
        },
        merge_message: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_UPDATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINES]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_STAGES]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_STAGE_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId", "stageId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
        stageId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_ARTEFACTS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId", "stageId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
        stageId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_TRIGGER_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS]: undefined,
  [AppRoute.SETTINGS_KEYS]: undefined,
  [AppRoute.SETTINGS_KEY_ADD]: {
    params: {
      type: "object",
      required: ["username"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS_KEY_ADD_ACTION]: {
    params: {
      type: "object",
      required: ["username"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: ["name", "key"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        key: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS_KEY_UPDATE]: {
    params: {
      type: "object",
      required: ["username", "keyId"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        keyId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS_KEY_UPDATE_ACTION]: {
    params: {
      type: "object",
      required: ["username", "keyId"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        keyId: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: ["name", "key"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        key: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION]: {
    params: {
      type: "object",
      required: [],
      additionalProperties: false,
      properties: {
        outputFormat: {
          type: "string",
          enum: ["html", "json"],
        },
      },
    },
    body: {
      type: "object",
      required: ["code", "language", "theme_scheme"],
      additionalProperties: false,
      properties: {
        code: {
          type: "string",
        },
        language: {
          type: "string",
        },
        theme_scheme: {
          type: "string",
          enum: ["light", "dark"],
        },
      },
    },
  },
  [AppRoute.USER_DASHBOARD]: undefined,
  [AppRoute.USER_DETAILS]: {
    params: {
      type: "object",
      required: ["username"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
      },
    },
  },
};

.ts
TypeScript
(application/typescript)
// 3rd-party
import type { FastifySchema } from "fastify";
// generated via script[generate:prisma]
import type { ResourceVisibility } from "@prisma/client";
// app
import type { AppThemeScheme } from "./types";
// app islands DTO's
import { PullRequestFormState } from "./islands/RepositoryPullRequestCreateForm";

export enum AppRoute {
  HOME = "home",
  SSH_AUTH = "ssh.auth_helper",
  THEME_SET_SCHEME_ACTION = "theme.set_scheme.action",
  AUTH_REGISTER = "auth.register",
  AUTH_REGISTER_ACTION = "auth.register.action",
  AUTH_LOGIN = "auth.login",
  AUTH_LOGIN_ACTION = "auth.login.action",
  AUTH_LOGOUT_ACTION = "auth.logout.action",
  ORGANIZATION_DETAILS = "organization.details",
  REPOSITORY_COUNTERS_API = "repository.counters.api",
  REPOSITORY_BROWSER = "repository.browser",
  REPOSITORY_BROWSER_WITH_PATH = "repository.browser.with_path",
  REPOSITORY_COMMITS_LOG = "repository.commits_log",
  REPOSITORY_COMPARE = "repository.compare",
  REPOSITORY_CREATE = "repository.create",
  REPOSITORY_CREATE_ACTION = "repository.create.action",
  REPOSITORY_DETAILS = "repository.details",
  REPOSITORY_DETAILS_WITH_TRAILING_SLASH = "repository.details.with_trailing_slash",
  REPOSITORY_EXPLORE = "repository.explore",
  REPOSITORY_SHOW_OBJECT = "repository.show_object",
  REPOSITORY_FORK = "repository.fork",
  REPOSITORY_FORK_ACTION = "repository.fork.action",
  REPOSITORY_PULL_REQUESTS = "repository.pull_requests",
  REPOSITORY_PULL_REQUEST_CLOSE_ACTION = "repository.pull_request.close.action",
  REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION = "repository.pull_request.comment.create.action",
  REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION = "repository.pull_request.comment.delete.action",
  REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION = "repository.pull_request.comment.update.action",
  REPOSITORY_PULL_REQUEST_CREATE = "repository.pull_request.create",
  REPOSITORY_PULL_REQUEST_CREATE_ACTION = "repository.pull_request.create.action",
  REPOSITORY_PULL_REQUEST_DELETE_ACTION = "repository.pull_request.delete.action",
  REPOSITORY_PULL_REQUEST_DETAILS = "repository.pull_request.details",
  REPOSITORY_PULL_REQUEST_MERGE_ACTION = "repository.pull_request.merge.action",
  REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION = "repository.pull_request.delete_source_branch.action",
  REPOSITORY_PULL_REQUEST_UPDATE_ACTION = "repository.pull_request.update.action",
  REPOSITORY_PIPELINES = "repository.pipelines",
  REPOSITORY_PIPELINE_DETAILS = "repository.pipeline_details",
  REPOSITORY_PIPELINE_STAGES = "repository.pipeline.stages",
  REPOSITORY_PIPELINE_STAGE_DETAILS = "repository.pipeline.stages.details",
  REPOSITORY_PIPELINE_ARTEFACTS = "repository.pipeline.artefacts",
  REPOSITORY_PIPELINE_TRIGGER_ACTION = "repository.pipeline.trigger.action",
  SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION = "syntax_highlight.highlight_code.action",
  SETTINGS = "settings.home",
  SETTINGS_KEYS = "settings.keys.list",
  SETTINGS_KEY_ADD = "settings.keys.add",
  SETTINGS_KEY_ADD_ACTION = "settings.keys.add.action",
  SETTINGS_KEY_UPDATE = "settings.keys.update",
  SETTINGS_KEY_UPDATE_ACTION = "settings.keys.update.action",
  USER_DASHBOARD = "user.dashboard",
  USER_DETAILS = "user.details",
}

export const AppRoutePaths: Record<AppRoute, string> = {
  [AppRoute.HOME]: "/",
  [AppRoute.SSH_AUTH]: "/_ssh/auth",
  [AppRoute.THEME_SET_SCHEME_ACTION]: "/theme/:themeScheme",
  [AppRoute.AUTH_REGISTER]: "/auth/register",
  [AppRoute.AUTH_REGISTER_ACTION]: "/auth/register",
  [AppRoute.AUTH_LOGIN]: "/auth/login",
  [AppRoute.AUTH_LOGIN_ACTION]: "/auth/login",
  [AppRoute.AUTH_LOGOUT_ACTION]: "/auth/logout",
  [AppRoute.ORGANIZATION_DETAILS]: "/:orgSlug",
  [AppRoute.REPOSITORY_COUNTERS_API]: "/api/repos/:orgSlug/:repoSlug/counters",
  [AppRoute.REPOSITORY_BROWSER]: "/:orgSlug/:repoSlug/:currentRef/tree",
  [AppRoute.REPOSITORY_BROWSER_WITH_PATH]:
    "/:orgSlug/:repoSlug/:currentRef/tree/*",
  [AppRoute.REPOSITORY_COMMITS_LOG]: "/:orgSlug/:repoSlug/:currentRef/commits",
  [AppRoute.REPOSITORY_COMPARE]: "/:orgSlug/:repoSlug/compare/:refA..:refB",
  [AppRoute.REPOSITORY_CREATE]: "/repo/new",
  [AppRoute.REPOSITORY_CREATE_ACTION]: "/repo/new",
  [AppRoute.REPOSITORY_DETAILS]: "/:orgSlug/:repoSlug",
  [AppRoute.REPOSITORY_DETAILS_WITH_TRAILING_SLASH]: "/:orgSlug/:repoSlug/",
  [AppRoute.REPOSITORY_EXPLORE]: "/repo/explore",
  [AppRoute.REPOSITORY_SHOW_OBJECT]: "/:orgSlug/:repoSlug/show/:objectId",
  [AppRoute.REPOSITORY_FORK]: "/:orgSlug/:repoSlug/fork",
  [AppRoute.REPOSITORY_FORK_ACTION]: "/:orgSlug/:repoSlug/fork",
  [AppRoute.REPOSITORY_PULL_REQUESTS]: "/:orgSlug/:repoSlug/pulls",
  [AppRoute.REPOSITORY_PULL_REQUEST_CLOSE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/close",
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/comment",
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/comment/delete",
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/comment/edit",
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE]: "/:orgSlug/:repoSlug/pulls/new",
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/new",
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/delete",
  [AppRoute.REPOSITORY_PULL_REQUEST_DETAILS]:
    "/:orgSlug/:repoSlug/pulls/:pullUid",
  [AppRoute.REPOSITORY_PULL_REQUEST_MERGE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/merge",
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/delete-source-branch",
  [AppRoute.REPOSITORY_PULL_REQUEST_UPDATE_ACTION]:
    "/:orgSlug/:repoSlug/pulls/:pullUid/edit",
  [AppRoute.REPOSITORY_PIPELINES]: "/:orgSlug/:repoSlug/pipelines",
  [AppRoute.REPOSITORY_PIPELINE_DETAILS]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId",
  [AppRoute.REPOSITORY_PIPELINE_STAGES]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/stages",
  [AppRoute.REPOSITORY_PIPELINE_STAGE_DETAILS]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/stages/:stageId",
  [AppRoute.REPOSITORY_PIPELINE_ARTEFACTS]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/artefacts",
  [AppRoute.REPOSITORY_PIPELINE_TRIGGER_ACTION]:
    "/:orgSlug/:repoSlug/pipelines/:pipelineId/trigger",
  [AppRoute.SETTINGS]: "/@:username/settings",
  [AppRoute.SETTINGS_KEYS]: "/@:username/settings/keys",
  [AppRoute.SETTINGS_KEY_ADD]: "/@:username/settings/keys/add",
  [AppRoute.SETTINGS_KEY_ADD_ACTION]: "/@:username/settings/keys/add",
  [AppRoute.SETTINGS_KEY_UPDATE]: "/@:username/settings/keys/:keyId/edit",
  [AppRoute.SETTINGS_KEY_UPDATE_ACTION]:
    "/@:username/settings/keys/:keyId/edit",
  [AppRoute.SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION]:
    "/api/syntax/highlight/:outputFormat",
  [AppRoute.USER_DASHBOARD]: "/dashboard",
  [AppRoute.USER_DETAILS]: "/@:username",
};

export interface AppRouteParams {
  [x: string]: any;
  [AppRoute.HOME]: undefined;
  [AppRoute.SSH_AUTH]: {
    body: {
      // git-receive-pack: push, git-upload-pack: clone, pull, fetch
      command: "git-receive-pack" | "git-upload-pack";
      repoSlug: string;
      username: string;
      publicKey: string;
    };
  };
  [AppRoute.REPOSITORY_COUNTERS_API]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.THEME_SET_SCHEME_ACTION]: {
    params: {
      themeScheme: AppThemeScheme;
    };
  };
  [AppRoute.AUTH_REGISTER]: undefined;
  [AppRoute.AUTH_REGISTER_ACTION]: {
    body: {
      email_address: string;
      username: string;
      password: string;
    };
  };
  [AppRoute.AUTH_LOGIN]: {
    querystring: {
      after_login_goto?: string;
    };
  };
  [AppRoute.AUTH_LOGIN_ACTION]: {
    body: {
      email_address: string;
      password: string;
    };
  };
  [AppRoute.AUTH_LOGOUT_ACTION]: undefined;
  [AppRoute.ORGANIZATION_DETAILS]: {
    params: {
      orgSlug: string;
    };
  };
  [AppRoute.REPOSITORY_BROWSER]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      currentRef: string;
      "*": string;
    };
  };
  [AppRoute.REPOSITORY_BROWSER_WITH_PATH]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      currentRef: string;
      "*": string;
    };
  };
  [AppRoute.REPOSITORY_COMMITS_LOG]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      currentRef: string;
    };
  };
  [AppRoute.REPOSITORY_COMPARE]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      refA: string;
      refB: string;
    };
  };
  [AppRoute.REPOSITORY_CREATE]: undefined;
  [AppRoute.REPOSITORY_CREATE_ACTION]: {
    body: {
      parent_org_slug: string;
      repo_display_name: string;
      repo_init_license_file: "on" | "off";
      repo_init_license_kind: string;
      repo_init_readme_file: "on" | "off";
      repo_keywords: string;
      repo_keywords_add: string;
      repo_short_description: string;
      repo_slug: string;
      repo_visibility: ResourceVisibility;
      repo_website_url: string;
    };
  };
  [AppRoute.REPOSITORY_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_DETAILS_WITH_TRAILING_SLASH]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_EXPLORE]: undefined;
  [AppRoute.REPOSITORY_SHOW_OBJECT]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      objectId: string;
    };
  };
  [AppRoute.REPOSITORY_FORK]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_FORK_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
    body: {
      target_org_slug: string;
      target_repo_display_name: string;
      target_repo_slug: string;
      target_repo_visibility: ResourceVisibility;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUESTS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_CLOSE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {
      reason_message: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {}; // TODO: define this object shape
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
      commentId: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
      commentId: string;
    };
    body: {}; // TODO: define this object shape
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
    querystring: {
      from_branch?: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
    body: {
      state_from: PullRequestFormState;
      state_dest: PullRequestFormState;
      summary: string;
      description: string;
      source_parent_org_slug: string;
      source_repository_slug: string;
      source_repository_from_branch: string;
      target_parent_org_slug: string;
      target_repository_slug: string;
      target_repository_dest_branch: string;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_MERGE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {
      merge_summary: string;
      merge_message: string;
      delete_source_branch?: boolean;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
  };
  [AppRoute.REPOSITORY_PULL_REQUEST_UPDATE_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pullUid: number;
    };
    body: {}; // TODO: define this object shape
  };
  [AppRoute.REPOSITORY_PIPELINES]: {
    params: {
      orgSlug: string;
      repoSlug: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_STAGES]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_STAGE_DETAILS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
      stageId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_ARTEFACTS]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.REPOSITORY_PIPELINE_TRIGGER_ACTION]: {
    params: {
      orgSlug: string;
      repoSlug: string;
      pipelineId: string;
    };
  };
  [AppRoute.SETTINGS]: undefined;
  [AppRoute.SETTINGS_KEYS]: undefined;
  [AppRoute.SETTINGS_KEY_ADD]: {
    params: {
      username: string;
    };
  };
  [AppRoute.SETTINGS_KEY_ADD_ACTION]: {
    params: {
      username: string;
    };
    body: {
      name: string;
      key: string;
    };
  };
  [AppRoute.SETTINGS_KEY_UPDATE]: {
    params: {
      username: string;
      keyId: string;
    };
  };
  [AppRoute.SETTINGS_KEY_UPDATE_ACTION]: {
    params: {
      username: string;
      keyId: string;
    };
    body: {
      name: string;
      key: string;
    };
  };
  [AppRoute.SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION]: {
    params: {
      outputFormat?: "html" | "json";
    };
    body: {
      code: string;
      language: string;
      theme_scheme: AppThemeScheme;
    };
  };
  [AppRoute.USER_DASHBOARD]: undefined;
  [AppRoute.USER_DETAILS]: {
    params: {
      username: string;
    };
  };
}

export const AppRouteSchemas: Record<AppRoute, undefined | FastifySchema> = {
  [AppRoute.HOME]: undefined,
  [AppRoute.SSH_AUTH]: {
    body: {
      type: "object",
      required: ["command", "repoSlug", "username", "publicKey"],
      additionalProperties: false,
      properties: {
        command: {
          type: "string",
          enum: ["git-receive-pack", "git-upload-pack"],
        },
        repoSlug: {
          type: "string",
        },
        username: {
          type: "string",
        },
        publicKey: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_COUNTERS_API]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: { type: "string" },
        repoSlug: { type: "string" },
      },
    },
  },
  [AppRoute.THEME_SET_SCHEME_ACTION]: {
    params: {
      type: "object",
      required: ["themeScheme"],
      additionalProperties: false,
      properties: {
        themeScheme: {
          type: "string",
          enum: ["light", "dark"],
        },
      },
    },
  },
  [AppRoute.AUTH_REGISTER]: undefined,
  [AppRoute.AUTH_REGISTER_ACTION]: {
    body: {
      type: "object",
      required: ["email_address", "username", "password"],
      additionalProperties: false,
      properties: {
        email_address: { type: "string" },
        username: { type: "string" },
        password: { type: "string" },
      },
    },
  },
  [AppRoute.AUTH_LOGIN]: {
    querystring: {
      type: "object",
      required: [],
      additionalProperties: false,
      properties: {
        after_login_goto: { type: "string" },
      },
    },
  },
  [AppRoute.AUTH_LOGIN_ACTION]: {
    body: {
      type: "object",
      required: ["email_address", "password"],
      additionalProperties: false,
      properties: {
        email_address: { type: "string" },
        password: { type: "string" },
      },
    },
  },
  [AppRoute.AUTH_LOGOUT_ACTION]: undefined,
  [AppRoute.ORGANIZATION_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_BROWSER]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "currentRef", "*"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        currentRef: {
          type: "string",
        },
        "*": {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_BROWSER_WITH_PATH]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "currentRef", "*"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        currentRef: {
          type: "string",
        },
        "*": {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_COMMITS_LOG]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "currentRef"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        currentRef: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_COMPARE]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "refA", "refB"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        refA: {
          type: "string",
        },
        refB: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_CREATE]: undefined,
  [AppRoute.REPOSITORY_CREATE_ACTION]: {
    body: {
      type: "object",
      required: [
        "parent_org_slug",
        "repo_display_name",
        // "repo_init_license_file",
        // "repo_init_license_kind",
        // "repo_init_readme_file",
        "repo_keywords",
        "repo_keywords_add",
        // "repo_short_description",
        "repo_slug",
        // "repo_visibility",
        // "repo_website_url",
      ],
      additionalProperties: false,
      properties: {
        parent_org_slug: {
          type: "string",
        },
        repo_display_name: {
          type: "string",
          minLength: 3,
          maxLength: 64,
        },
        repo_init_license_file: {
          type: "string",
          enum: ["on", "off"],
        },
        repo_init_license_kind: {
          type: "string",
        },
        repo_init_readme_file: {
          type: "string",
          enum: ["on", "off"],
        },
        repo_keywords: {
          type: "string",
        },
        repo_keywords_add: {
          type: "string",
        },
        repo_short_description: {
          type: "string",
          minLength: 10,
          maxLength: 140,
        },
        repo_slug: {
          type: "string",
          minLength: 3,
          maxLength: 64,
        },
        repo_visibility: {
          type: "string",
          enum: ["PUBLIC", "UNLISTED", "PRIVATE"],
        },
        repo_website_url: {
          type: "string",
          format: "uri",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_DETAILS_WITH_TRAILING_SLASH]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_EXPLORE]: undefined,
  [AppRoute.REPOSITORY_SHOW_OBJECT]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "objectId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        objectId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_FORK]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: [
        "target_org_slug",
        "target_repo_display_name",
        "target_repo_slug",
        "target_repo_visibility",
      ],
      additionalProperties: false,
      properties: {
        target_org_slug: {
          type: "string",
        },
        target_repo_display_name: {
          type: "string",
        },
        target_repo_slug: {
          type: "string",
        },
        target_repo_visibility: {
          type: "string",
          enum: ["PUBLIC", "UNLISTED", "PRIVATE"],
        },
      },
    },
  },
  [AppRoute.REPOSITORY_FORK_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUESTS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_CLOSE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_CREATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
    // body: {}, // TODO: define this object shape
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_DELETE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_COMMENT_UPDATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
    // body: {}, // TODO: define this object shape
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
    querystring: {
      type: "object",
      required: [],
      additionalProperties: false,
      properties: {
        from_branch: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_CREATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: [
        "state_from",
        "state_dest",
        // --
        "summary",
        "source_parent_org_slug",
        "source_repository_slug",
        "source_repository_from_branch",
        "target_parent_org_slug",
        "target_repository_slug",
        "target_repository_dest_branch",
      ],
      additionalProperties: false,
      properties: {
        state_from: {
          type: "string",
        },
        state_dest: {
          type: "string",
        },
        summary: {
          type: "string",
        },
        description: {
          type: "string",
        },
        source_parent_org_slug: {
          type: "string",
        },
        source_repository_slug: {
          type: "string",
        },
        source_repository_from_branch: {
          type: "string",
        },
        target_parent_org_slug: {
          type: "string",
        },
        target_repository_slug: {
          type: "string",
        },
        target_repository_dest_branch: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_MERGE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
    body: {
      type: "object",
      required: ["merge_summary"],
      additionalProperties: false,
      properties: {
        merge_summary: {
          type: "string",
        },
        merge_message: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_DELETE_SOURCE_BRANCH_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PULL_REQUEST_UPDATE_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pullUid"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pullUid: {
          type: "number",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINES]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_STAGES]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_STAGE_DETAILS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId", "stageId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
        stageId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_ARTEFACTS]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId", "stageId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
        stageId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.REPOSITORY_PIPELINE_TRIGGER_ACTION]: {
    params: {
      type: "object",
      required: ["orgSlug", "repoSlug", "pipelineId"],
      additionalProperties: false,
      properties: {
        orgSlug: {
          type: "string",
        },
        repoSlug: {
          type: "string",
        },
        pipelineId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS]: undefined,
  [AppRoute.SETTINGS_KEYS]: undefined,
  [AppRoute.SETTINGS_KEY_ADD]: {
    params: {
      type: "object",
      required: ["username"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS_KEY_ADD_ACTION]: {
    params: {
      type: "object",
      required: ["username"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: ["name", "key"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        key: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS_KEY_UPDATE]: {
    params: {
      type: "object",
      required: ["username", "keyId"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        keyId: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SETTINGS_KEY_UPDATE_ACTION]: {
    params: {
      type: "object",
      required: ["username", "keyId"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        keyId: {
          type: "string",
        },
      },
    },
    body: {
      type: "object",
      required: ["name", "key"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
        key: {
          type: "string",
        },
      },
    },
  },
  [AppRoute.SYNTAX_HIGHLIGHT_HIGHLIGHT_CODE_ACTION]: {
    params: {
      type: "object",
      required: [],
      additionalProperties: false,
      properties: {
        outputFormat: {
          type: "string",
          enum: ["html", "json"],
        },
      },
    },
    body: {
      type: "object",
      required: ["code", "language", "theme_scheme"],
      additionalProperties: false,
      properties: {
        code: {
          type: "string",
        },
        language: {
          type: "string",
        },
        theme_scheme: {
          type: "string",
          enum: ["light", "dark"],
        },
      },
    },
  },
  [AppRoute.USER_DASHBOARD]: undefined,
  [AppRoute.USER_DETAILS]: {
    params: {
      type: "object",
      required: ["username"],
      additionalProperties: false,
      properties: {
        username: {
          type: "string",
        },
      },
    },
  },
};

GitFOSS • v0.2.0 (#421408f) • MIT License