mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 17:29:14 +00:00
feat(secret-sync): Cloudflare Workers
This commit is contained in:
@@ -3,7 +3,7 @@ import { Knex } from "knex";
|
|||||||
|
|
||||||
import { chunkArray } from "@app/lib/fn";
|
import { chunkArray } from "@app/lib/fn";
|
||||||
import { selectAllTableCols } from "@app/lib/knex";
|
import { selectAllTableCols } from "@app/lib/knex";
|
||||||
import { logger, initLogger } from "@app/lib/logger";
|
import { initLogger, logger } from "@app/lib/logger";
|
||||||
|
|
||||||
import { SecretType, TableName } from "../schemas";
|
import { SecretType, TableName } from "../schemas";
|
||||||
|
|
||||||
|
|||||||
@@ -2469,6 +2469,9 @@ export const SecretSyncs = {
|
|||||||
projectName: "The name of the Cloudflare Pages project to sync secrets to.",
|
projectName: "The name of the Cloudflare Pages project to sync secrets to.",
|
||||||
environment: "The environment of the Cloudflare Pages project to sync secrets to."
|
environment: "The environment of the Cloudflare Pages project to sync secrets to."
|
||||||
},
|
},
|
||||||
|
CLOUDFLARE_WORKERS: {
|
||||||
|
scriptId: "The ID of the Cloudflare Workers script to sync secrets to."
|
||||||
|
},
|
||||||
ZABBIX: {
|
ZABBIX: {
|
||||||
scope: "The Zabbix scope that secrets should be synced to.",
|
scope: "The Zabbix scope that secrets should be synced to.",
|
||||||
hostId: "The ID of the Zabbix host to sync secrets to.",
|
hostId: "The ID of the Zabbix host to sync secrets to.",
|
||||||
|
|||||||
@@ -50,4 +50,32 @@ export const registerCloudflareConnectionRouter = async (server: FastifyZodProvi
|
|||||||
return projects;
|
return projects;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.route({
|
||||||
|
method: "GET",
|
||||||
|
url: `/:connectionId/cloudflare-workers-projects`,
|
||||||
|
config: {
|
||||||
|
rateLimit: readLimit
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
params: z.object({
|
||||||
|
connectionId: z.string().uuid()
|
||||||
|
}),
|
||||||
|
response: {
|
||||||
|
200: z
|
||||||
|
.object({
|
||||||
|
id: z.string()
|
||||||
|
})
|
||||||
|
.array()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
|
handler: async (req) => {
|
||||||
|
const { connectionId } = req.params;
|
||||||
|
|
||||||
|
const projects = await server.services.appConnection.cloudflare.listWorkersProjects(connectionId, req.permission);
|
||||||
|
|
||||||
|
return projects;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import {
|
||||||
|
CloudflareWorkersSyncSchema,
|
||||||
|
CreateCloudflareWorkersSyncSchema,
|
||||||
|
UpdateCloudflareWorkersSyncSchema
|
||||||
|
} from "@app/services/secret-sync/cloudflare-workers/cloudflare-workers-schemas";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
|
||||||
|
import { registerSyncSecretsEndpoints } from "./secret-sync-endpoints";
|
||||||
|
|
||||||
|
export const registerCloudflareWorkersSyncRouter = async (server: FastifyZodProvider) =>
|
||||||
|
registerSyncSecretsEndpoints({
|
||||||
|
destination: SecretSync.CloudflareWorkers,
|
||||||
|
server,
|
||||||
|
responseSchema: CloudflareWorkersSyncSchema,
|
||||||
|
createSchema: CreateCloudflareWorkersSyncSchema,
|
||||||
|
updateSchema: UpdateCloudflareWorkersSyncSchema
|
||||||
|
});
|
||||||
@@ -9,6 +9,7 @@ import { registerAzureDevOpsSyncRouter } from "./azure-devops-sync-router";
|
|||||||
import { registerAzureKeyVaultSyncRouter } from "./azure-key-vault-sync-router";
|
import { registerAzureKeyVaultSyncRouter } from "./azure-key-vault-sync-router";
|
||||||
import { registerCamundaSyncRouter } from "./camunda-sync-router";
|
import { registerCamundaSyncRouter } from "./camunda-sync-router";
|
||||||
import { registerCloudflarePagesSyncRouter } from "./cloudflare-pages-sync-router";
|
import { registerCloudflarePagesSyncRouter } from "./cloudflare-pages-sync-router";
|
||||||
|
import { registerCloudflareWorkersSyncRouter } from "./cloudflare-workers-sync-router";
|
||||||
import { registerDatabricksSyncRouter } from "./databricks-sync-router";
|
import { registerDatabricksSyncRouter } from "./databricks-sync-router";
|
||||||
import { registerFlyioSyncRouter } from "./flyio-sync-router";
|
import { registerFlyioSyncRouter } from "./flyio-sync-router";
|
||||||
import { registerGcpSyncRouter } from "./gcp-sync-router";
|
import { registerGcpSyncRouter } from "./gcp-sync-router";
|
||||||
@@ -49,5 +50,6 @@ export const SECRET_SYNC_REGISTER_ROUTER_MAP: Record<SecretSync, (server: Fastif
|
|||||||
[SecretSync.Flyio]: registerFlyioSyncRouter,
|
[SecretSync.Flyio]: registerFlyioSyncRouter,
|
||||||
[SecretSync.GitLab]: registerGitLabSyncRouter,
|
[SecretSync.GitLab]: registerGitLabSyncRouter,
|
||||||
[SecretSync.CloudflarePages]: registerCloudflarePagesSyncRouter,
|
[SecretSync.CloudflarePages]: registerCloudflarePagesSyncRouter,
|
||||||
|
[SecretSync.CloudflareWorkers]: registerCloudflareWorkersSyncRouter,
|
||||||
[SecretSync.Zabbix]: registerZabbixSyncRouter
|
[SecretSync.Zabbix]: registerZabbixSyncRouter
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ import {
|
|||||||
CloudflarePagesSyncListItemSchema,
|
CloudflarePagesSyncListItemSchema,
|
||||||
CloudflarePagesSyncSchema
|
CloudflarePagesSyncSchema
|
||||||
} from "@app/services/secret-sync/cloudflare-pages/cloudflare-pages-schema";
|
} from "@app/services/secret-sync/cloudflare-pages/cloudflare-pages-schema";
|
||||||
|
import {
|
||||||
|
CloudflareWorkersSyncListItemSchema,
|
||||||
|
CloudflareWorkersSyncSchema
|
||||||
|
} from "@app/services/secret-sync/cloudflare-workers/cloudflare-workers-schemas";
|
||||||
import { DatabricksSyncListItemSchema, DatabricksSyncSchema } from "@app/services/secret-sync/databricks";
|
import { DatabricksSyncListItemSchema, DatabricksSyncSchema } from "@app/services/secret-sync/databricks";
|
||||||
import { FlyioSyncListItemSchema, FlyioSyncSchema } from "@app/services/secret-sync/flyio";
|
import { FlyioSyncListItemSchema, FlyioSyncSchema } from "@app/services/secret-sync/flyio";
|
||||||
import { GcpSyncListItemSchema, GcpSyncSchema } from "@app/services/secret-sync/gcp";
|
import { GcpSyncListItemSchema, GcpSyncSchema } from "@app/services/secret-sync/gcp";
|
||||||
@@ -64,6 +68,7 @@ const SecretSyncSchema = z.discriminatedUnion("destination", [
|
|||||||
FlyioSyncSchema,
|
FlyioSyncSchema,
|
||||||
GitLabSyncSchema,
|
GitLabSyncSchema,
|
||||||
CloudflarePagesSyncSchema,
|
CloudflarePagesSyncSchema,
|
||||||
|
CloudflareWorkersSyncSchema,
|
||||||
ZabbixSyncSchema
|
ZabbixSyncSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -90,6 +95,7 @@ const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
|||||||
FlyioSyncListItemSchema,
|
FlyioSyncListItemSchema,
|
||||||
GitLabSyncListItemSchema,
|
GitLabSyncListItemSchema,
|
||||||
CloudflarePagesSyncListItemSchema,
|
CloudflarePagesSyncListItemSchema,
|
||||||
|
CloudflareWorkersSyncListItemSchema,
|
||||||
ZabbixSyncListItemSchema
|
ZabbixSyncListItemSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ import { CloudflareConnectionMethod } from "./cloudflare-connection-enum";
|
|||||||
import {
|
import {
|
||||||
TCloudflareConnection,
|
TCloudflareConnection,
|
||||||
TCloudflareConnectionConfig,
|
TCloudflareConnectionConfig,
|
||||||
TCloudflarePagesProject
|
TCloudflarePagesProject,
|
||||||
|
TCloudflareWorkersProject
|
||||||
} from "./cloudflare-connection-types";
|
} from "./cloudflare-connection-types";
|
||||||
|
|
||||||
export const getCloudflareConnectionListItem = () => {
|
export const getCloudflareConnectionListItem = () => {
|
||||||
@@ -43,6 +44,28 @@ export const listCloudflarePagesProjects = async (
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const listCloudflareWorkersProjects = async (
|
||||||
|
appConnection: TCloudflareConnection
|
||||||
|
): Promise<TCloudflareWorkersProject[]> => {
|
||||||
|
const {
|
||||||
|
credentials: { apiToken, accountId }
|
||||||
|
} = appConnection;
|
||||||
|
|
||||||
|
const { data } = await request.get<{ result: { id: string }[] }>(
|
||||||
|
`${IntegrationUrls.CLOUDFLARE_API_URL}/client/v4/accounts/${accountId}/workers/scripts`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return data.result.map((a) => ({
|
||||||
|
id: a.id
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
export const validateCloudflareConnectionCredentials = async (config: TCloudflareConnectionConfig) => {
|
export const validateCloudflareConnectionCredentials = async (config: TCloudflareConnectionConfig) => {
|
||||||
const { apiToken, accountId } = config.credentials;
|
const { apiToken, accountId } = config.credentials;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { logger } from "@app/lib/logger";
|
|||||||
import { OrgServiceActor } from "@app/lib/types";
|
import { OrgServiceActor } from "@app/lib/types";
|
||||||
|
|
||||||
import { AppConnection } from "../app-connection-enums";
|
import { AppConnection } from "../app-connection-enums";
|
||||||
import { listCloudflarePagesProjects } from "./cloudflare-connection-fns";
|
import { listCloudflarePagesProjects, listCloudflareWorkersProjects } from "./cloudflare-connection-fns";
|
||||||
import { TCloudflareConnection } from "./cloudflare-connection-types";
|
import { TCloudflareConnection } from "./cloudflare-connection-types";
|
||||||
|
|
||||||
type TGetAppConnectionFunc = (
|
type TGetAppConnectionFunc = (
|
||||||
@@ -24,7 +24,20 @@ export const cloudflareConnectionService = (getAppConnection: TGetAppConnectionF
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const listWorkersProjects = async (connectionId: string, actor: OrgServiceActor) => {
|
||||||
|
const appConnection = await getAppConnection(AppConnection.Cloudflare, connectionId, actor);
|
||||||
|
try {
|
||||||
|
const projects = await listCloudflareWorkersProjects(appConnection);
|
||||||
|
|
||||||
|
return projects;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error, "Failed to list Cloudflare Workers projects for Cloudflare connection");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listPagesProjects
|
listPagesProjects,
|
||||||
|
listWorkersProjects
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,3 +28,7 @@ export type TCloudflarePagesProject = {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TCloudflareWorkersProject = {
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import { TSecretSyncListItem } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
export const CLOUDFLARE_WORKERS_SYNC_LIST_OPTION: TSecretSyncListItem = {
|
||||||
|
name: "Cloudflare Workers",
|
||||||
|
destination: SecretSync.CloudflareWorkers,
|
||||||
|
connection: AppConnection.Cloudflare,
|
||||||
|
canImportSecrets: false
|
||||||
|
};
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
import { request } from "@app/lib/config/request";
|
||||||
|
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||||
|
import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";
|
||||||
|
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
import { SECRET_SYNC_NAME_MAP } from "../secret-sync-maps";
|
||||||
|
import { TCloudflareWorkersSyncWithCredentials } from "./cloudflare-workers-types";
|
||||||
|
|
||||||
|
const getProjectEnvironmentSecretNames = async (
|
||||||
|
secretSync: TCloudflareWorkersSyncWithCredentials
|
||||||
|
): Promise<string[]> => {
|
||||||
|
const {
|
||||||
|
destinationConfig,
|
||||||
|
connection: {
|
||||||
|
credentials: { apiToken, accountId }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const { data } = await request.get<{
|
||||||
|
result: Array<{ name: string }>;
|
||||||
|
}>(
|
||||||
|
`${IntegrationUrls.CLOUDFLARE_WORKERS_API_URL}/client/v4/accounts/${accountId}/workers/scripts/${destinationConfig.scriptId}/secrets`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
Accept: "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return data.result.map((s) => s.name);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getSecretEndpointForSingle = (secretSync: TCloudflareWorkersSyncWithCredentials, secretName: string) => {
|
||||||
|
const {
|
||||||
|
destinationConfig,
|
||||||
|
connection: {
|
||||||
|
credentials: { accountId }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
return `${IntegrationUrls.CLOUDFLARE_WORKERS_API_URL}/client/v4/accounts/${accountId}/workers/scripts/${destinationConfig.scriptId}/secrets/${secretName}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncFns = {
|
||||||
|
syncSecrets: async (secretSync: TCloudflareWorkersSyncWithCredentials, secretMap: TSecretMap) => {
|
||||||
|
const {
|
||||||
|
connection: {
|
||||||
|
credentials: { apiToken }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const existingSecretNames = await getProjectEnvironmentSecretNames(secretSync);
|
||||||
|
const secretMapKeys = new Set(Object.keys(secretMap));
|
||||||
|
|
||||||
|
const secretsToCreateOrUpdatePromises = Object.entries(secretMap).map(async ([key, val]) => {
|
||||||
|
await request.put(
|
||||||
|
getSecretEndpointForSingle(secretSync, key),
|
||||||
|
{ value: val.value },
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await Promise.all(secretsToCreateOrUpdatePromises);
|
||||||
|
|
||||||
|
if (!secretSync.syncOptions.disableSecretDeletion) {
|
||||||
|
const secretsToDeletePromises = existingSecretNames
|
||||||
|
.filter((existingKey) => {
|
||||||
|
const isManagedBySchema = matchesSchema(
|
||||||
|
existingKey,
|
||||||
|
secretSync.environment?.slug || "",
|
||||||
|
secretSync.syncOptions.keySchema
|
||||||
|
);
|
||||||
|
const isInNewSecretMap = secretMapKeys.has(existingKey);
|
||||||
|
return !isInNewSecretMap && isManagedBySchema;
|
||||||
|
})
|
||||||
|
.map(async (key) => {
|
||||||
|
await request.delete(getSecretEndpointForSingle(secretSync, key), {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await Promise.all(secretsToDeletePromises);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSecrets: async (secretSync: TCloudflareWorkersSyncWithCredentials): Promise<TSecretMap> => {
|
||||||
|
throw new Error(`${SECRET_SYNC_NAME_MAP[secretSync.destination]} does not support importing secrets.`);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSecrets: async (secretSync: TCloudflareWorkersSyncWithCredentials, secretMap: TSecretMap) => {
|
||||||
|
const {
|
||||||
|
connection: {
|
||||||
|
credentials: { apiToken }
|
||||||
|
}
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const existingSecretNames = await getProjectEnvironmentSecretNames(secretSync);
|
||||||
|
const secretMapToRemoveKeys = new Set(Object.keys(secretMap));
|
||||||
|
|
||||||
|
const deletePromises = existingSecretNames.map(async (existingKey) => {
|
||||||
|
const isManagedBySchema = matchesSchema(
|
||||||
|
existingKey,
|
||||||
|
secretSync.environment?.slug || "",
|
||||||
|
secretSync.syncOptions.keySchema
|
||||||
|
);
|
||||||
|
const isInSecretMapToRemove = secretMapToRemoveKeys.has(existingKey);
|
||||||
|
|
||||||
|
if (isInSecretMapToRemove && isManagedBySchema) {
|
||||||
|
await request.delete(getSecretEndpointForSingle(secretSync, existingKey), {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${apiToken}`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await Promise.all(deletePromises);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { SecretSyncs } from "@app/lib/api-docs";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import {
|
||||||
|
BaseSecretSyncSchema,
|
||||||
|
GenericCreateSecretSyncFieldsSchema,
|
||||||
|
GenericUpdateSecretSyncFieldsSchema
|
||||||
|
} from "@app/services/secret-sync/secret-sync-schemas";
|
||||||
|
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
const CloudflareWorkersSyncDestinationConfigSchema = z.object({
|
||||||
|
scriptId: z
|
||||||
|
.string()
|
||||||
|
.min(1, "Script ID is required")
|
||||||
|
.describe(SecretSyncs.DESTINATION_CONFIG.CLOUDFLARE_WORKERS.scriptId)
|
||||||
|
});
|
||||||
|
|
||||||
|
const CloudflareWorkersSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: false };
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncSchema = BaseSecretSyncSchema(
|
||||||
|
SecretSync.CloudflareWorkers,
|
||||||
|
CloudflareWorkersSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destination: z.literal(SecretSync.CloudflareWorkers),
|
||||||
|
destinationConfig: CloudflareWorkersSyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateCloudflareWorkersSyncSchema = GenericCreateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.CloudflareWorkers,
|
||||||
|
CloudflareWorkersSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: CloudflareWorkersSyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const UpdateCloudflareWorkersSyncSchema = GenericUpdateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.CloudflareWorkers,
|
||||||
|
CloudflareWorkersSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: CloudflareWorkersSyncDestinationConfigSchema.optional()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncListItemSchema = z.object({
|
||||||
|
name: z.literal("Cloudflare Workers"),
|
||||||
|
connection: z.literal(AppConnection.Cloudflare),
|
||||||
|
destination: z.literal(SecretSync.CloudflareWorkers),
|
||||||
|
canImportSecrets: z.literal(false)
|
||||||
|
});
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { TCloudflareConnection } from "@app/services/app-connection/cloudflare/cloudflare-connection-types";
|
||||||
|
|
||||||
|
import {
|
||||||
|
CloudflareWorkersSyncListItemSchema,
|
||||||
|
CloudflareWorkersSyncSchema,
|
||||||
|
CreateCloudflareWorkersSyncSchema
|
||||||
|
} from "./cloudflare-workers-schemas";
|
||||||
|
|
||||||
|
export type TCloudflareWorkersSyncListItem = z.infer<typeof CloudflareWorkersSyncListItemSchema>;
|
||||||
|
|
||||||
|
export type TCloudflareWorkersSync = z.infer<typeof CloudflareWorkersSyncSchema>;
|
||||||
|
|
||||||
|
export type TCloudflareWorkersSyncInput = z.infer<typeof CreateCloudflareWorkersSyncSchema>;
|
||||||
|
|
||||||
|
export type TCloudflareWorkersSyncWithCredentials = TCloudflareWorkersSync & {
|
||||||
|
connection: TCloudflareConnection;
|
||||||
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./cloudflare-workers-constants";
|
||||||
|
export * from "./cloudflare-workers-fns";
|
||||||
|
export * from "./cloudflare-workers-schemas";
|
||||||
|
export * from "./cloudflare-workers-types";
|
||||||
@@ -21,6 +21,7 @@ export enum SecretSync {
|
|||||||
Flyio = "flyio",
|
Flyio = "flyio",
|
||||||
GitLab = "gitlab",
|
GitLab = "gitlab",
|
||||||
CloudflarePages = "cloudflare-pages",
|
CloudflarePages = "cloudflare-pages",
|
||||||
|
CloudflareWorkers = "cloudflare-workers",
|
||||||
Zabbix = "zabbix"
|
Zabbix = "zabbix"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { AZURE_KEY_VAULT_SYNC_LIST_OPTION, azureKeyVaultSyncFactory } from "./az
|
|||||||
import { CAMUNDA_SYNC_LIST_OPTION, camundaSyncFactory } from "./camunda";
|
import { CAMUNDA_SYNC_LIST_OPTION, camundaSyncFactory } from "./camunda";
|
||||||
import { CLOUDFLARE_PAGES_SYNC_LIST_OPTION } from "./cloudflare-pages/cloudflare-pages-constants";
|
import { CLOUDFLARE_PAGES_SYNC_LIST_OPTION } from "./cloudflare-pages/cloudflare-pages-constants";
|
||||||
import { CloudflarePagesSyncFns } from "./cloudflare-pages/cloudflare-pages-fns";
|
import { CloudflarePagesSyncFns } from "./cloudflare-pages/cloudflare-pages-fns";
|
||||||
|
import { CLOUDFLARE_WORKERS_SYNC_LIST_OPTION, CloudflareWorkersSyncFns } from "./cloudflare-workers";
|
||||||
import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
|
import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
|
||||||
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
||||||
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
||||||
@@ -70,6 +71,7 @@ const SECRET_SYNC_LIST_OPTIONS: Record<SecretSync, TSecretSyncListItem> = {
|
|||||||
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION,
|
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION,
|
||||||
[SecretSync.GitLab]: GITLAB_SYNC_LIST_OPTION,
|
[SecretSync.GitLab]: GITLAB_SYNC_LIST_OPTION,
|
||||||
[SecretSync.CloudflarePages]: CLOUDFLARE_PAGES_SYNC_LIST_OPTION,
|
[SecretSync.CloudflarePages]: CLOUDFLARE_PAGES_SYNC_LIST_OPTION,
|
||||||
|
[SecretSync.CloudflareWorkers]: CLOUDFLARE_WORKERS_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Zabbix]: ZABBIX_SYNC_LIST_OPTION
|
[SecretSync.Zabbix]: ZABBIX_SYNC_LIST_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -238,6 +240,8 @@ export const SecretSyncFns = {
|
|||||||
return GitLabSyncFns.syncSecrets(secretSync, schemaSecretMap, { appConnectionDAL, kmsService });
|
return GitLabSyncFns.syncSecrets(secretSync, schemaSecretMap, { appConnectionDAL, kmsService });
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
return CloudflarePagesSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
return CloudflarePagesSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
return CloudflareWorkersSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
return ZabbixSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
return ZabbixSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
default:
|
default:
|
||||||
@@ -332,6 +336,9 @@ export const SecretSyncFns = {
|
|||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
secretMap = await CloudflarePagesSyncFns.getSecrets(secretSync);
|
secretMap = await CloudflarePagesSyncFns.getSecrets(secretSync);
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
secretMap = await CloudflareWorkersSyncFns.getSecrets(secretSync);
|
||||||
|
break;
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
secretMap = await ZabbixSyncFns.getSecrets(secretSync);
|
secretMap = await ZabbixSyncFns.getSecrets(secretSync);
|
||||||
break;
|
break;
|
||||||
@@ -412,6 +419,8 @@ export const SecretSyncFns = {
|
|||||||
return GitLabSyncFns.removeSecrets(secretSync, schemaSecretMap, { appConnectionDAL, kmsService });
|
return GitLabSyncFns.removeSecrets(secretSync, schemaSecretMap, { appConnectionDAL, kmsService });
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
return CloudflarePagesSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return CloudflarePagesSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
return CloudflareWorkersSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
return ZabbixSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return ZabbixSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const SECRET_SYNC_NAME_MAP: Record<SecretSync, string> = {
|
|||||||
[SecretSync.Flyio]: "Fly.io",
|
[SecretSync.Flyio]: "Fly.io",
|
||||||
[SecretSync.GitLab]: "GitLab",
|
[SecretSync.GitLab]: "GitLab",
|
||||||
[SecretSync.CloudflarePages]: "Cloudflare Pages",
|
[SecretSync.CloudflarePages]: "Cloudflare Pages",
|
||||||
|
[SecretSync.CloudflareWorkers]: "Cloudflare Workers",
|
||||||
[SecretSync.Zabbix]: "Zabbix"
|
[SecretSync.Zabbix]: "Zabbix"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,6 +51,7 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.Flyio]: AppConnection.Flyio,
|
[SecretSync.Flyio]: AppConnection.Flyio,
|
||||||
[SecretSync.GitLab]: AppConnection.GitLab,
|
[SecretSync.GitLab]: AppConnection.GitLab,
|
||||||
[SecretSync.CloudflarePages]: AppConnection.Cloudflare,
|
[SecretSync.CloudflarePages]: AppConnection.Cloudflare,
|
||||||
|
[SecretSync.CloudflareWorkers]: AppConnection.Cloudflare,
|
||||||
[SecretSync.Zabbix]: AppConnection.Zabbix
|
[SecretSync.Zabbix]: AppConnection.Zabbix
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,5 +78,6 @@ export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
|||||||
[SecretSync.Flyio]: SecretSyncPlanType.Regular,
|
[SecretSync.Flyio]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.GitLab]: SecretSyncPlanType.Regular,
|
[SecretSync.GitLab]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.CloudflarePages]: SecretSyncPlanType.Regular,
|
[SecretSync.CloudflarePages]: SecretSyncPlanType.Regular,
|
||||||
|
[SecretSync.CloudflareWorkers]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.Zabbix]: SecretSyncPlanType.Regular
|
[SecretSync.Zabbix]: SecretSyncPlanType.Regular
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ import {
|
|||||||
TCloudflarePagesSyncListItem,
|
TCloudflarePagesSyncListItem,
|
||||||
TCloudflarePagesSyncWithCredentials
|
TCloudflarePagesSyncWithCredentials
|
||||||
} from "./cloudflare-pages/cloudflare-pages-types";
|
} from "./cloudflare-pages/cloudflare-pages-types";
|
||||||
|
import {
|
||||||
|
TCloudflareWorkersSync,
|
||||||
|
TCloudflareWorkersSyncInput,
|
||||||
|
TCloudflareWorkersSyncListItem,
|
||||||
|
TCloudflareWorkersSyncWithCredentials
|
||||||
|
} from "./cloudflare-workers";
|
||||||
import { TFlyioSync, TFlyioSyncInput, TFlyioSyncListItem, TFlyioSyncWithCredentials } from "./flyio/flyio-sync-types";
|
import { TFlyioSync, TFlyioSyncInput, TFlyioSyncListItem, TFlyioSyncWithCredentials } from "./flyio/flyio-sync-types";
|
||||||
import { TGcpSync, TGcpSyncInput, TGcpSyncListItem, TGcpSyncWithCredentials } from "./gcp";
|
import { TGcpSync, TGcpSyncInput, TGcpSyncListItem, TGcpSyncWithCredentials } from "./gcp";
|
||||||
import { TGitLabSync, TGitLabSyncInput, TGitLabSyncListItem, TGitLabSyncWithCredentials } from "./gitlab";
|
import { TGitLabSync, TGitLabSyncInput, TGitLabSyncListItem, TGitLabSyncWithCredentials } from "./gitlab";
|
||||||
@@ -138,6 +144,7 @@ export type TSecretSync =
|
|||||||
| TFlyioSync
|
| TFlyioSync
|
||||||
| TGitLabSync
|
| TGitLabSync
|
||||||
| TCloudflarePagesSync
|
| TCloudflarePagesSync
|
||||||
|
| TCloudflareWorkersSync
|
||||||
| TZabbixSync;
|
| TZabbixSync;
|
||||||
|
|
||||||
export type TSecretSyncWithCredentials =
|
export type TSecretSyncWithCredentials =
|
||||||
@@ -163,6 +170,7 @@ export type TSecretSyncWithCredentials =
|
|||||||
| TFlyioSyncWithCredentials
|
| TFlyioSyncWithCredentials
|
||||||
| TGitLabSyncWithCredentials
|
| TGitLabSyncWithCredentials
|
||||||
| TCloudflarePagesSyncWithCredentials
|
| TCloudflarePagesSyncWithCredentials
|
||||||
|
| TCloudflareWorkersSyncWithCredentials
|
||||||
| TZabbixSyncWithCredentials;
|
| TZabbixSyncWithCredentials;
|
||||||
|
|
||||||
export type TSecretSyncInput =
|
export type TSecretSyncInput =
|
||||||
@@ -188,6 +196,7 @@ export type TSecretSyncInput =
|
|||||||
| TFlyioSyncInput
|
| TFlyioSyncInput
|
||||||
| TGitLabSyncInput
|
| TGitLabSyncInput
|
||||||
| TCloudflarePagesSyncInput
|
| TCloudflarePagesSyncInput
|
||||||
|
| TCloudflareWorkersSyncInput
|
||||||
| TZabbixSyncInput;
|
| TZabbixSyncInput;
|
||||||
|
|
||||||
export type TSecretSyncListItem =
|
export type TSecretSyncListItem =
|
||||||
@@ -213,6 +222,7 @@ export type TSecretSyncListItem =
|
|||||||
| TFlyioSyncListItem
|
| TFlyioSyncListItem
|
||||||
| TGitLabSyncListItem
|
| TGitLabSyncListItem
|
||||||
| TCloudflarePagesSyncListItem
|
| TCloudflarePagesSyncListItem
|
||||||
|
| TCloudflareWorkersSyncListItem
|
||||||
| TZabbixSyncListItem;
|
| TZabbixSyncListItem;
|
||||||
|
|
||||||
export type TSyncOptionsConfig = {
|
export type TSyncOptionsConfig = {
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import { SingleValue } from "react-select";
|
|||||||
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
||||||
import { FilterableSelect, FormControl, Select, SelectItem } from "@app/components/v2";
|
import { FilterableSelect, FormControl, Select, SelectItem } from "@app/components/v2";
|
||||||
import {
|
import {
|
||||||
TCloudflareProject,
|
TCloudflarePagesProject,
|
||||||
useCloudflareConnectionListPagesProjects
|
useCloudflareConnectionListPagesProjects
|
||||||
} from "@app/hooks/api/appConnections/cloudflare";
|
} from "@app/hooks/api/appConnections/cloudflare";
|
||||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
@@ -52,7 +52,7 @@ export const CloudflarePagesSyncFields = () => {
|
|||||||
isDisabled={!connectionId}
|
isDisabled={!connectionId}
|
||||||
value={projects ? (projects.find((project) => project.name === value) ?? []) : []}
|
value={projects ? (projects.find((project) => project.name === value) ?? []) : []}
|
||||||
onChange={(option) => {
|
onChange={(option) => {
|
||||||
onChange((option as SingleValue<TCloudflareProject>)?.name ?? null);
|
onChange((option as SingleValue<TCloudflarePagesProject>)?.name ?? null);
|
||||||
}}
|
}}
|
||||||
options={projects}
|
options={projects}
|
||||||
placeholder="Select a project..."
|
placeholder="Select a project..."
|
||||||
|
|||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
||||||
|
import { SingleValue } from "react-select";
|
||||||
|
|
||||||
|
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
||||||
|
import { FilterableSelect, FormControl } from "@app/components/v2";
|
||||||
|
import {
|
||||||
|
TCloudflareWorkersProject,
|
||||||
|
useCloudflareConnectionListWorkersProjects
|
||||||
|
} from "@app/hooks/api/appConnections/cloudflare";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "../schemas";
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncFields = () => {
|
||||||
|
const { control, setValue } = useFormContext<
|
||||||
|
TSecretSyncForm & { destination: SecretSync.CloudflareWorkers }
|
||||||
|
>();
|
||||||
|
|
||||||
|
const connectionId = useWatch({ name: "connection.id", control });
|
||||||
|
|
||||||
|
const { data: projects = [], isPending: isProjectsPending } =
|
||||||
|
useCloudflareConnectionListWorkersProjects(connectionId, {
|
||||||
|
enabled: Boolean(connectionId)
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SecretSyncConnectionField
|
||||||
|
onChange={() => {
|
||||||
|
setValue("destinationConfig.scriptId", "");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Controller
|
||||||
|
name="destinationConfig.scriptId"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
label="Worker Script"
|
||||||
|
>
|
||||||
|
<FilterableSelect
|
||||||
|
isLoading={isProjectsPending && Boolean(connectionId)}
|
||||||
|
isDisabled={!connectionId}
|
||||||
|
value={projects ? (projects.find((project) => project.id === value) ?? []) : []}
|
||||||
|
onChange={(option) => {
|
||||||
|
onChange((option as SingleValue<TCloudflareWorkersProject>)?.id ?? null);
|
||||||
|
}}
|
||||||
|
options={projects}
|
||||||
|
placeholder="Select a worker script..."
|
||||||
|
getOptionLabel={(option) => option.id}
|
||||||
|
getOptionValue={(option) => option.id}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
+3
@@ -11,6 +11,7 @@ import { AzureDevOpsSyncFields } from "./AzureDevOpsSyncFields";
|
|||||||
import { AzureKeyVaultSyncFields } from "./AzureKeyVaultSyncFields";
|
import { AzureKeyVaultSyncFields } from "./AzureKeyVaultSyncFields";
|
||||||
import { CamundaSyncFields } from "./CamundaSyncFields";
|
import { CamundaSyncFields } from "./CamundaSyncFields";
|
||||||
import { CloudflarePagesSyncFields } from "./CloudflarePagesSyncFields";
|
import { CloudflarePagesSyncFields } from "./CloudflarePagesSyncFields";
|
||||||
|
import { CloudflareWorkersSyncFields } from "./CloudflareWorkersSyncFields";
|
||||||
import { DatabricksSyncFields } from "./DatabricksSyncFields";
|
import { DatabricksSyncFields } from "./DatabricksSyncFields";
|
||||||
import { FlyioSyncFields } from "./FlyioSyncFields";
|
import { FlyioSyncFields } from "./FlyioSyncFields";
|
||||||
import { GcpSyncFields } from "./GcpSyncFields";
|
import { GcpSyncFields } from "./GcpSyncFields";
|
||||||
@@ -77,6 +78,8 @@ export const SecretSyncDestinationFields = () => {
|
|||||||
return <GitLabSyncFields />;
|
return <GitLabSyncFields />;
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
return <CloudflarePagesSyncFields />;
|
return <CloudflarePagesSyncFields />;
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
return <CloudflareWorkersSyncFields />;
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
return <ZabbixSyncFields />;
|
return <ZabbixSyncFields />;
|
||||||
default:
|
default:
|
||||||
|
|||||||
+1
@@ -58,6 +58,7 @@ export const SecretSyncOptionsFields = ({ hideInitialSync }: Props) => {
|
|||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
case SecretSync.GitLab:
|
case SecretSync.GitLab:
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
AdditionalSyncOptionsFieldsComponent = null;
|
AdditionalSyncOptionsFieldsComponent = null;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
||||||
|
import { GenericFieldLabel } from "@app/components/v2";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncReviewFields = () => {
|
||||||
|
const { watch } = useFormContext<
|
||||||
|
TSecretSyncForm & { destination: SecretSync.CloudflareWorkers }
|
||||||
|
>();
|
||||||
|
const scriptId = watch("destinationConfig.scriptId");
|
||||||
|
|
||||||
|
return <GenericFieldLabel label="Script">{scriptId}</GenericFieldLabel>;
|
||||||
|
};
|
||||||
+4
@@ -20,6 +20,7 @@ import { AzureDevOpsSyncReviewFields } from "./AzureDevOpsSyncReviewFields";
|
|||||||
import { AzureKeyVaultSyncReviewFields } from "./AzureKeyVaultSyncReviewFields";
|
import { AzureKeyVaultSyncReviewFields } from "./AzureKeyVaultSyncReviewFields";
|
||||||
import { CamundaSyncReviewFields } from "./CamundaSyncReviewFields";
|
import { CamundaSyncReviewFields } from "./CamundaSyncReviewFields";
|
||||||
import { CloudflarePagesSyncReviewFields } from "./CloudflarePagesReviewFields";
|
import { CloudflarePagesSyncReviewFields } from "./CloudflarePagesReviewFields";
|
||||||
|
import { CloudflareWorkersSyncReviewFields } from "./CloudflareWorkersReviewFields";
|
||||||
import { DatabricksSyncReviewFields } from "./DatabricksSyncReviewFields";
|
import { DatabricksSyncReviewFields } from "./DatabricksSyncReviewFields";
|
||||||
import { FlyioSyncReviewFields } from "./FlyioSyncReviewFields";
|
import { FlyioSyncReviewFields } from "./FlyioSyncReviewFields";
|
||||||
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
||||||
@@ -125,6 +126,9 @@ export const SecretSyncReviewFields = () => {
|
|||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
DestinationFieldsComponent = <CloudflarePagesSyncReviewFields />;
|
DestinationFieldsComponent = <CloudflarePagesSyncReviewFields />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
DestinationFieldsComponent = <CloudflareWorkersSyncReviewFields />;
|
||||||
|
break;
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
DestinationFieldsComponent = <ZabbixSyncReviewFields />;
|
DestinationFieldsComponent = <ZabbixSyncReviewFields />;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||||
|
z.object({
|
||||||
|
destination: z.literal(SecretSync.CloudflareWorkers),
|
||||||
|
destinationConfig: z.object({
|
||||||
|
scriptId: z.string().trim().min(1, "Script ID is required")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
@@ -8,6 +8,7 @@ import { AzureDevOpsSyncDestinationSchema } from "./azure-devops-sync-destinatio
|
|||||||
import { AzureKeyVaultSyncDestinationSchema } from "./azure-key-vault-sync-destination-schema";
|
import { AzureKeyVaultSyncDestinationSchema } from "./azure-key-vault-sync-destination-schema";
|
||||||
import { CamundaSyncDestinationSchema } from "./camunda-sync-destination-schema";
|
import { CamundaSyncDestinationSchema } from "./camunda-sync-destination-schema";
|
||||||
import { CloudflarePagesSyncDestinationSchema } from "./cloudflare-pages-sync-destination-schema";
|
import { CloudflarePagesSyncDestinationSchema } from "./cloudflare-pages-sync-destination-schema";
|
||||||
|
import { CloudflareWorkersSyncDestinationSchema } from "./cloudflare-workers-sync-destination-schema";
|
||||||
import { DatabricksSyncDestinationSchema } from "./databricks-sync-destination-schema";
|
import { DatabricksSyncDestinationSchema } from "./databricks-sync-destination-schema";
|
||||||
import { FlyioSyncDestinationSchema } from "./flyio-sync-destination-schema";
|
import { FlyioSyncDestinationSchema } from "./flyio-sync-destination-schema";
|
||||||
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
||||||
@@ -47,6 +48,7 @@ const SecretSyncUnionSchema = z.discriminatedUnion("destination", [
|
|||||||
FlyioSyncDestinationSchema,
|
FlyioSyncDestinationSchema,
|
||||||
GitlabSyncDestinationSchema,
|
GitlabSyncDestinationSchema,
|
||||||
CloudflarePagesSyncDestinationSchema,
|
CloudflarePagesSyncDestinationSchema,
|
||||||
|
CloudflareWorkersSyncDestinationSchema,
|
||||||
ZabbixSyncDestinationSchema
|
ZabbixSyncDestinationSchema
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }
|
|||||||
name: "Cloudflare Pages",
|
name: "Cloudflare Pages",
|
||||||
image: "Cloudflare.png"
|
image: "Cloudflare.png"
|
||||||
},
|
},
|
||||||
|
[SecretSync.CloudflareWorkers]: {
|
||||||
|
name: "Cloudflare Workers",
|
||||||
|
image: "Cloudflare.png"
|
||||||
|
},
|
||||||
[SecretSync.Zabbix]: {
|
[SecretSync.Zabbix]: {
|
||||||
name: "Zabbix",
|
name: "Zabbix",
|
||||||
image: "Zabbix.png"
|
image: "Zabbix.png"
|
||||||
@@ -111,6 +115,7 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.Flyio]: AppConnection.Flyio,
|
[SecretSync.Flyio]: AppConnection.Flyio,
|
||||||
[SecretSync.GitLab]: AppConnection.Gitlab,
|
[SecretSync.GitLab]: AppConnection.Gitlab,
|
||||||
[SecretSync.CloudflarePages]: AppConnection.Cloudflare,
|
[SecretSync.CloudflarePages]: AppConnection.Cloudflare,
|
||||||
|
[SecretSync.CloudflareWorkers]: AppConnection.Cloudflare,
|
||||||
[SecretSync.Zabbix]: AppConnection.Zabbix
|
[SecretSync.Zabbix]: AppConnection.Zabbix
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,21 +3,23 @@ import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
|||||||
import { apiRequest } from "@app/config/request";
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
import { appConnectionKeys } from "../queries";
|
import { appConnectionKeys } from "../queries";
|
||||||
import { TCloudflareProject } from "./types";
|
import { TCloudflarePagesProject, TCloudflareWorkersProject } from "./types";
|
||||||
|
|
||||||
const cloudflareConnectionKeys = {
|
const cloudflareConnectionKeys = {
|
||||||
all: [...appConnectionKeys.all, "cloudflare"] as const,
|
all: [...appConnectionKeys.all, "cloudflare"] as const,
|
||||||
listPagesProjects: (connectionId: string) =>
|
listPagesProjects: (connectionId: string) =>
|
||||||
[...cloudflareConnectionKeys.all, "pages-projects", connectionId] as const
|
[...cloudflareConnectionKeys.all, "pages-projects", connectionId] as const,
|
||||||
|
listWorkersProjects: (connectionId: string) =>
|
||||||
|
[...cloudflareConnectionKeys.all, "workers-projects", connectionId] as const
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCloudflareConnectionListPagesProjects = (
|
export const useCloudflareConnectionListPagesProjects = (
|
||||||
connectionId: string,
|
connectionId: string,
|
||||||
options?: Omit<
|
options?: Omit<
|
||||||
UseQueryOptions<
|
UseQueryOptions<
|
||||||
TCloudflareProject[],
|
TCloudflarePagesProject[],
|
||||||
unknown,
|
unknown,
|
||||||
TCloudflareProject[],
|
TCloudflarePagesProject[],
|
||||||
ReturnType<typeof cloudflareConnectionKeys.listPagesProjects>
|
ReturnType<typeof cloudflareConnectionKeys.listPagesProjects>
|
||||||
>,
|
>,
|
||||||
"queryKey" | "queryFn"
|
"queryKey" | "queryFn"
|
||||||
@@ -26,7 +28,7 @@ export const useCloudflareConnectionListPagesProjects = (
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: cloudflareConnectionKeys.listPagesProjects(connectionId),
|
queryKey: cloudflareConnectionKeys.listPagesProjects(connectionId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data } = await apiRequest.get<TCloudflareProject[]>(
|
const { data } = await apiRequest.get<TCloudflarePagesProject[]>(
|
||||||
`/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-pages-projects`
|
`/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-pages-projects`
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -35,3 +37,28 @@ export const useCloudflareConnectionListPagesProjects = (
|
|||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useCloudflareConnectionListWorkersProjects = (
|
||||||
|
connectionId: string,
|
||||||
|
options?: Omit<
|
||||||
|
UseQueryOptions<
|
||||||
|
TCloudflareWorkersProject[],
|
||||||
|
unknown,
|
||||||
|
TCloudflareWorkersProject[],
|
||||||
|
ReturnType<typeof cloudflareConnectionKeys.listWorkersProjects>
|
||||||
|
>,
|
||||||
|
"queryKey" | "queryFn"
|
||||||
|
>
|
||||||
|
) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: cloudflareConnectionKeys.listWorkersProjects(connectionId),
|
||||||
|
queryFn: async () => {
|
||||||
|
const { data } = await apiRequest.get<TCloudflareWorkersProject[]>(
|
||||||
|
`/api/v1/app-connections/cloudflare/${connectionId}/cloudflare-workers-projects`
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
export type TCloudflareProject = {
|
export type TCloudflarePagesProject = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type TCloudflareWorkersProject = {
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export enum SecretSync {
|
|||||||
Flyio = "flyio",
|
Flyio = "flyio",
|
||||||
GitLab = "gitlab",
|
GitLab = "gitlab",
|
||||||
CloudflarePages = "cloudflare-pages",
|
CloudflarePages = "cloudflare-pages",
|
||||||
|
CloudflareWorkers = "cloudflare-workers",
|
||||||
Zabbix = "zabbix"
|
Zabbix = "zabbix"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
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 TCloudflareWorkersSync = TRootSecretSync & {
|
||||||
|
destination: SecretSync.CloudflareWorkers;
|
||||||
|
destinationConfig: {
|
||||||
|
scriptId: string;
|
||||||
|
};
|
||||||
|
connection: {
|
||||||
|
app: AppConnection.Cloudflare;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -10,6 +10,7 @@ import { TAzureDevOpsSync } from "./azure-devops-sync";
|
|||||||
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
|
import { TAzureKeyVaultSync } from "./azure-key-vault-sync";
|
||||||
import { TCamundaSync } from "./camunda-sync";
|
import { TCamundaSync } from "./camunda-sync";
|
||||||
import { TCloudflarePagesSync } from "./cloudflare-pages-sync";
|
import { TCloudflarePagesSync } from "./cloudflare-pages-sync";
|
||||||
|
import { TCloudflareWorkersSync } from "./cloudflare-workers-sync";
|
||||||
import { TDatabricksSync } from "./databricks-sync";
|
import { TDatabricksSync } from "./databricks-sync";
|
||||||
import { TFlyioSync } from "./flyio-sync";
|
import { TFlyioSync } from "./flyio-sync";
|
||||||
import { TGcpSync } from "./gcp-sync";
|
import { TGcpSync } from "./gcp-sync";
|
||||||
@@ -55,6 +56,7 @@ export type TSecretSync =
|
|||||||
| TFlyioSync
|
| TFlyioSync
|
||||||
| TGitLabSync
|
| TGitLabSync
|
||||||
| TCloudflarePagesSync
|
| TCloudflarePagesSync
|
||||||
|
| TCloudflareWorkersSync
|
||||||
| TZabbixSync;
|
| TZabbixSync;
|
||||||
|
|
||||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import { TCloudflareWorkersSync } from "@app/hooks/api/secretSyncs/types/cloudflare-workers-sync";
|
||||||
|
|
||||||
|
import { getSecretSyncDestinationColValues } from "../helpers";
|
||||||
|
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: TCloudflareWorkersSync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncDestinationCol = ({ secretSync }: Props) => {
|
||||||
|
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
||||||
|
|
||||||
|
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
||||||
|
};
|
||||||
+3
@@ -8,6 +8,7 @@ import { AzureDevOpsSyncDestinationCol } from "./AzureDevOpsSyncDestinationCol";
|
|||||||
import { AzureKeyVaultDestinationSyncCol } from "./AzureKeyVaultDestinationSyncCol";
|
import { AzureKeyVaultDestinationSyncCol } from "./AzureKeyVaultDestinationSyncCol";
|
||||||
import { CamundaSyncDestinationCol } from "./CamundaSyncDestinationCol";
|
import { CamundaSyncDestinationCol } from "./CamundaSyncDestinationCol";
|
||||||
import { CloudflarePagesSyncDestinationCol } from "./CloudflarePagesSyncDestinationCol";
|
import { CloudflarePagesSyncDestinationCol } from "./CloudflarePagesSyncDestinationCol";
|
||||||
|
import { CloudflareWorkersSyncDestinationCol } from "./CloudflareWorkersSyncDestinationCol";
|
||||||
import { DatabricksSyncDestinationCol } from "./DatabricksSyncDestinationCol";
|
import { DatabricksSyncDestinationCol } from "./DatabricksSyncDestinationCol";
|
||||||
import { FlyioSyncDestinationCol } from "./FlyioSyncDestinationCol";
|
import { FlyioSyncDestinationCol } from "./FlyioSyncDestinationCol";
|
||||||
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
||||||
@@ -74,6 +75,8 @@ export const SecretSyncDestinationCol = ({ secretSync }: Props) => {
|
|||||||
return <GitLabSyncDestinationCol secretSync={secretSync} />;
|
return <GitLabSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
return <CloudflarePagesSyncDestinationCol secretSync={secretSync} />;
|
return <CloudflarePagesSyncDestinationCol secretSync={secretSync} />;
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
return <CloudflareWorkersSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
return <ZabbixSyncDestinationCol secretSync={secretSync} />;
|
return <ZabbixSyncDestinationCol secretSync={secretSync} />;
|
||||||
default:
|
default:
|
||||||
|
|||||||
+4
@@ -145,6 +145,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
|
|||||||
primaryText = destinationConfig.projectName;
|
primaryText = destinationConfig.projectName;
|
||||||
secondaryText = destinationConfig.environment;
|
secondaryText = destinationConfig.environment;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
primaryText = destinationConfig.scriptId;
|
||||||
|
secondaryText = "Script ID";
|
||||||
|
break;
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
if (destinationConfig.scope === ZabbixSyncScope.Host) {
|
if (destinationConfig.scope === ZabbixSyncScope.Host) {
|
||||||
primaryText = destinationConfig.hostName;
|
primaryText = destinationConfig.hostName;
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||||
|
import { TCloudflareWorkersSync } from "@app/hooks/api/secretSyncs/types/cloudflare-workers-sync";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: TCloudflareWorkersSync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CloudflareWorkersSyncDestinationSection = ({ secretSync }: Props) => {
|
||||||
|
const {
|
||||||
|
destinationConfig: { scriptId }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
return <GenericFieldLabel label="Script ID">{scriptId}</GenericFieldLabel>;
|
||||||
|
};
|
||||||
+4
@@ -19,6 +19,7 @@ import { AzureDevOpsSyncDestinationSection } from "./AzureDevOpsSyncDestinationS
|
|||||||
import { AzureKeyVaultSyncDestinationSection } from "./AzureKeyVaultSyncDestinationSection";
|
import { AzureKeyVaultSyncDestinationSection } from "./AzureKeyVaultSyncDestinationSection";
|
||||||
import { CamundaSyncDestinationSection } from "./CamundaSyncDestinationSection";
|
import { CamundaSyncDestinationSection } from "./CamundaSyncDestinationSection";
|
||||||
import { CloudflarePagesSyncDestinationSection } from "./CloudflarePagesSyncDestinationSection";
|
import { CloudflarePagesSyncDestinationSection } from "./CloudflarePagesSyncDestinationSection";
|
||||||
|
import { CloudflareWorkersSyncDestinationSection } from "./CloudflareWorkersSyncDestinationSection";
|
||||||
import { DatabricksSyncDestinationSection } from "./DatabricksSyncDestinationSection";
|
import { DatabricksSyncDestinationSection } from "./DatabricksSyncDestinationSection";
|
||||||
import { FlyioSyncDestinationSection } from "./FlyioSyncDestinationSection";
|
import { FlyioSyncDestinationSection } from "./FlyioSyncDestinationSection";
|
||||||
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
import { GcpSyncDestinationSection } from "./GcpSyncDestinationSection";
|
||||||
@@ -115,6 +116,9 @@ export const SecretSyncDestinationSection = ({ secretSync, onEditDestination }:
|
|||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
DestinationComponents = <CloudflarePagesSyncDestinationSection secretSync={secretSync} />;
|
DestinationComponents = <CloudflarePagesSyncDestinationSection secretSync={secretSync} />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
|
DestinationComponents = <CloudflareWorkersSyncDestinationSection secretSync={secretSync} />;
|
||||||
|
break;
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
DestinationComponents = <ZabbixSyncDestinationSection secretSync={secretSync} />;
|
DestinationComponents = <ZabbixSyncDestinationSection secretSync={secretSync} />;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
@@ -60,6 +60,7 @@ export const SecretSyncOptionsSection = ({ secretSync, onEditOptions }: Props) =
|
|||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
case SecretSync.GitLab:
|
case SecretSync.GitLab:
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
|
case SecretSync.CloudflareWorkers:
|
||||||
case SecretSync.Zabbix:
|
case SecretSync.Zabbix:
|
||||||
AdditionalSyncOptionsComponent = null;
|
AdditionalSyncOptionsComponent = null;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user