Merge branch 'main' into ENG-3259

This commit is contained in:
x032205
2025-07-17 15:41:19 -04:00
185 changed files with 3501 additions and 178 deletions
@@ -0,0 +1,2 @@
export * from "./queries";
export * from "./types";
@@ -0,0 +1,37 @@
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { appConnectionKeys } from "@app/hooks/api/appConnections";
import { TChecklyAccount } from "./types";
const checklyConnectionKeys = {
all: [...appConnectionKeys.all, "checkly"] as const,
listAccounts: (connectionId: string) =>
[...checklyConnectionKeys.all, "workspace-scopes", connectionId] as const
};
export const useChecklyConnectionListAccounts = (
connectionId: string,
options?: Omit<
UseQueryOptions<
TChecklyAccount[],
unknown,
TChecklyAccount[],
ReturnType<typeof checklyConnectionKeys.listAccounts>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: checklyConnectionKeys.listAccounts(connectionId),
queryFn: async () => {
const { data } = await apiRequest.get<{ accounts: TChecklyAccount[] }>(
`/api/v1/app-connections/checkly/${connectionId}/accounts`
);
return data.accounts;
},
...options
});
};
@@ -0,0 +1,5 @@
export type TChecklyAccount = {
id: string;
name: string;
runtimeId: string;
};
@@ -30,5 +30,7 @@ export enum AppConnection {
Cloudflare = "cloudflare",
Bitbucket = "bitbucket",
Zabbix = "zabbix",
Railway = "railway"
Railway = "railway",
Checkly = "checkly",
Supabase = "supabase"
}
@@ -0,0 +1,2 @@
export * from "./queries";
export * from "./types";
@@ -0,0 +1,37 @@
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { appConnectionKeys } from "@app/hooks/api/appConnections";
import { TSupabaseProject } from "./types";
const supabaseConnectionKeys = {
all: [...appConnectionKeys.all, "supabase"] as const,
listProjects: (connectionId: string) =>
[...supabaseConnectionKeys.all, "workspace-scopes", connectionId] as const
};
export const useSupabaseConnectionListProjects = (
connectionId: string,
options?: Omit<
UseQueryOptions<
TSupabaseProject[],
unknown,
TSupabaseProject[],
ReturnType<typeof supabaseConnectionKeys.listProjects>
>,
"queryKey" | "queryFn"
>
) => {
return useQuery({
queryKey: supabaseConnectionKeys.listProjects(connectionId),
queryFn: async () => {
const { data } = await apiRequest.get<{ projects: TSupabaseProject[] }>(
`/api/v1/app-connections/supabase/${connectionId}/projects`
);
return data.projects;
},
...options
});
};
@@ -0,0 +1,4 @@
export type TSupabaseProject = {
id: string;
name: string;
};
@@ -144,6 +144,14 @@ export type TRailwayConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Railway;
};
export type TChecklyConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Checkly;
};
export type TSupabaseConnectionOption = TAppConnectionOptionBase & {
app: AppConnection.Supabase;
};
export type TAppConnectionOption =
| TAwsConnectionOption
| TGitHubConnectionOption
@@ -174,7 +182,8 @@ export type TAppConnectionOption =
| TCloudflareConnectionOption
| TBitbucketConnectionOption
| TZabbixConnectionOption
| TRailwayConnectionOption;
| TRailwayConnectionOption
| TChecklyConnectionOption;
export type TAppConnectionOptionMap = {
[AppConnection.AWS]: TAwsConnectionOption;
@@ -209,4 +218,6 @@ export type TAppConnectionOptionMap = {
[AppConnection.Bitbucket]: TBitbucketConnectionOption;
[AppConnection.Zabbix]: TZabbixConnectionOption;
[AppConnection.Railway]: TRailwayConnectionOption;
[AppConnection.Checkly]: TChecklyConnectionOption;
[AppConnection.Supabase]: TSupabaseConnectionOption;
};
@@ -0,0 +1,14 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
export enum ChecklyConnectionMethod {
ApiKey = "api-key"
}
export type TChecklyConnection = TRootAppConnection & {
app: AppConnection.Checkly;
method: ChecklyConnectionMethod.ApiKey;
credentials: {
apiKey: string;
};
};
@@ -9,6 +9,7 @@ import { TAzureDevOpsConnection } from "./azure-devops-connection";
import { TAzureKeyVaultConnection } from "./azure-key-vault-connection";
import { TBitbucketConnection } from "./bitbucket-connection";
import { TCamundaConnection } from "./camunda-connection";
import { TChecklyConnection } from "./checkly-connection";
import { TCloudflareConnection } from "./cloudflare-connection";
import { TDatabricksConnection } from "./databricks-connection";
import { TFlyioConnection } from "./flyio-connection";
@@ -27,6 +28,7 @@ import { TOracleDBConnection } from "./oracledb-connection";
import { TPostgresConnection } from "./postgres-connection";
import { TRailwayConnection } from "./railway-connection";
import { TRenderConnection } from "./render-connection";
import { TSupabaseConnection } from "./supabase-connection";
import { TTeamCityConnection } from "./teamcity-connection";
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
import { TVercelConnection } from "./vercel-connection";
@@ -97,7 +99,9 @@ export type TAppConnection =
| TCloudflareConnection
| TBitbucketConnection
| TZabbixConnection
| TRailwayConnection;
| TRailwayConnection
| TChecklyConnection
| TSupabaseConnection;
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
@@ -157,4 +161,6 @@ export type TAppConnectionMap = {
[AppConnection.Bitbucket]: TBitbucketConnection;
[AppConnection.Zabbix]: TZabbixConnection;
[AppConnection.Railway]: TRailwayConnection;
[AppConnection.Checkly]: TChecklyConnection;
[AppConnection.Supabase]: TSupabaseConnection;
};
@@ -0,0 +1,15 @@
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
export enum SupabaseConnectionMethod {
AccessToken = "access-token"
}
export type TSupabaseConnection = TRootAppConnection & {
app: AppConnection.Supabase;
method: SupabaseConnectionMethod.AccessToken;
credentials: {
instanceUrl?: string;
accessKey: string;
};
};
@@ -43,6 +43,7 @@ export type TSecretApprovalRequest = {
isReplicated?: boolean;
slug: string;
createdAt: string;
updatedAt: string;
committerUserId: string;
reviewers: {
userId: string;
+3 -2
View File
@@ -22,9 +22,10 @@ export enum SecretSync {
GitLab = "gitlab",
CloudflarePages = "cloudflare-pages",
CloudflareWorkers = "cloudflare-workers",
Supabase = "supabase",
Zabbix = "zabbix",
Railway = "railway"
Railway = "railway",
Checkly = "checkly"
}
export enum SecretSyncStatus {
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretSync } from "@app/hooks/api/secretSyncs";
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
export type TChecklySync = TRootSecretSync & {
destination: SecretSync.Checkly;
destinationConfig: {
accountId: string;
accountName: string;
};
connection: {
app: AppConnection.Checkly;
name: string;
id: string;
};
};
@@ -9,6 +9,7 @@ import { TAzureAppConfigurationSync } from "./azure-app-configuration-sync";
import { TAzureDevOpsSync } from "./azure-devops-sync";
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
import { TCamundaSync } from "./camunda-sync";
import { TChecklySync } from "./checkly-sync";
import { TCloudflarePagesSync } from "./cloudflare-pages-sync";
import { TCloudflareWorkersSync } from "./cloudflare-workers-sync";
import { TDatabricksSync } from "./databricks-sync";
@@ -21,6 +22,7 @@ import { THerokuSync } from "./heroku-sync";
import { THumanitecSync } from "./humanitec-sync";
import { TOCIVaultSync } from "./oci-vault-sync";
import { TRailwaySync } from "./railway-sync";
import { TSupabaseSync } from "./supabase";
import { TTeamCitySync } from "./teamcity-sync";
import { TTerraformCloudSync } from "./terraform-cloud-sync";
import { TVercelSync } from "./vercel-sync";
@@ -59,7 +61,9 @@ export type TSecretSync =
| TCloudflarePagesSync
| TCloudflareWorkersSync
| TZabbixSync
| TRailwaySync;
| TRailwaySync
| TChecklySync
| TSupabaseSync;
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */
import { AppConnection } from "@app/hooks/api/appConnections/enums";
import { SecretSync } from "@app/hooks/api/secretSyncs";
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
export type TSupabaseSync = TRootSecretSync & {
destination: SecretSync.Supabase;
destinationConfig: {
projectId: string;
projectName: string;
};
connection: {
app: AppConnection.Supabase;
name: string;
id: string;
};
};
@@ -17,8 +17,8 @@ export type SubscriptionPlan = {
rbac: boolean;
secretVersioning: boolean;
slug: string;
secretApproval: string;
secretRotation: string;
secretApproval: boolean;
secretRotation: boolean;
tier: number;
workspaceLimit: number;
workspacesUsed: number;
@@ -0,0 +1,60 @@
import { useMemo } from "react";
import { useSubscription, useWorkspace } from "@app/context";
import { useGetAccessApprovalPolicies } from "@app/hooks/api";
const matchesPath = (folderPath: string, pattern: string) => {
const normalizedPath = folderPath === "/" ? "/" : folderPath.replace(/\/$/, "");
const normalizedPattern = pattern === "/" ? "/" : pattern.replace(/\/$/, "");
if (normalizedPath === normalizedPattern) {
return true;
}
if (normalizedPattern.endsWith("/**")) {
const basePattern = normalizedPattern.slice(0, -3); // Remove "/**"
// Handle root wildcard "/**"
if (basePattern === "") {
return true;
}
// Check if path starts with the base pattern
if (normalizedPath === basePattern) {
return true;
}
// Check if path is a subdirectory of the base pattern
return normalizedPath.startsWith(`${basePattern}/`);
}
return false;
};
type Params = {
secretPath: string;
environment: string;
};
export const usePathAccessPolicies = ({ secretPath, environment }: Params) => {
const { currentWorkspace } = useWorkspace();
const { subscription } = useSubscription();
const { data: policies } = useGetAccessApprovalPolicies({
projectSlug: currentWorkspace.slug,
options: {
enabled: subscription.secretApproval
}
});
return useMemo(() => {
const pathPolicies = policies?.filter(
(policy) =>
policy.environment.slug === environment && matchesPath(secretPath, policy.secretPath)
);
return {
hasPathPolicies: subscription.secretApproval && Boolean(pathPolicies?.length),
pathPolicies
};
}, [secretPath, environment, policies, subscription.secretApproval]);
};