export interface CODEProps { space?: string repoName?: string repoPath?: string gitRef?: string resourcePath?: string commitRef?: string branch?: string tags?: string diffRefs?: string pullRequestId?: string pullRequestSection?: string webhookId?: string } export interface CODEQueryProps { query?: string } export const pathProps: Readonly, 'repoPath' | 'branch' | 'tags'>> = { space: ':space', repoName: ':repoName', gitRef: ':gitRef*', resourcePath: ':resourcePath*', commitRef: ':commitRef*', diffRefs: ':diffRefs*', pullRequestId: ':pullRequestId', pullRequestSection: ':pullRequestSection*', webhookId: ':webhookId' } export interface CODERoutes { toSignIn: () => string toRegister: () => string toCODEHome: () => string toCODESpaces: () => string toCODEGlobalSettings: () => string toCODERepositories: (args: Required>) => string toCODERepository: (args: RequiredField, 'repoPath'>) => string toCODEFileEdit: (args: Required>) => string toCODECommits: (args: Required>) => string toCODECommit: (args: Required>) => string toCODEPullRequests: (args: Required>) => string toCODEPullRequest: ( args: RequiredField< Pick, 'repoPath' | 'pullRequestId' > ) => string toCODECompare: (args: Required>) => string toCODEBranches: (args: Required>) => string toCODETags: (args: Required>) => string toCODEWebhooks: (args: Required>) => string toCODEWebhookNew: (args: Required>) => string toCODEWebhookDetails: (args: Required>) => string toCODESettings: (args: Required>) => string } export const routes: CODERoutes = { toSignIn: (): string => '/signin', toRegister: (): string => '/register', toCODEHome: () => `/`, toCODESpaces: () => `/spaces`, toCODEGlobalSettings: () => '/settings', toCODERepositories: ({ space }) => `/spaces/${space}`, toCODERepository: ({ repoPath, gitRef, resourcePath }) => `/${repoPath}${gitRef ? '/files/' + gitRef : ''}${resourcePath ? '/~/' + resourcePath : ''}`, toCODEFileEdit: ({ repoPath, gitRef, resourcePath }: RequiredField, 'repoPath' | 'gitRef'>) => `/${repoPath}/edit/${gitRef}/~/${resourcePath || ''}`, toCODECommits: ({ repoPath, commitRef }) => `/${repoPath}/commits/${commitRef}`, toCODECommit: ({ repoPath, commitRef }) => `/${repoPath}/commit/${commitRef}`, toCODEPullRequests: ({ repoPath }) => `/${repoPath}/pulls`, toCODEPullRequest: ({ repoPath, pullRequestId, pullRequestSection }) => `/${repoPath}/pulls/${pullRequestId}${pullRequestSection ? '/' + pullRequestSection : ''}`, toCODECompare: ({ repoPath, diffRefs }) => `/${repoPath}/pulls/compare/${diffRefs}`, toCODEBranches: ({ repoPath }) => `/${repoPath}/branches`, toCODETags: ({ repoPath }) => `/${repoPath}/tags`, toCODESettings: ({ repoPath }) => `/${repoPath}/settings`, toCODEWebhooks: ({ repoPath }) => `/${repoPath}/webhooks`, toCODEWebhookNew: ({ repoPath }) => `/${repoPath}/webhooks/new`, toCODEWebhookDetails: ({ repoPath, webhookId }) => `/${repoPath}/webhook/${webhookId}` }