mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: simplify database colums
This commit is contained in:
@@ -47,7 +47,7 @@ const BitbucketProviderSchema = z.object({
|
|||||||
})
|
})
|
||||||
.required(),
|
.required(),
|
||||||
branch: z.string().min(1, "Branch is required"),
|
branch: z.string().min(1, "Branch is required"),
|
||||||
bitbucketProviderId: z.string().min(1, "Bitbucket Provider is required"),
|
bitbucketId: z.string().min(1, "Bitbucket Provider is required"),
|
||||||
});
|
});
|
||||||
|
|
||||||
type BitbucketProvider = z.infer<typeof BitbucketProviderSchema>;
|
type BitbucketProvider = z.infer<typeof BitbucketProviderSchema>;
|
||||||
@@ -71,14 +71,14 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
},
|
},
|
||||||
bitbucketProviderId: "",
|
bitbucketId: "",
|
||||||
branch: "",
|
branch: "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(BitbucketProviderSchema),
|
resolver: zodResolver(BitbucketProviderSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
const repository = form.watch("repository");
|
const repository = form.watch("repository");
|
||||||
const bitbucketProviderId = form.watch("bitbucketProviderId");
|
const bitbucketId = form.watch("bitbucketId");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: repositories,
|
data: repositories,
|
||||||
@@ -86,7 +86,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
error,
|
error,
|
||||||
isError,
|
isError,
|
||||||
} = api.gitProvider.getBitbucketRepositories.useQuery({
|
} = api.gitProvider.getBitbucketRepositories.useQuery({
|
||||||
bitbucketProviderId,
|
bitbucketId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -97,11 +97,10 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
{
|
{
|
||||||
owner: repository?.owner,
|
owner: repository?.owner,
|
||||||
repo: repository?.repo,
|
repo: repository?.repo,
|
||||||
bitbucketProviderId,
|
bitbucketId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled:
|
enabled: !!repository?.owner && !!repository?.repo && !!bitbucketId,
|
||||||
!!repository?.owner && !!repository?.repo && !!bitbucketProviderId,
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
owner: data.bitbucketOwner || "",
|
owner: data.bitbucketOwner || "",
|
||||||
},
|
},
|
||||||
buildPath: data.bitbucketBuildPath || "/",
|
buildPath: data.bitbucketBuildPath || "/",
|
||||||
bitbucketProviderId: data.bitbucketProviderId || "",
|
bitbucketId: data.bitbucketId || "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [form.reset, data, form]);
|
}, [form.reset, data, form]);
|
||||||
@@ -125,7 +124,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
bitbucketRepository: data.repository.repo,
|
bitbucketRepository: data.repository.repo,
|
||||||
bitbucketOwner: data.repository.owner,
|
bitbucketOwner: data.repository.owner,
|
||||||
bitbucketBuildPath: data.buildPath,
|
bitbucketBuildPath: data.buildPath,
|
||||||
bitbucketProviderId: data.bitbucketProviderId,
|
bitbucketId: data.bitbucketId,
|
||||||
applicationId,
|
applicationId,
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
@@ -150,7 +149,7 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
<div className="grid md:grid-cols-2 gap-4">
|
<div className="grid md:grid-cols-2 gap-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="bitbucketProviderId"
|
name="bitbucketId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="md:col-span-2 flex flex-col">
|
<FormItem className="md:col-span-2 flex flex-col">
|
||||||
<FormLabel>Bitbucket Account</FormLabel>
|
<FormLabel>Bitbucket Account</FormLabel>
|
||||||
@@ -174,8 +173,8 @@ export const SaveBitbucketProvider = ({ applicationId }: Props) => {
|
|||||||
<SelectContent>
|
<SelectContent>
|
||||||
{bitbucketProviders?.map((bitbucketProvider) => (
|
{bitbucketProviders?.map((bitbucketProvider) => (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
key={bitbucketProvider.bitbucketProviderId}
|
key={bitbucketProvider.bitbucketId}
|
||||||
value={bitbucketProvider.bitbucketProviderId}
|
value={bitbucketProvider.bitbucketId}
|
||||||
>
|
>
|
||||||
{bitbucketProvider.gitProvider.name}
|
{bitbucketProvider.gitProvider.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const GithubProviderSchema = z.object({
|
|||||||
})
|
})
|
||||||
.required(),
|
.required(),
|
||||||
branch: z.string().min(1, "Branch is required"),
|
branch: z.string().min(1, "Branch is required"),
|
||||||
githubProviderId: z.string().min(1, "Github Provider is required"),
|
githubId: z.string().min(1, "Github Provider is required"),
|
||||||
});
|
});
|
||||||
|
|
||||||
type GithubProvider = z.infer<typeof GithubProviderSchema>;
|
type GithubProvider = z.infer<typeof GithubProviderSchema>;
|
||||||
@@ -69,18 +69,18 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
},
|
},
|
||||||
githubProviderId: "",
|
githubId: "",
|
||||||
branch: "",
|
branch: "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(GithubProviderSchema),
|
resolver: zodResolver(GithubProviderSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
const repository = form.watch("repository");
|
const repository = form.watch("repository");
|
||||||
const githubProviderId = form.watch("githubProviderId");
|
const githubId = form.watch("githubId");
|
||||||
|
|
||||||
const { data: repositories, isLoading: isLoadingRepositories } =
|
const { data: repositories, isLoading: isLoadingRepositories } =
|
||||||
api.gitProvider.getRepositories.useQuery({
|
api.gitProvider.getRepositories.useQuery({
|
||||||
githubProviderId,
|
githubId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -91,10 +91,10 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
{
|
{
|
||||||
owner: repository?.owner,
|
owner: repository?.owner,
|
||||||
repo: repository?.repo,
|
repo: repository?.repo,
|
||||||
githubProviderId,
|
githubId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!repository?.owner && !!repository?.repo && !!githubProviderId,
|
enabled: !!repository?.owner && !!repository?.repo && !!githubId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
owner: data.owner || "",
|
owner: data.owner || "",
|
||||||
},
|
},
|
||||||
buildPath: data.buildPath || "/",
|
buildPath: data.buildPath || "/",
|
||||||
githubProviderId: data.githubProviderId || "",
|
githubId: data.githubId || "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [form.reset, data, form]);
|
}, [form.reset, data, form]);
|
||||||
@@ -119,7 +119,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
applicationId,
|
applicationId,
|
||||||
owner: data.repository.owner,
|
owner: data.repository.owner,
|
||||||
buildPath: data.buildPath,
|
buildPath: data.buildPath,
|
||||||
githubProviderId: data.githubProviderId,
|
githubId: data.githubId,
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
toast.success("Service Provided Saved");
|
toast.success("Service Provided Saved");
|
||||||
@@ -140,7 +140,7 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
<div className="grid md:grid-cols-2 gap-4">
|
<div className="grid md:grid-cols-2 gap-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="githubProviderId"
|
name="githubId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="md:col-span-2 flex flex-col">
|
<FormItem className="md:col-span-2 flex flex-col">
|
||||||
<FormLabel>Github Account</FormLabel>
|
<FormLabel>Github Account</FormLabel>
|
||||||
@@ -164,8 +164,8 @@ export const SaveGithubProvider = ({ applicationId }: Props) => {
|
|||||||
<SelectContent>
|
<SelectContent>
|
||||||
{githubProviders?.map((githubProvider) => (
|
{githubProviders?.map((githubProvider) => (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
key={githubProvider.githubProviderId}
|
key={githubProvider.githubId}
|
||||||
value={githubProvider.githubProviderId}
|
value={githubProvider.githubId}
|
||||||
>
|
>
|
||||||
{githubProvider.gitProvider.name}
|
{githubProvider.gitProvider.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const GitlabProviderSchema = z.object({
|
|||||||
})
|
})
|
||||||
.required(),
|
.required(),
|
||||||
branch: z.string().min(1, "Branch is required"),
|
branch: z.string().min(1, "Branch is required"),
|
||||||
gitlabProviderId: z.string().min(1, "Gitlab Provider is required"),
|
gitlabId: z.string().min(1, "Gitlab Provider is required"),
|
||||||
});
|
});
|
||||||
|
|
||||||
type GitlabProvider = z.infer<typeof GitlabProviderSchema>;
|
type GitlabProvider = z.infer<typeof GitlabProviderSchema>;
|
||||||
@@ -70,21 +70,21 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
owner: "",
|
owner: "",
|
||||||
repo: "",
|
repo: "",
|
||||||
},
|
},
|
||||||
gitlabProviderId: "",
|
gitlabId: "",
|
||||||
branch: "",
|
branch: "",
|
||||||
},
|
},
|
||||||
resolver: zodResolver(GitlabProviderSchema),
|
resolver: zodResolver(GitlabProviderSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
const repository = form.watch("repository");
|
const repository = form.watch("repository");
|
||||||
const gitlabProviderId = form.watch("gitlabProviderId");
|
const gitlabId = form.watch("gitlabId");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: repositories,
|
data: repositories,
|
||||||
isLoading: isLoadingRepositories,
|
isLoading: isLoadingRepositories,
|
||||||
error,
|
error,
|
||||||
} = api.gitProvider.getGitlabRepositories.useQuery({
|
} = api.gitProvider.getGitlabRepositories.useQuery({
|
||||||
gitlabProviderId,
|
gitlabId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -95,10 +95,10 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
{
|
{
|
||||||
owner: repository?.owner,
|
owner: repository?.owner,
|
||||||
repo: repository?.repo,
|
repo: repository?.repo,
|
||||||
gitlabProviderId: gitlabProviderId,
|
gitlabId: gitlabId,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: !!repository?.owner && !!repository?.repo && !!gitlabProviderId,
|
enabled: !!repository?.owner && !!repository?.repo && !!gitlabId,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
owner: data.gitlabOwner || "",
|
owner: data.gitlabOwner || "",
|
||||||
},
|
},
|
||||||
buildPath: data.gitlabBuildPath || "/",
|
buildPath: data.gitlabBuildPath || "/",
|
||||||
gitlabProviderId: data.gitlabProviderId || "",
|
gitlabId: data.gitlabId || "",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [form.reset, data, form]);
|
}, [form.reset, data, form]);
|
||||||
@@ -122,7 +122,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
gitlabRepository: data.repository.repo,
|
gitlabRepository: data.repository.repo,
|
||||||
gitlabOwner: data.repository.owner,
|
gitlabOwner: data.repository.owner,
|
||||||
gitlabBuildPath: data.buildPath,
|
gitlabBuildPath: data.buildPath,
|
||||||
gitlabProviderId: data.gitlabProviderId,
|
gitlabId: data.gitlabId,
|
||||||
applicationId,
|
applicationId,
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
@@ -145,7 +145,7 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
<div className="grid md:grid-cols-2 gap-4">
|
<div className="grid md:grid-cols-2 gap-4">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="gitlabProviderId"
|
name="gitlabId"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem className="md:col-span-2 flex flex-col">
|
<FormItem className="md:col-span-2 flex flex-col">
|
||||||
<FormLabel>Gitlab Account</FormLabel>
|
<FormLabel>Gitlab Account</FormLabel>
|
||||||
@@ -169,8 +169,8 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
<SelectContent>
|
<SelectContent>
|
||||||
{gitlabProviders?.map((gitlabProvider) => (
|
{gitlabProviders?.map((gitlabProvider) => (
|
||||||
<SelectItem
|
<SelectItem
|
||||||
key={gitlabProvider.gitlabProviderId}
|
key={gitlabProvider.gitlabId}
|
||||||
value={gitlabProvider.gitlabProviderId}
|
value={gitlabProvider.gitlabId}
|
||||||
>
|
>
|
||||||
{gitlabProvider.gitProvider.name}
|
{gitlabProvider.gitProvider.name}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { buttonVariants } from "@/components/ui/button";
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
|
import { Card, CardContent } from "@/components/ui/card";
|
||||||
import { AddGitlabProvider } from "./add-gitlab-provider";
|
import { AddGitlabProvider } from "./add-gitlab-provider";
|
||||||
import {
|
import {
|
||||||
BitbucketIcon,
|
BitbucketIcon,
|
||||||
@@ -49,13 +49,12 @@ export const ShowGitProviders = () => {
|
|||||||
const isGitlab = gitProvider.providerType === "gitlab";
|
const isGitlab = gitProvider.providerType === "gitlab";
|
||||||
const haveGithubRequirements =
|
const haveGithubRequirements =
|
||||||
gitProvider.providerType === "github" &&
|
gitProvider.providerType === "github" &&
|
||||||
gitProvider.githubProvider?.githubPrivateKey &&
|
gitProvider.github?.githubPrivateKey &&
|
||||||
gitProvider.githubProvider?.githubAppId &&
|
gitProvider.github?.githubAppId &&
|
||||||
gitProvider.githubProvider?.githubInstallationId;
|
gitProvider.github?.githubInstallationId;
|
||||||
|
|
||||||
const haveGitlabRequirements =
|
const haveGitlabRequirements =
|
||||||
gitProvider.gitlabProvider?.accessToken &&
|
gitProvider.gitlab?.accessToken && gitProvider.gitlab?.refreshToken;
|
||||||
gitProvider.gitlabProvider?.refreshToken;
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="space-y-4"
|
className="space-y-4"
|
||||||
@@ -89,7 +88,7 @@ export const ShowGitProviders = () => {
|
|||||||
{!haveGithubRequirements && isGithub && (
|
{!haveGithubRequirements && isGithub && (
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<Link
|
<Link
|
||||||
href={`${gitProvider?.githubProvider?.githubAppName}/installations/new?state=gh_setup:${gitProvider?.githubProvider.githubProviderId}`}
|
href={`${gitProvider?.github?.githubAppName}/installations/new?state=gh_setup:${gitProvider?.github.githubId}`}
|
||||||
className={buttonVariants({ className: "w-fit" })}
|
className={buttonVariants({ className: "w-fit" })}
|
||||||
>
|
>
|
||||||
Install Github App
|
Install Github App
|
||||||
@@ -100,7 +99,7 @@ export const ShowGitProviders = () => {
|
|||||||
{haveGithubRequirements && isGithub && (
|
{haveGithubRequirements && isGithub && (
|
||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<Link
|
<Link
|
||||||
href={`${gitProvider?.githubProvider?.githubAppName}`}
|
href={`${gitProvider?.github?.githubAppName}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className={buttonVariants({
|
className={buttonVariants({
|
||||||
className: "w-fit",
|
className: "w-fit",
|
||||||
@@ -116,8 +115,8 @@ export const ShowGitProviders = () => {
|
|||||||
<div className="flex flex-col gap-1">
|
<div className="flex flex-col gap-1">
|
||||||
<Link
|
<Link
|
||||||
href={getGitlabUrl(
|
href={getGitlabUrl(
|
||||||
gitProvider.gitlabProvider?.applicationId || "",
|
gitProvider.gitlab?.applicationId || "",
|
||||||
gitProvider.gitlabProvider?.gitlabProviderId || "",
|
gitProvider.gitlab?.gitlabId || "",
|
||||||
)}
|
)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
className={buttonVariants({
|
className={buttonVariants({
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
owner: input.owner,
|
owner: input.owner,
|
||||||
buildPath: input.buildPath,
|
buildPath: input.buildPath,
|
||||||
applicationStatus: "idle",
|
applicationStatus: "idle",
|
||||||
githubProviderId: input.githubProviderId,
|
githubId: input.githubId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -224,7 +224,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
gitlabBuildPath: input.gitlabBuildPath,
|
gitlabBuildPath: input.gitlabBuildPath,
|
||||||
sourceType: "gitlab",
|
sourceType: "gitlab",
|
||||||
applicationStatus: "idle",
|
applicationStatus: "idle",
|
||||||
gitlabProviderId: input.gitlabProviderId,
|
gitlabId: input.gitlabId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -239,7 +239,7 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
bitbucketBuildPath: input.bitbucketBuildPath,
|
bitbucketBuildPath: input.bitbucketBuildPath,
|
||||||
sourceType: "bitbucket",
|
sourceType: "bitbucket",
|
||||||
applicationStatus: "idle",
|
applicationStatus: "idle",
|
||||||
bitbucketProviderId: input.bitbucketProviderId,
|
bitbucketId: input.bitbucketId,
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export const gitProvider = createTRPCRouter({
|
|||||||
getGitlabRepositories: protectedProcedure
|
getGitlabRepositories: protectedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
gitlabProviderId: z.string().optional(),
|
gitlabId: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
@@ -141,7 +141,7 @@ export const gitProvider = createTRPCRouter({
|
|||||||
z.object({
|
z.object({
|
||||||
owner: z.string(),
|
owner: z.string(),
|
||||||
repo: z.string(),
|
repo: z.string(),
|
||||||
gitlabProviderId: z.string().optional(),
|
gitlabId: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
@@ -150,7 +150,7 @@ export const gitProvider = createTRPCRouter({
|
|||||||
getBitbucketRepositories: protectedProcedure
|
getBitbucketRepositories: protectedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
bitbucketProviderId: z.string().optional(),
|
bitbucketId: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
@@ -161,7 +161,7 @@ export const gitProvider = createTRPCRouter({
|
|||||||
z.object({
|
z.object({
|
||||||
owner: z.string(),
|
owner: z.string(),
|
||||||
repo: z.string(),
|
repo: z.string(),
|
||||||
bitbucketProviderId: z.string().optional(),
|
bitbucketId: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
@@ -170,7 +170,7 @@ export const gitProvider = createTRPCRouter({
|
|||||||
getRepositories: protectedProcedure
|
getRepositories: protectedProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
githubProviderId: z.string().optional(),
|
githubId: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.query(async ({ input }) => {
|
.query(async ({ input }) => {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export const apiTraefikConfig = z.object({
|
|||||||
export const apiGetBranches = z.object({
|
export const apiGetBranches = z.object({
|
||||||
repo: z.string().min(1),
|
repo: z.string().min(1),
|
||||||
owner: z.string().min(1),
|
owner: z.string().min(1),
|
||||||
githubProviderId: z.string().optional(),
|
githubId: z.string().optional(),
|
||||||
});
|
});
|
||||||
export const apiModifyTraefikConfig = z.object({
|
export const apiModifyTraefikConfig = z.object({
|
||||||
path: z.string().min(1),
|
path: z.string().min(1),
|
||||||
|
|||||||
@@ -111,18 +111,16 @@ export const cloneRawBitbucketRepository = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface GetBitbucketRepositories {
|
interface GetBitbucketRepositories {
|
||||||
bitbucketProviderId?: string;
|
bitbucketId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getBitbucketRepositories = async (
|
export const getBitbucketRepositories = async (
|
||||||
input: GetBitbucketRepositories,
|
input: GetBitbucketRepositories,
|
||||||
) => {
|
) => {
|
||||||
if (!input.bitbucketProviderId) {
|
if (!input.bitbucketId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const bitbucketProvider = await getBitbucketProvider(
|
const bitbucketProvider = await getBitbucketProvider(input.bitbucketId);
|
||||||
input.bitbucketProviderId,
|
|
||||||
);
|
|
||||||
|
|
||||||
const url = `https://api.bitbucket.org/2.0/repositories/${bitbucketProvider.bitbucketUsername}`;
|
const url = `https://api.bitbucket.org/2.0/repositories/${bitbucketProvider.bitbucketUsername}`;
|
||||||
|
|
||||||
@@ -168,16 +166,14 @@ export const getBitbucketRepositories = async (
|
|||||||
interface GetBitbucketBranches {
|
interface GetBitbucketBranches {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
bitbucketProviderId?: string;
|
bitbucketId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getBitbucketBranches = async (input: GetBitbucketBranches) => {
|
export const getBitbucketBranches = async (input: GetBitbucketBranches) => {
|
||||||
if (!input.bitbucketProviderId) {
|
if (!input.bitbucketId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const bitbucketProvider = await getBitbucketProvider(
|
const bitbucketProvider = await getBitbucketProvider(input.bitbucketId);
|
||||||
input.bitbucketProviderId,
|
|
||||||
);
|
|
||||||
const { owner, repo } = input;
|
const { owner, repo } = input;
|
||||||
const url = `https://api.bitbucket.org/2.0/repositories/${owner}/${repo}/refs/branches`;
|
const url = `https://api.bitbucket.org/2.0/repositories/${owner}/${repo}/refs/branches`;
|
||||||
|
|
||||||
|
|||||||
@@ -176,15 +176,15 @@ export const cloneRawGithubRepository = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface GetGithubRepositories {
|
interface GetGithubRepositories {
|
||||||
githubProviderId?: string;
|
githubId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGithubRepositories = async (input: GetGithubRepositories) => {
|
export const getGithubRepositories = async (input: GetGithubRepositories) => {
|
||||||
if (!input.githubProviderId) {
|
if (!input.githubId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const githubProvider = await getGithubProvider(input.githubProviderId);
|
const githubProvider = await getGithubProvider(input.githubId);
|
||||||
|
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
authStrategy: createAppAuth,
|
authStrategy: createAppAuth,
|
||||||
@@ -207,14 +207,14 @@ export const getGithubRepositories = async (input: GetGithubRepositories) => {
|
|||||||
interface GetGithubBranches {
|
interface GetGithubBranches {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
githubProviderId?: string;
|
githubId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGithubBranches = async (input: GetGithubBranches) => {
|
export const getGithubBranches = async (input: GetGithubBranches) => {
|
||||||
if (!input.githubProviderId) {
|
if (!input.githubId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const githubProvider = await getGithubProvider(input.githubProviderId);
|
const githubProvider = await getGithubProvider(input.githubId);
|
||||||
|
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
authStrategy: createAppAuth,
|
authStrategy: createAppAuth,
|
||||||
|
|||||||
@@ -152,17 +152,17 @@ export const cloneGitlabRepository = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface GetGitlabRepositories {
|
interface GetGitlabRepositories {
|
||||||
gitlabProviderId?: string;
|
gitlabId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGitlabRepositories = async (input: GetGitlabRepositories) => {
|
export const getGitlabRepositories = async (input: GetGitlabRepositories) => {
|
||||||
if (!input.gitlabProviderId) {
|
if (!input.gitlabId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
await refreshGitlabToken(input.gitlabProviderId);
|
await refreshGitlabToken(input.gitlabId);
|
||||||
|
|
||||||
const gitlabProvider = await getGitlabProvider(input.gitlabProviderId);
|
const gitlabProvider = await getGitlabProvider(input.gitlabId);
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
||||||
{
|
{
|
||||||
@@ -192,15 +192,15 @@ export const getGitlabRepositories = async (input: GetGitlabRepositories) => {
|
|||||||
interface GetGitlabBranches {
|
interface GetGitlabBranches {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
gitlabProviderId?: string;
|
gitlabId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGitlabBranches = async (input: GetGitlabBranches) => {
|
export const getGitlabBranches = async (input: GetGitlabBranches) => {
|
||||||
if (!input.gitlabProviderId) {
|
if (!input.gitlabId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const gitlabProvider = await getGitlabProvider(input.gitlabProviderId);
|
const gitlabProvider = await getGitlabProvider(input.gitlabId);
|
||||||
|
|
||||||
const projectResponse = await fetch(
|
const projectResponse = await fetch(
|
||||||
`https://gitlab.com/api/v4/projects?search=${input.repo}&owned=true&page=1&per_page=100`,
|
`https://gitlab.com/api/v4/projects?search=${input.repo}&owned=true&page=1&per_page=100`,
|
||||||
|
|||||||
Reference in New Issue
Block a user