Review fixes

This commit is contained in:
x032205
2025-06-17 16:05:09 -04:00
parent 76c95ace63
commit 1921346b4f
4 changed files with 13 additions and 6 deletions
@@ -3,6 +3,7 @@ import { AxiosError } from "axios";
import { request } from "@app/lib/config/request"; import { request } from "@app/lib/config/request";
import { BadRequestError } from "@app/lib/errors"; import { BadRequestError } from "@app/lib/errors";
import { AppConnection } from "@app/services/app-connection/app-connection-enums"; import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
import { FlyioConnectionMethod } from "./flyio-connection-enums"; import { FlyioConnectionMethod } from "./flyio-connection-enums";
import { TFlyioApp, TFlyioConnection, TFlyioConnectionConfig } from "./flyio-connection-types"; import { TFlyioApp, TFlyioConnection, TFlyioConnectionConfig } from "./flyio-connection-types";
@@ -20,7 +21,7 @@ export const validateFlyioConnectionCredentials = async (config: TFlyioConnectio
try { try {
await request.post( await request.post(
"https://api.fly.io/graphql", IntegrationUrls.FLYIO_API_URL,
{ query: "query { viewer { id email } }" }, { query: "query { viewer { id email } }" },
{ {
headers: { headers: {
@@ -47,7 +48,7 @@ export const listFlyioApps = async (appConnection: TFlyioConnection) => {
const { accessToken } = appConnection.credentials; const { accessToken } = appConnection.credentials;
const resp = await request.post<{ data: { apps: { nodes: TFlyioApp[] } } }>( const resp = await request.post<{ data: { apps: { nodes: TFlyioApp[] } } }>(
"https://api.fly.io/graphql", IntegrationUrls.FLYIO_API_URL,
{ {
query: query:
"query GetApps { apps { nodes { id name hostname status organization { id slug } currentRelease { version status createdAt } } } }" "query GetApps { apps { nodes { id name hostname status organization { id slug } currentRelease { version status createdAt } } } }"
@@ -16,6 +16,7 @@ export const FlyioConnectionAccessTokenCredentialsSchema = z.object({
.trim() .trim()
.min(1, "Access Token required") .min(1, "Access Token required")
.max(1000) .max(1000)
.startsWith("FlyV1", "Token must start with 'FlyV1'")
.describe(AppConnections.CREDENTIALS.FLYIO.accessToken) .describe(AppConnections.CREDENTIALS.FLYIO.accessToken)
}); });
@@ -1,4 +1,5 @@
import { request } from "@app/lib/config/request"; import { request } from "@app/lib/config/request";
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
import { import {
TDeleteFlyioVariable, TDeleteFlyioVariable,
TFlyioListVariables, TFlyioListVariables,
@@ -14,7 +15,7 @@ import { SECRET_SYNC_NAME_MAP } from "../secret-sync-maps";
const listFlyioSecrets = async ({ accessToken, appId }: TFlyioListVariables) => { const listFlyioSecrets = async ({ accessToken, appId }: TFlyioListVariables) => {
const { data } = await request.post<{ data: { app: { secrets: TFlyioSecret[] } } }>( const { data } = await request.post<{ data: { app: { secrets: TFlyioSecret[] } } }>(
"https://api.fly.io/graphql", IntegrationUrls.FLYIO_API_URL,
{ {
query: "query GetAppSecrets($appId: String!) { app(id: $appId) { id name secrets { name createdAt } } }", query: "query GetAppSecrets($appId: String!) { app(id: $appId) { id name secrets { name createdAt } } }",
variables: { appId } variables: { appId }
@@ -33,7 +34,7 @@ const listFlyioSecrets = async ({ accessToken, appId }: TFlyioListVariables) =>
const putFlyioSecrets = async ({ accessToken, appId, secretMap }: TPutFlyioVariable) => { const putFlyioSecrets = async ({ accessToken, appId, secretMap }: TPutFlyioVariable) => {
return request.post( return request.post(
"https://api.fly.io/graphql", IntegrationUrls.FLYIO_API_URL,
{ {
query: query:
"mutation SetAppSecrets($appId: ID!, $secrets: [SecretInput!]!) { setSecrets(input: { appId: $appId, secrets: $secrets }) { app { name } release { version } } }", "mutation SetAppSecrets($appId: ID!, $secrets: [SecretInput!]!) { setSecrets(input: { appId: $appId, secrets: $secrets }) { app { name } release { version } } }",
@@ -53,7 +54,7 @@ const putFlyioSecrets = async ({ accessToken, appId, secretMap }: TPutFlyioVaria
const deleteFlyioSecrets = async ({ accessToken, appId, keys }: TDeleteFlyioVariable) => { const deleteFlyioSecrets = async ({ accessToken, appId, keys }: TDeleteFlyioVariable) => {
return request.post( return request.post(
"https://api.fly.io/graphql", IntegrationUrls.FLYIO_API_URL,
{ {
query: query:
"mutation UnsetAppSecrets($appId: ID!, $keys: [String!]!) { unsetSecrets(input: { appId: $appId, keys: $keys }) { app { name } release { version } } }", "mutation UnsetAppSecrets($appId: ID!, $keys: [String!]!) { unsetSecrets(input: { appId: $appId, keys: $keys }) { app { name } release { version } } }",
@@ -32,7 +32,11 @@ const formSchema = z.discriminatedUnion("method", [
rootSchema.extend({ rootSchema.extend({
method: z.literal(FlyioConnectionMethod.AccessToken), method: z.literal(FlyioConnectionMethod.AccessToken),
credentials: z.object({ credentials: z.object({
accessToken: z.string().trim().min(1, "Access Token required") accessToken: z
.string()
.trim()
.min(1, "Access Token required")
.startsWith("FlyV1", "Token must start with 'FlyV1'")
}) })
}) })
]); ]);