Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(app-connection): BitBucket app connection

x03220562ad82f7b129
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 4405728b2f..b457eafb37 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2268,6 +2268,10 @@ export const AppConnections = {
accessToken: "The Access Token used to access GitLab.",
code: "The OAuth code to use to connect with GitLab.",
accessTokenType: "The type of token used to connect with GitLab."
+ },
+ BITBUCKET: {
+ email: "The email used to access BitBucket.",
+ apiToken: "The API token used to access BitBucket."
}
}
};
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
index 6160828f4f..be991703c2 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-router.ts
@@ -31,6 +31,10 @@ import {
AzureKeyVaultConnectionListItemSchema,
SanitizedAzureKeyVaultConnectionSchema
} from "@app/services/app-connection/azure-key-vault";
+import {
+ BitBucketConnectionListItemSchema,
+ SanitizedBitBucketConnectionSchema
+} from "@app/services/app-connection/bitbucket";
import {
CamundaConnectionListItemSchema,
SanitizedCamundaConnectionSchema
@@ -116,7 +120,8 @@ const SanitizedAppConnectionSchema = z.union([
...SanitizedRenderConnectionSchema.options,
...SanitizedFlyioConnectionSchema.options,
...SanitizedGitLabConnectionSchema.options,
- ...SanitizedCloudflareConnectionSchema.options
+ ...SanitizedCloudflareConnectionSchema.options,
+ ...SanitizedBitBucketConnectionSchema.options
]);
const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
@@ -148,7 +153,8 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
RenderConnectionListItemSchema,
FlyioConnectionListItemSchema,
GitLabConnectionListItemSchema,
- CloudflareConnectionListItemSchema
+ CloudflareConnectionListItemSchema,
+ BitBucketConnectionListItemSchema
]);
export const registerAppConnectionRouter = async (server: FastifyZodProvider) => {
diff --git a/backend/src/server/routes/v1/app-connection-routers/bitbucket-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/bitbucket-connection-router.ts
new file mode 100644
index 0000000000..bcef795c1c
--- /dev/null
+++ b/backend/src/server/routes/v1/app-connection-routers/bitbucket-connection-router.ts
@@ -0,0 +1,18 @@
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ CreateBitBucketConnectionSchema,
+ SanitizedBitBucketConnectionSchema,
+ UpdateBitBucketConnectionSchema
+} from "@app/services/app-connection/bitbucket";
+
+import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
+
+export const registerBitBucketConnectionRouter = async (server: FastifyZodProvider) => {
+ registerAppConnectionEndpoints({
+ app: AppConnection.BitBucket,
+ server,
+ sanitizedResponseSchema: SanitizedBitBucketConnectionSchema,
+ createSchema: CreateBitBucketConnectionSchema,
+ updateSchema: UpdateBitBucketConnectionSchema
+ });
+};
diff --git a/backend/src/server/routes/v1/app-connection-routers/index.ts b/backend/src/server/routes/v1/app-connection-routers/index.ts
index cd4ccd7289..e164a90882 100644
--- a/backend/src/server/routes/v1/app-connection-routers/index.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/index.ts
@@ -9,6 +9,7 @@ import { registerAzureAppConfigurationConnectionRouter } from "./azure-app-confi
import { registerAzureClientSecretsConnectionRouter } from "./azure-client-secrets-connection-router";
import { registerAzureDevOpsConnectionRouter } from "./azure-devops-connection-router";
import { registerAzureKeyVaultConnectionRouter } from "./azure-key-vault-connection-router";
+import { registerBitBucketConnectionRouter } from "./bitbucket-connection-router";
import { registerCamundaConnectionRouter } from "./camunda-connection-router";
import { registerCloudflareConnectionRouter } from "./cloudflare-connection-router";
import { registerDatabricksConnectionRouter } from "./databricks-connection-router";
@@ -62,5 +63,6 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
[AppConnection.Render]: registerRenderConnectionRouter,
[AppConnection.Flyio]: registerFlyioConnectionRouter,
[AppConnection.GitLab]: registerGitLabConnectionRouter,
- [AppConnection.Cloudflare]: registerCloudflareConnectionRouter
+ [AppConnection.Cloudflare]: registerCloudflareConnectionRouter,
+ [AppConnection.BitBucket]: registerBitBucketConnectionRouter
};
diff --git a/backend/src/services/app-connection/app-connection-enums.ts b/backend/src/services/app-connection/app-connection-enums.ts
index 11b84b5adb..93b5734729 100644
--- a/backend/src/services/app-connection/app-connection-enums.ts
+++ b/backend/src/services/app-connection/app-connection-enums.ts
@@ -27,7 +27,8 @@ export enum AppConnection {
Render = "render",
Flyio = "flyio",
GitLab = "gitlab",
- Cloudflare = "cloudflare"
+ Cloudflare = "cloudflare",
+ BitBucket = "bitbucket"
}
export enum AWSRegion {
diff --git a/backend/src/services/app-connection/app-connection-fns.ts b/backend/src/services/app-connection/app-connection-fns.ts
index 78f6b99b5f..431576a920 100644
--- a/backend/src/services/app-connection/app-connection-fns.ts
+++ b/backend/src/services/app-connection/app-connection-fns.ts
@@ -50,6 +50,11 @@ import {
getAzureKeyVaultConnectionListItem,
validateAzureKeyVaultConnectionCredentials
} from "./azure-key-vault";
+import {
+ BitBucketConnectionMethod,
+ getBitBucketConnectionListItem,
+ validateBitBucketConnectionCredentials
+} from "./bitbucket";
import { CamundaConnectionMethod, getCamundaConnectionListItem, validateCamundaConnectionCredentials } from "./camunda";
import { CloudflareConnectionMethod } from "./cloudflare/cloudflare-connection-enum";
import {
@@ -136,7 +141,8 @@ export const listAppConnectionOptions = () => {
getRenderConnectionListItem(),
getFlyioConnectionListItem(),
getGitLabConnectionListItem(),
- getCloudflareConnectionListItem()
+ getCloudflareConnectionListItem(),
+ getBitBucketConnectionListItem()
].sort((a, b) => a.name.localeCompare(b.name));
};
@@ -216,7 +222,8 @@ export const validateAppConnectionCredentials = async (
[AppConnection.Render]: validateRenderConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.Flyio]: validateFlyioConnectionCredentials as TAppConnectionCredentialsValidator,
[AppConnection.GitLab]: validateGitLabConnectionCredentials as TAppConnectionCredentialsValidator,
- [AppConnection.Cloudflare]: validateCloudflareConnectionCredentials as TAppConnectionCredentialsValidator
+ [AppConnection.Cloudflare]: validateCloudflareConnectionCredentials as TAppConnectionCredentialsValidator,
+ [AppConnection.BitBucket]: validateBitBucketConnectionCredentials as TAppConnectionCredentialsValidator
};
return VALIDATE_APP_CONNECTION_CREDENTIALS_MAP[appConnection.app](appConnection);
@@ -253,6 +260,7 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
case VercelConnectionMethod.ApiToken:
case OnePassConnectionMethod.ApiToken:
case CloudflareConnectionMethod.APIToken:
+ case BitBucketConnectionMethod.ApiToken:
return "API Token";
case PostgresConnectionMethod.UsernameAndPassword:
case MsSqlConnectionMethod.UsernameAndPassword:
@@ -332,7 +340,8 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
[AppConnection.Render]: platformManagedCredentialsNotSupported,
[AppConnection.Flyio]: platformManagedCredentialsNotSupported,
[AppConnection.GitLab]: platformManagedCredentialsNotSupported,
- [AppConnection.Cloudflare]: platformManagedCredentialsNotSupported
+ [AppConnection.Cloudflare]: platformManagedCredentialsNotSupported,
+ [AppConnection.BitBucket]: platformManagedCredentialsNotSupported
};
export const enterpriseAppCheck = async (
diff --git a/backend/src/services/app-connection/app-connection-maps.ts b/backend/src/services/app-connection/app-connection-maps.ts
index 9c0a3b5b8e..a2d953d07a 100644
--- a/backend/src/services/app-connection/app-connection-maps.ts
+++ b/backend/src/services/app-connection/app-connection-maps.ts
@@ -29,7 +29,8 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {
[AppConnection.Render]: "Render",
[AppConnection.Flyio]: "Fly.io",
[AppConnection.GitLab]: "GitLab",
- [AppConnection.Cloudflare]: "Cloudflare"
+ [AppConnection.Cloudflare]: "Cloudflare",
+ [AppConnection.BitBucket]: "BitBucket"
};
export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanType> = {
@@ -61,5 +62,6 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp
[AppConnection.Render]: AppConnectionPlanType.Regular,
[AppConnection.Flyio]: AppConnectionPlanType.Regular,
[AppConnection.GitLab]: AppConnectionPlanType.Regular,
- [AppConnection.Cloudflare]: AppConnectionPlanType.Regular
+ [AppConnection.Cloudflare]: AppConnectionPlanType.Regular,
+ [AppConnection.BitBucket]: AppConnectionPlanType.Regular
};
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index bcadd96364..6e2bc2c6f2 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -45,6 +45,8 @@ import { azureClientSecretsConnectionService } from "./azure-client-secrets/azur
import { ValidateAzureDevOpsConnectionCredentialsSchema } from "./azure-devops/azure-devops-schemas";
import { azureDevOpsConnectionService } from "./azure-devops/azure-devops-service";
import { ValidateAzureKeyVaultConnectionCredentialsSchema } from "./azure-key-vault";
+import { ValidateBitBucketConnectionCredentialsSchema } from "./bitbucket";
+import { bitBucketConnectionService } from "./bitbucket/bitbucket-connection-service";
import { ValidateCamundaConnectionCredentialsSchema } from "./camunda";
import { camundaConnectionService } from "./camunda/camunda-connection-service";
import { ValidateCloudflareConnectionCredentialsSchema } from "./cloudflare/cloudflare-connection-schema";
@@ -119,7 +121,8 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
[AppConnection.Render]: ValidateRenderConnectionCredentialsSchema,
[AppConnection.Flyio]: ValidateFlyioConnectionCredentialsSchema,
[AppConnection.GitLab]: ValidateGitLabConnectionCredentialsSchema,
- [AppConnection.Cloudflare]: ValidateCloudflareConnectionCredentialsSchema
+ [AppConnection.Cloudflare]: ValidateCloudflareConnectionCredentialsSchema,
+ [AppConnection.BitBucket]: ValidateBitBucketConnectionCredentialsSchema
};
export const appConnectionServiceFactory = ({
@@ -529,6 +532,7 @@ export const appConnectionServiceFactory = ({
render: renderConnectionService(connectAppConnectionById),
flyio: flyioConnectionService(connectAppConnectionById),
gitlab: gitlabConnectionService(connectAppConnectionById, appConnectionDAL, kmsService),
- cloudflare: cloudflareConnectionService(connectAppConnectionById)
+ cloudflare: cloudflareConnectionService(connectAppConnectionById),
+ bitbucket: bitBucketConnectionService(connectAppConnectionById)
};
};
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index 0295a80b46..2dbacbbd4e 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -56,6 +56,12 @@ import {
TAzureKeyVaultConnectionInput,
TValidateAzureKeyVaultConnectionCredentialsSchema
} from "./azure-key-vault";
+import {
+ TBitBucketConnection,
+ TBitBucketConnectionConfig,
+ TBitBucketConnectionInput,
+ TValidateBitBucketConnectionCredentialsSchema
+} from "./bitbucket";
import {
TCamundaConnection,
TCamundaConnectionConfig,
@@ -196,6 +202,7 @@ export type TAppConnection = { id: string } & (
| TFlyioConnection
| TGitLabConnection
| TCloudflareConnection
+ | TBitBucketConnection
);
export type TAppConnectionRaw = NonNullable<Awaited<ReturnType<TAppConnectionDALFactory["findById"]>>>;
@@ -232,6 +239,7 @@ export type TAppConnectionInput = { id: string } & (
| TFlyioConnectionInput
| TGitLabConnectionInput
| TCloudflareConnectionInput
+ | TBitBucketConnectionInput
);
export type TSqlConnectionInput =
@@ -275,7 +283,8 @@ export type TAppConnectionConfig =
| TRenderConnectionConfig
| TFlyioConnectionConfig
| TGitLabConnectionConfig
- | TCloudflareConnectionConfig;
+ | TCloudflareConnectionConfig
+ | TBitBucketConnectionConfig;
export type TValidateAppConnectionCredentialsSchema =
| TValidateAwsConnectionCredentialsSchema
@@ -306,7 +315,8 @@ export type TValidateAppConnectionCredentialsSchema =
| TValidateRenderConnectionCredentialsSchema
| TValidateFlyioConnectionCredentialsSchema
| TValidateGitLabConnectionCredentialsSchema
- | TValidateCloudflareConnectionCredentialsSchema;
+ | TValidateCloudflareConnectionCredentialsSchema
+ | TValidateBitBucketConnectionCredentialsSchema;
export type TListAwsConnectionKmsKeys = {
connectionId: string;
diff --git a/backend/src/services/app-connection/bitbucket/bitbucket-connection-enums.ts b/backend/src/services/app-connection/bitbucket/bitbucket-connection-enums.ts
new file mode 100644
index 0000000000..629c5b6d72
--- /dev/null
+++ b/backend/src/services/app-connection/bitbucket/bitbucket-connection-enums.ts
@@ -0,0 +1,3 @@
+export enum BitBucketConnectionMethod {
+ ApiToken = "api-token"
+}
diff --git a/backend/src/services/app-connection/bitbucket/bitbucket-connection-fns.ts b/backend/src/services/app-connection/bitbucket/bitbucket-connection-fns.ts
new file mode 100644
index 0000000000..45ce2c0b58
--- /dev/null
+++ b/backend/src/services/app-connection/bitbucket/bitbucket-connection-fns.ts
@@ -0,0 +1,40 @@
+import { AxiosError } from "axios";
+
+import { request } from "@app/lib/config/request";
+import { BadRequestError } from "@app/lib/errors";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+
+import { BitBucketConnectionMethod } from "./bitbucket-connection-enums";
+import { TBitBucketConnectionConfig } from "./bitbucket-connection-types";
+
+export const getBitBucketConnectionListItem = () => {
+ return {
+ name: "BitBucket" as const,
+ app: AppConnection.BitBucket as const,
+ methods: Object.values(BitBucketConnectionMethod) as [BitBucketConnectionMethod.ApiToken]
+ };
+};
+
+export const validateBitBucketConnectionCredentials = async (config: TBitBucketConnectionConfig) => {
+ const { email, apiToken } = config.credentials;
+
+ try {
+ await request.get("https://api.bitbucket.org/2.0/user", {
+ headers: {
+ Authorization: `Basic ${Buffer.from(`${email}:${apiToken}`).toString("base64")}`,
+ Accept: "application/json"
+ }
+ });
+ } catch (error: unknown) {
+ if (error instanceof AxiosError) {
+ throw new BadRequestError({
+ message: `Failed to validate credentials: ${error.message || "Unknown error"}`
+ });
+ }
+ throw new BadRequestError({
+ message: "Unable to validate connection: verify credentials"
+ });
+ }
+
+ return config.credentials;
+};
diff --git a/backend/src/services/app-connection/bitbucket/bitbucket-connection-schemas.ts b/backend/src/services/app-connection/bitbucket/bitbucket-connection-schemas.ts
new file mode 100644
index 0000000000..a331db8cc2
--- /dev/null
+++ b/backend/src/services/app-connection/bitbucket/bitbucket-connection-schemas.ts
@@ -0,0 +1,61 @@
+import z from "zod";
+
+import { AppConnections } from "@app/lib/api-docs";
+import { AppConnection } from "@app/services/app-connection/app-connection-enums";
+import {
+ BaseAppConnectionSchema,
+ GenericCreateAppConnectionFieldsSchema,
+ GenericUpdateAppConnectionFieldsSchema
+} from "@app/services/app-connection/app-connection-schemas";
+
+import { BitBucketConnectionMethod } from "./bitbucket-connection-enums";
+
+export const BitBucketConnectionAccessTokenCredentialsSchema = z.object({
+ apiToken: z.string().trim().min(1, "API Token required").describe(AppConnections.CREDENTIALS.BITBUCKET.apiToken),
+ email: z.string().email().trim().min(1, "Email required").describe(AppConnections.CREDENTIALS.BITBUCKET.email)
+});
+
+const BaseBitBucketConnectionSchema = BaseAppConnectionSchema.extend({ app: z.literal(AppConnection.BitBucket) });
+
+export const BitBucketConnectionSchema = BaseBitBucketConnectionSchema.extend({
+ method: z.literal(BitBucketConnectionMethod.ApiToken),
+ credentials: BitBucketConnectionAccessTokenCredentialsSchema
+});
+
+export const SanitizedBitBucketConnectionSchema = z.discriminatedUnion("method", [
+ BaseBitBucketConnectionSchema.extend({
+ method: z.literal(BitBucketConnectionMethod.ApiToken),
+ credentials: BitBucketConnectionAccessTokenCredentialsSchema.pick({
+ email: true
+ })
+ })
+]);
+
+export const ValidateBitBucketConnectionCredentialsSchema = z.discriminatedUnion("method", [
+ z.object({
+ method: z
+ .literal(BitBucketConnectionMethod.ApiToken)
+ .describe(AppConnections.CREATE(AppConnection.BitBucket).method),
+ credentials: BitBucketConnectionAccessTokenCredentialsSchema.describe(
+ AppConnections.CREATE(AppConnection.BitBucket).credentials
+ )
+ })
+]);
+
+export const CreateBitBucketConnectionSchema = ValidateBitBucketConnectionCredentialsSchema.and(
+ GenericCreateAppConnectionFieldsSchema(AppConnection.BitBucket)
+);
+
+export const UpdateBitBucketConnectionSchema = z
+ .object({
+ credentials: BitBucketConnectionAccessTokenCredentialsSchema.optional().describe(
+ AppConnections.UPDATE(AppConnection.BitBucket).credentials
+ )
+ })
+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.BitBucket));
+
+export const BitBucketConnectionListItemSchema = z.object({
+ name: z.literal("BitBucket"),
+ app: z.literal(AppConnection.BitBucket),
+ methods: z.nativeEnum(BitBucketConnectionMethod).array()
+});
diff --git a/backend/src/services/app-connection/bitbucket/bitbucket-connection-service.ts b/backend/src/services/app-connection/bitbucket/bitbucket-connection-service.ts
new file mode 100644
index 0000000000..16d3edea4b
--- /dev/null
+++ b/backend/src/services/app-connection/bitbucket/bitbucket-connection-service.ts
@@ -0,0 +1,15 @@
+import { OrgServiceActor } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+// import { listBitBucketVaults } from "./bitbucket-connection-fns";
+import { TBitBucketConnection } from "./bitbucket-connection-types";
+
+type TGetAppConnectionFunc = (
+ app: AppConnection,
+ connectionId: string,
+ actor: OrgServiceActor
+) => Promise<TBitBucketConnection>;
+
+export const bitBucketConnectionService = (_getAppConnection: TGetAppConnectionFunc) => {
+ return {};
+};
diff --git a/backend/src/services/app-connection/bitbucket/bitbucket-connection-types.ts b/backend/src/services/app-connection/bitbucket/bitbucket-connection-types.ts
new file mode 100644
index 0000000000..a59fdb3972
--- /dev/null
+++ b/backend/src/services/app-connection/bitbucket/bitbucket-connection-types.ts
@@ -0,0 +1,38 @@
+import z from "zod";
+
+import { DiscriminativePick } from "@app/lib/types";
+
+import { AppConnection } from "../app-connection-enums";
+import {
+ BitBucketConnectionSchema,
+ CreateBitBucketConnectionSchema,
+ ValidateBitBucketConnectionCredentialsSchema
+} from "./bitbucket-connection-schemas";
+
+export type TBitBucketConnection = z.infer<typeof BitBucketConnectionSchema>;
+
+export type TBitBucketConnectionInput = z.infer<typeof CreateBitBucketConnectionSchema> & {
+ app: AppConnection.BitBucket;
+};
+
+export type TValidateBitBucketConnectionCredentialsSchema = typeof ValidateBitBucketConnectionCredentialsSchema;
+
+export type TBitBucketConnectionConfig = DiscriminativePick<
+ TBitBucketConnectionInput,
+ "method" | "app" | "credentials"
+> & {
+ orgId: string;
+};
+
+export type TBitBucketVault = {
+ id: string;
+ name: string;
+ type: string;
+ items: number;
+
+ attributeVersion: number;
+ contentVersion: number;
+
+ createdAt: string;
+ updatedAt: string;
+};
diff --git a/backend/src/services/app-connection/bitbucket/index.ts b/backend/src/services/app-connection/bitbucket/index.ts
new file mode 100644
index 0000000000..634342ba78
--- /dev/null
+++ b/backend/src/services/app-connection/bitbucket/index.ts
@@ -0,0 +1,4 @@
+export * from "./bitbucket-connection-enums";
+export * from "./bitbucket-connection-fns";
+export * from "./bitbucket-connection-schemas";
+export * from "./bitbucket-connection-types";
diff --git a/frontend/src/helpers/appConnections.ts b/frontend/src/helpers/appConnections.ts
index e1fd9e365f..972247bf4c 100644
--- a/frontend/src/helpers/appConnections.ts
+++ b/frontend/src/helpers/appConnections.ts
@@ -42,6 +42,7 @@ import {
import { HerokuConnectionMethod } from "@app/hooks/api/appConnections/types/heroku-connection";
import { OCIConnectionMethod } from "@app/hooks/api/appConnections/types/oci-connection";
import { RenderConnectionMethod } from "@app/hooks/api/appConnections/types/render-connection";
+import { BitBucketConnectionMethod } from "@app/hooks/api/appConnections/types/bitbucket-connection";
export const APP_CONNECTION_MAP: Record<
AppConnection,
@@ -88,7 +89,8 @@ export const APP_CONNECTION_MAP: Record<
[AppConnection.Render]: { name: "Render", image: "Render.png" },
[AppConnection.Flyio]: { name: "Fly.io", image: "Flyio.svg" },
[AppConnection.Gitlab]: { name: "GitLab", image: "GitLab.png" },
- [AppConnection.Cloudflare]: { name: "Cloudflare", image: "Cloudflare.png" }
+ [AppConnection.Cloudflare]: { name: "Cloudflare", image: "Cloudflare.png" },
+ [AppConnection.BitBucket]: { name: "BitBucket", image: "BitBucket.png" }
};
export const getAppConnectionMethodDetails = (method: TAppConnection["method"]) => {
@@ -120,6 +122,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
case VercelConnectionMethod.ApiToken:
case OnePassConnectionMethod.ApiToken:
case CloudflareConnectionMethod.ApiToken:
+ case BitBucketConnectionMethod.ApiToken:
return { name: "API Token", icon: faKey };
case PostgresConnectionMethod.UsernameAndPassword:
case MsSqlConnectionMethod.UsernameAndPassword:
diff --git a/frontend/src/hooks/api/appConnections/bitbucket/index.ts b/frontend/src/hooks/api/appConnections/bitbucket/index.ts
new file mode 100644
index 0000000000..2c1906d369
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/bitbucket/index.ts
@@ -0,0 +1,2 @@
+export * from "./queries";
+export * from "./types";
diff --git a/frontend/src/hooks/api/appConnections/bitbucket/queries.tsx b/frontend/src/hooks/api/appConnections/bitbucket/queries.tsx
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frontend/src/hooks/api/appConnections/bitbucket/types.ts b/frontend/src/hooks/api/appConnections/bitbucket/types.ts
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/frontend/src/hooks/api/appConnections/enums.ts b/frontend/src/hooks/api/appConnections/enums.ts
index 8097720a72..87e08ae361 100644
--- a/frontend/src/hooks/api/appConnections/enums.ts
+++ b/frontend/src/hooks/api/appConnections/enums.ts
@@ -27,5 +27,6 @@ export enum AppConnection {
Render = "render",
Flyio = "flyio",
Gitlab = "gitlab",
- Cloudflare = "cloudflare"
+ Cloudflare = "cloudflare",
+ BitBucket = "bitbucket"
}
diff --git a/frontend/src/hooks/api/appConnections/types/app-options.ts b/frontend/src/hooks/api/appConnections/types/app-options.ts
index b71370da7b..84af3dbe62 100644
--- a/frontend/src/hooks/api/appConnections/types/app-options.ts
+++ b/frontend/src/hooks/api/appConnections/types/app-options.ts
@@ -132,6 +132,10 @@ export type TCloudflareConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Cloudflare;
};
+export type TBitBucketConnectionOption = TAppConnectionOptionBase & {
+ app: AppConnection.BitBucket;
+};
+
export type TAppConnectionOption =
| TAwsConnectionOption
| TGitHubConnectionOption
@@ -159,7 +163,8 @@ export type TAppConnectionOption =
| TRenderConnectionOption
| TFlyioConnectionOption
| TGitlabConnectionOption
- | TCloudflareConnectionOption;
+ | TCloudflareConnectionOption
+ | TBitBucketConnectionOption;
export type TAppConnectionOptionMap = {
[AppConnection.AWS]: TAwsConnectionOption;
@@ -191,4 +196,5 @@ export type TAppConnectionOptionMap = {
[AppConnection.Flyio]: TFlyioConnectionOption;
[AppConnection.Gitlab]: TGitlabConnectionOption;
[AppConnection.Cloudflare]: TCloudflareConnectionOption;
+ [AppConnection.BitBucket]: TBitBucketConnectionOption;
};
diff --git a/frontend/src/hooks/api/appConnections/types/bitbucket-connection.ts b/frontend/src/hooks/api/appConnections/types/bitbucket-connection.ts
new file mode 100644
index 0000000000..5a47401053
--- /dev/null
+++ b/frontend/src/hooks/api/appConnections/types/bitbucket-connection.ts
@@ -0,0 +1,14 @@
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
+
+export enum BitBucketConnectionMethod {
+ ApiToken = "api-token"
+}
+
+export type TBitBucketConnection = TRootAppConnection & { app: AppConnection.BitBucket } & {
+ method: BitBucketConnectionMethod.ApiToken;
+ credentials: {
+ email: string;
+ apiToken: string;
+ };
+};
diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.ts
index 2eaebb45a5..6c0da9b698 100644
--- a/frontend/src/hooks/api/appConnections/types/index.ts
+++ b/frontend/src/hooks/api/appConnections/types/index.ts
@@ -7,6 +7,7 @@ import { TAzureAppConfigurationConnection } from "./azure-app-configuration-conn
import { TAzureClientSecretsConnection } from "./azure-client-secrets-connection";
import { TAzureDevOpsConnection } from "./azure-devops-connection";
import { TAzureKeyVaultConnection } from "./azure-key-vault-connection";
+import { TBitBucketConnection } from "./bitbucket-connection";
import { TCamundaConnection } from "./camunda-connection";
import { TCloudflareConnection } from "./cloudflare-connection";
import { TDatabricksConnection } from "./databricks-connection";
@@ -59,6 +60,7 @@ export * from "./teamcity-connection";
export * from "./terraform-cloud-connection";
export * from "./vercel-connection";
export * from "./windmill-connection";
+export * from "./bitbucket-connection";
export type TAppConnection =
| TAwsConnection
@@ -89,7 +91,8 @@ export type TAppConnection =
| TRenderConnection
| TFlyioConnection
| TGitLabConnection
- | TCloudflareConnection;
+ | TCloudflareConnection
+ | TBitBucketConnection;
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
@@ -146,4 +149,5 @@ export type TAppConnectionMap = {
[AppConnection.Flyio]: TFlyioConnection;
[AppConnection.Gitlab]: TGitLabConnection;
[AppConnection.Cloudflare]: TCloudflareConnection;
+ [AppConnection.BitBucket]: TBitBucketConnection;
};
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
index 52abfee5d0..92b23ce3e8 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
@@ -38,6 +38,7 @@ import { TeamCityConnectionForm } from "./TeamCityConnectionForm";
import { TerraformCloudConnectionForm } from "./TerraformCloudConnectionForm";
import { VercelConnectionForm } from "./VercelConnectionForm";
import { WindmillConnectionForm } from "./WindmillConnectionForm";
+import { BitBucketConnectionForm } from "./BitBucketConnectionForm";
type FormProps = {
onComplete: (appConnection: TAppConnection) => void;
@@ -134,6 +135,8 @@ const CreateForm = ({ app, onComplete }: CreateFormProps) => {
return <GitLabConnectionForm onSubmit={onSubmit} />;
case AppConnection.Cloudflare:
return <CloudflareConnectionForm onSubmit={onSubmit} />;
+ case AppConnection.BitBucket:
+ return <BitBucketConnectionForm onSubmit={onSubmit} />;
default:
throw new Error(`Unhandled App ${app}`);
}
@@ -228,6 +231,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
return <GitLabConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
case AppConnection.Cloudflare:
return <CloudflareConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
+ case AppConnection.BitBucket:
+ return <BitBucketConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
default:
throw new Error(`Unhandled App ${(appConnection as TAppConnection).app}`);
}
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/BitBucketConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/BitBucketConnectionForm.tsx
new file mode 100644
index 0000000000..e700d7c08f
--- /dev/null
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/BitBucketConnectionForm.tsx
@@ -0,0 +1,144 @@
+import { Controller, FormProvider, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+
+import {
+ Button,
+ FormControl,
+ Input,
+ ModalClose,
+ SecretInput,
+ Select,
+ SelectItem
+} from "@app/components/v2";
+import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
+import { BitBucketConnectionMethod, TBitBucketConnection } from "@app/hooks/api/appConnections";
+import { AppConnection } from "@app/hooks/api/appConnections/enums";
+
+import {
+ genericAppConnectionFieldsSchema,
+ GenericAppConnectionsFields
+} from "./GenericAppConnectionFields";
+
+type Props = {
+ appConnection?: TBitBucketConnection;
+ onSubmit: (formData: FormData) => void;
+};
+
+const rootSchema = genericAppConnectionFieldsSchema.extend({
+ app: z.literal(AppConnection.BitBucket)
+});
+
+const formSchema = z.discriminatedUnion("method", [
+ rootSchema.extend({
+ method: z.literal(BitBucketConnectionMethod.ApiToken),
+ credentials: z.object({
+ email: z.string().email().trim().min(1, "Email required"),
+ apiToken: z.string().trim().min(1, "API Token required")
+ })
+ })
+]);
+
+type FormData = z.infer<typeof formSchema>;
+
+export const BitBucketConnectionForm = ({ appConnection, onSubmit }: Props) => {
+ const isUpdate = Boolean(appConnection);
+
+ const form = useForm<FormData>({
+ resolver: zodResolver(formSchema),
+ defaultValues: appConnection ?? {
+ app: AppConnection.BitBucket,
+ method: BitBucketConnectionMethod.ApiToken
+ }
+ });
+
+ const {
+ handleSubmit,
+ control,
+ formState: { isSubmitting, isDirty }
+ } = form;
+
+ return (
+ <FormProvider {...form}>
+ <form onSubmit={handleSubmit(onSubmit)}>
+ {!isUpdate && <GenericAppConnectionsFields />}
+ <Controller
+ name="method"
+ control={control}
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ tooltipText={`The method you would like to use to connect with ${
+ APP_CONNECTION_MAP[AppConnection.BitBucket].name
+ }. This field cannot be changed after creation.`}
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="Method"
+ >
+ <Select
+ isDisabled={isUpdate}
+ value={value}
+ onValueChange={(val) => onChange(val)}
+ className="w-full border border-mineshaft-500"
+ position="popper"
+ dropdownContainerClassName="max-w-none"
+ >
+ {Object.values(BitBucketConnectionMethod).map((method) => {
+ return (
+ <SelectItem value={method} key={method}>
+ {getAppConnectionMethodDetails(method).name}{" "}
+ </SelectItem>
+ );
+ })}
+ </Select>
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.email"
+ control={control}
+ shouldUnregister
+ render={({ field, fieldState: { error } }) => (
+ <FormControl errorText={error?.message} isError={Boolean(error?.message)} label="Email">
+ <Input {...field} placeholder="[email protected]" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ name="credentials.apiToken"
+ control={control}
+ shouldUnregister
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ label="API Token"
+ >
+ <SecretInput
+ containerClassName="text-gray-400 group-focus-within:!border-primary-400/50 border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ />
+ </FormControl>
+ )}
+ />
+ <div className="mt-8 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ colorSchema="secondary"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting || !isDirty}
+ >
+ {isUpdate ? "Update Credentials" : "Connect to BitBucket"}
+ </Button>
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
+ </Button>
+ </ModalClose>
+ </div>
+ </form>
+ </FormProvider>
+ );
+};