mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 01:27:41 +00:00
fix: greptile review comments
This commit is contained in:
@@ -148,7 +148,7 @@ export const listLaravelForgeServers = async (
|
|||||||
export const listLaravelForgeSites = async (
|
export const listLaravelForgeSites = async (
|
||||||
appConnection: TLaravelForgeConnection,
|
appConnection: TLaravelForgeConnection,
|
||||||
organizationSlug: string,
|
organizationSlug: string,
|
||||||
serverId: string
|
serverId: number
|
||||||
): Promise<TLaravelForgeSite[]> => {
|
): Promise<TLaravelForgeSite[]> => {
|
||||||
const { credentials } = appConnection;
|
const { credentials } = appConnection;
|
||||||
const { apiToken } = credentials;
|
const { apiToken } = credentials;
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ export const laravelForgeConnectionService = (getAppConnection: TGetAppConnectio
|
|||||||
connectionId: string,
|
connectionId: string,
|
||||||
actor: OrgServiceActor,
|
actor: OrgServiceActor,
|
||||||
organizationSlug: string,
|
organizationSlug: string,
|
||||||
serverId: string
|
serverId: number
|
||||||
): Promise<TLaravelForgeSite[]> => {
|
): Promise<TLaravelForgeSite[]> => {
|
||||||
const appConnection = await getAppConnection(AppConnection.LaravelForge, connectionId, actor);
|
const appConnection = await getAppConnection(AppConnection.LaravelForge, connectionId, actor);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import RE2 from "re2";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { SecretSyncs } from "@app/lib/api-docs";
|
import { SecretSyncs } from "@app/lib/api-docs";
|
||||||
@@ -10,10 +11,25 @@ import {
|
|||||||
} from "@app/services/secret-sync/secret-sync-schemas";
|
} from "@app/services/secret-sync/secret-sync-schemas";
|
||||||
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
|
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
const slugValidator = (val: string) => {
|
||||||
|
return new RE2("^[a-z0-9.-]+$").test(val) && !new RE2(".[-]$").test(val);
|
||||||
|
};
|
||||||
|
|
||||||
const LaravelForgeSyncDestinationConfigSchema = z.object({
|
const LaravelForgeSyncDestinationConfigSchema = z.object({
|
||||||
orgSlug: z.string().min(1, "Org Slug is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgSlug),
|
orgSlug: z
|
||||||
|
.string()
|
||||||
|
.min(1, "Org Slug is required")
|
||||||
|
.max(512, "Org Slug cannot exceed 512 characters")
|
||||||
|
.refine(
|
||||||
|
(val) => slugValidator(val),
|
||||||
|
"Org Slug can only contain lowercase letters, numbers, dots, and dashes, and cannot end with a dot or dash."
|
||||||
|
)
|
||||||
|
.describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgSlug),
|
||||||
orgName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgName),
|
orgName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.orgName),
|
||||||
serverId: z.string().min(1, "Server ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverId),
|
serverId: z.coerce
|
||||||
|
.number()
|
||||||
|
.int("Server ID must be a valid integer")
|
||||||
|
.describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverId),
|
||||||
serverName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverName),
|
serverName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.serverName),
|
||||||
siteId: z.string().min(1, "Site ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteId),
|
siteId: z.string().min(1, "Site ID is required").describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteId),
|
||||||
siteName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteName)
|
siteName: z.string().optional().describe(SecretSyncs.DESTINATION_CONFIG.LARAVEL_FORGE.siteName)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export type TLaravelForgeSyncWithCredentials = TLaravelForgeSync & {
|
|||||||
export type TGetLaravelForgeSecrets = {
|
export type TGetLaravelForgeSecrets = {
|
||||||
apiToken: string;
|
apiToken: string;
|
||||||
orgSlug: string;
|
orgSlug: string;
|
||||||
serverId: string;
|
serverId: number;
|
||||||
siteId: string;
|
siteId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ description: "Learn how to configure a Laravel Forge Sync for Infisical."
|
|||||||
"destinationConfig": {
|
"destinationConfig": {
|
||||||
"orgSlug": "org-abc123",
|
"orgSlug": "org-abc123",
|
||||||
"serverId": "server-abc123",
|
"serverId": "server-abc123",
|
||||||
"siteId": "site-abc123",
|
"siteId": "site-abc123"
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
@@ -147,7 +147,7 @@ description: "Learn how to configure a Laravel Forge Sync for Infisical."
|
|||||||
"destinationConfig": {
|
"destinationConfig": {
|
||||||
"orgSlug": "org-abc123",
|
"orgSlug": "org-abc123",
|
||||||
"serverId": "server-abc123",
|
"serverId": "server-abc123",
|
||||||
"siteId": "site-abc123",
|
"siteId": "site-abc123"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ const laravelForgeConnectionKeys = {
|
|||||||
all: [...appConnectionKeys.all, "laravel-forge"] as const,
|
all: [...appConnectionKeys.all, "laravel-forge"] as const,
|
||||||
listOrganizations: (connectionId: string) =>
|
listOrganizations: (connectionId: string) =>
|
||||||
[...laravelForgeConnectionKeys.all, "organizations", connectionId] as const,
|
[...laravelForgeConnectionKeys.all, "organizations", connectionId] as const,
|
||||||
listServers: (connectionId: string, organizationSlug?: string) =>
|
listServers: (connectionId: string, organizationSlug: string) =>
|
||||||
[...laravelForgeConnectionKeys.all, "servers", connectionId, organizationSlug] as const,
|
[...laravelForgeConnectionKeys.all, "servers", connectionId, organizationSlug] as const,
|
||||||
listSites: (connectionId: string, organizationSlug?: string, serverId?: string) =>
|
listSites: (connectionId: string, organizationSlug: string, serverId: number) =>
|
||||||
[...laravelForgeConnectionKeys.all, "sites", connectionId, organizationSlug, serverId] as const
|
[...laravelForgeConnectionKeys.all, "sites", connectionId, organizationSlug, serverId] as const
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ export const useLaravelForgeConnectionListServers = (
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: laravelForgeConnectionKeys.listServers(connectionId, organizationSlug),
|
queryKey: laravelForgeConnectionKeys.listServers(connectionId, organizationSlug),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const params = organizationSlug ? { organizationSlug } : {};
|
const params = { organizationSlug };
|
||||||
const { data } = await apiRequest.get<TLaravelForgeServer[]>(
|
const { data } = await apiRequest.get<TLaravelForgeServer[]>(
|
||||||
`/api/v1/app-connections/laravel-forge/${connectionId}/servers`,
|
`/api/v1/app-connections/laravel-forge/${connectionId}/servers`,
|
||||||
{ params }
|
{ params }
|
||||||
@@ -64,15 +64,15 @@ export const useLaravelForgeConnectionListServers = (
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
enabled: Boolean(connectionId),
|
enabled: Boolean(connectionId && organizationSlug),
|
||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useLaravelForgeConnectionListSites = (
|
export const useLaravelForgeConnectionListSites = (
|
||||||
connectionId: string,
|
connectionId: string,
|
||||||
organizationSlug?: string,
|
organizationSlug: string,
|
||||||
serverId?: string,
|
serverId: number,
|
||||||
options?: Omit<
|
options?: Omit<
|
||||||
UseQueryOptions<
|
UseQueryOptions<
|
||||||
TLaravelForgeSite[],
|
TLaravelForgeSite[],
|
||||||
@@ -86,9 +86,10 @@ export const useLaravelForgeConnectionListSites = (
|
|||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: laravelForgeConnectionKeys.listSites(connectionId, organizationSlug, serverId),
|
queryKey: laravelForgeConnectionKeys.listSites(connectionId, organizationSlug, serverId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const params: Record<string, string> = {};
|
const params = {
|
||||||
if (organizationSlug) params.organizationSlug = organizationSlug;
|
organizationSlug,
|
||||||
if (serverId) params.serverId = serverId;
|
serverId
|
||||||
|
};
|
||||||
|
|
||||||
const { data } = await apiRequest.get<TLaravelForgeSite[]>(
|
const { data } = await apiRequest.get<TLaravelForgeSite[]>(
|
||||||
`/api/v1/app-connections/laravel-forge/${connectionId}/sites`,
|
`/api/v1/app-connections/laravel-forge/${connectionId}/sites`,
|
||||||
@@ -97,7 +98,7 @@ export const useLaravelForgeConnectionListSites = (
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
enabled: Boolean(connectionId),
|
enabled: Boolean(connectionId && organizationSlug && serverId),
|
||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export type TLaravelForgeSync = TRootSecretSync & {
|
|||||||
destinationConfig: {
|
destinationConfig: {
|
||||||
orgSlug: string;
|
orgSlug: string;
|
||||||
orgName: string;
|
orgName: string;
|
||||||
serverId: string;
|
serverId: number;
|
||||||
serverName: string;
|
serverName: string;
|
||||||
siteId: string;
|
siteId: string;
|
||||||
siteName: string;
|
siteName: string;
|
||||||
|
|||||||
-1
@@ -10,6 +10,5 @@ type Props = {
|
|||||||
export const LaravelForgeSyncDestinationCol = ({ secretSync }: Props) => {
|
export const LaravelForgeSyncDestinationCol = ({ secretSync }: Props) => {
|
||||||
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
||||||
|
|
||||||
console.log({ secretSync });
|
|
||||||
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user