mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 11:29:42 +00:00
* feat: checkly app connection --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
63 lines
2.2 KiB
TypeScript
63 lines
2.2 KiB
TypeScript
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 { ChecklyConnectionMethod } from "./checkly-connection-constants";
|
|
|
|
export const ChecklyConnectionMethodSchema = z
|
|
.nativeEnum(ChecklyConnectionMethod)
|
|
.describe(AppConnections.CREATE(AppConnection.Checkly).method);
|
|
|
|
export const ChecklyConnectionAccessTokenCredentialsSchema = z.object({
|
|
apiKey: z.string().trim().min(1, "API Key required").max(255).describe(AppConnections.CREDENTIALS.CHECKLY.apiKey)
|
|
});
|
|
|
|
const BaseChecklyConnectionSchema = BaseAppConnectionSchema.extend({
|
|
app: z.literal(AppConnection.Checkly)
|
|
});
|
|
|
|
export const ChecklyConnectionSchema = BaseChecklyConnectionSchema.extend({
|
|
method: ChecklyConnectionMethodSchema,
|
|
credentials: ChecklyConnectionAccessTokenCredentialsSchema
|
|
});
|
|
|
|
export const SanitizedChecklyConnectionSchema = z.discriminatedUnion("method", [
|
|
BaseChecklyConnectionSchema.extend({
|
|
method: ChecklyConnectionMethodSchema,
|
|
credentials: ChecklyConnectionAccessTokenCredentialsSchema.pick({})
|
|
})
|
|
]);
|
|
|
|
export const ValidateChecklyConnectionCredentialsSchema = z.discriminatedUnion("method", [
|
|
z.object({
|
|
method: ChecklyConnectionMethodSchema,
|
|
credentials: ChecklyConnectionAccessTokenCredentialsSchema.describe(
|
|
AppConnections.CREATE(AppConnection.Checkly).credentials
|
|
)
|
|
})
|
|
]);
|
|
|
|
export const CreateChecklyConnectionSchema = ValidateChecklyConnectionCredentialsSchema.and(
|
|
GenericCreateAppConnectionFieldsSchema(AppConnection.Checkly)
|
|
);
|
|
|
|
export const UpdateChecklyConnectionSchema = z
|
|
.object({
|
|
credentials: ChecklyConnectionAccessTokenCredentialsSchema.optional().describe(
|
|
AppConnections.UPDATE(AppConnection.Checkly).credentials
|
|
)
|
|
})
|
|
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Checkly));
|
|
|
|
export const ChecklyConnectionListItemSchema = z.object({
|
|
name: z.literal("Checkly"),
|
|
app: z.literal(AppConnection.Checkly),
|
|
methods: z.nativeEnum(ChecklyConnectionMethod).array()
|
|
});
|