mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
chore: update zod and react-hook-form integration to use standard-schema resolver; update dependencies in pnpm-lock.yaml
This commit is contained in:
@@ -81,11 +81,12 @@
|
||||
"ssh2": "1.15.0",
|
||||
"toml": "3.0.0",
|
||||
"ws": "8.16.0",
|
||||
"zod": "^3.25.76",
|
||||
"semver": "7.7.3"
|
||||
"zod": "^4.3.6",
|
||||
"semver": "7.7.3",
|
||||
"better-call": "1.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@better-auth/cli": "1.4.18",
|
||||
"@better-auth/cli": "1.5.0-beta.13",
|
||||
"@types/semver": "7.7.1",
|
||||
"@types/adm-zip": "^0.5.7",
|
||||
"@types/bcrypt": "5.0.2",
|
||||
|
||||
@@ -328,9 +328,11 @@ const createSchema = createInsertSchema(applications, {
|
||||
customGitUrl: z.string().optional(),
|
||||
buildPath: z.string().optional(),
|
||||
environmentId: z.string(),
|
||||
// Override pgEnums so Zod 4 infers only string literals, not numeric enum indices
|
||||
sourceType: z
|
||||
.enum(["github", "docker", "git", "gitlab", "bitbucket", "gitea", "drop"])
|
||||
.optional(),
|
||||
triggerType: z.enum(["push", "tag"]).optional(),
|
||||
applicationStatus: z.enum(["idle", "running", "done", "error"]),
|
||||
buildType: z.enum([
|
||||
"dockerfile",
|
||||
|
||||
@@ -162,7 +162,13 @@ const createSchema = createInsertSchema(compose, {
|
||||
customGitSSHKeyId: z.string().optional(),
|
||||
command: z.string().optional(),
|
||||
composePath: z.string().min(1),
|
||||
// Override pgEnums so Zod 4 infers only string literals, not numeric enum indices
|
||||
composeType: z.enum(["docker-compose", "stack"]).optional(),
|
||||
sourceType: z
|
||||
.enum(["git", "github", "gitlab", "bitbucket", "gitea", "raw"])
|
||||
.optional(),
|
||||
triggerType: z.enum(["push", "tag"]).optional(),
|
||||
composeStatus: z.enum(["idle", "running", "done", "error"]).optional(),
|
||||
watchPaths: z.array(z.string()).optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -70,7 +70,11 @@ export const domainsRelations = relations(domains, ({ one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
const createSchema = createInsertSchema(domains, domain._def.schema.shape);
|
||||
const createSchema = createInsertSchema(domains, {
|
||||
...domain.shape,
|
||||
// Override pgEnum so Zod 4 infers only string literals, not numeric enum index
|
||||
domainType: z.enum(["compose", "application", "preview"]).optional(),
|
||||
});
|
||||
|
||||
export const apiCreateDomain = createSchema.pick({
|
||||
host: true,
|
||||
|
||||
@@ -483,7 +483,7 @@ export const apiCreateCustom = notificationsSchema
|
||||
})
|
||||
.extend({
|
||||
endpoint: z.string().min(1),
|
||||
headers: z.record(z.string()).optional(),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
export const apiUpdateCustom = apiCreateCustom.partial().extend({
|
||||
@@ -494,7 +494,7 @@ export const apiUpdateCustom = apiCreateCustom.partial().extend({
|
||||
|
||||
export const apiTestCustomConnection = z.object({
|
||||
endpoint: z.string().min(1),
|
||||
headers: z.record(z.string()).optional(),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
export const apiCreateLark = notificationsSchema
|
||||
|
||||
@@ -133,6 +133,9 @@ const createSchema = createInsertSchema(server, {
|
||||
serverId: z.string().min(1),
|
||||
name: z.string().min(1),
|
||||
description: z.string().optional(),
|
||||
// Override pgEnums so Zod 4 infers only string literals, not numeric enum indices
|
||||
serverType: z.enum(["deploy", "build"]).optional(),
|
||||
serverStatus: z.enum(["active", "inactive"]).optional(),
|
||||
});
|
||||
|
||||
export const apiCreateServer = createSchema
|
||||
@@ -168,10 +171,10 @@ export const apiUpdateServer = createSchema
|
||||
port: true,
|
||||
username: true,
|
||||
sshKeyId: true,
|
||||
serverType: true,
|
||||
})
|
||||
.required()
|
||||
.extend({
|
||||
serverType: z.enum(["deploy", "build"]),
|
||||
command: z.string().optional(),
|
||||
});
|
||||
|
||||
|
||||
@@ -175,12 +175,12 @@ export const NetworkSwarmSchema = z.array(
|
||||
.object({
|
||||
Target: z.string().optional(),
|
||||
Aliases: z.array(z.string()).optional(),
|
||||
DriverOpts: z.record(z.string()).optional(),
|
||||
DriverOpts: z.record(z.string(), z.string()).optional(),
|
||||
})
|
||||
.strict(),
|
||||
);
|
||||
|
||||
export const LabelsSwarmSchema = z.record(z.string());
|
||||
export const LabelsSwarmSchema = z.record(z.string(), z.string());
|
||||
|
||||
export const EndpointPortConfigSwarmSchema = z
|
||||
.object({
|
||||
|
||||
@@ -29,6 +29,7 @@ import { cloneGitlabRepository } from "@dokploy/server/utils/providers/gitlab";
|
||||
import { createTraefikConfig } from "@dokploy/server/utils/traefik/application";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { encodeBase64 } from "../utils/docker/utils";
|
||||
import { getDokployUrl } from "./admin";
|
||||
import {
|
||||
@@ -53,7 +54,7 @@ import { validUniqueServerAppName } from "./project";
|
||||
export type Application = typeof applications.$inferSelect;
|
||||
|
||||
export const createApplication = async (
|
||||
input: typeof apiCreateApplication._type,
|
||||
input: z.infer<typeof apiCreateApplication>,
|
||||
) => {
|
||||
const appName = buildAppName("app", input.appName);
|
||||
|
||||
|
||||
@@ -2,17 +2,16 @@ import { db } from "@dokploy/server/db";
|
||||
import { type apiCreateBackup, backups } from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Backup = typeof backups.$inferSelect;
|
||||
|
||||
export type BackupSchedule = Awaited<ReturnType<typeof findBackupById>>;
|
||||
export type BackupScheduleList = Awaited<ReturnType<typeof findBackupsByDbId>>;
|
||||
export const createBackup = async (input: typeof apiCreateBackup._type) => {
|
||||
export const createBackup = async (input: z.infer<typeof apiCreateBackup>) => {
|
||||
const newBackup = await db
|
||||
.insert(backups)
|
||||
.values({
|
||||
...input,
|
||||
})
|
||||
.values({ ...input } as typeof backups.$inferInsert)
|
||||
.returning()
|
||||
.then((value) => value[0]);
|
||||
|
||||
|
||||
@@ -7,11 +7,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Bitbucket = typeof bitbucket.$inferSelect;
|
||||
|
||||
export const createBitbucket = async (
|
||||
input: typeof apiCreateBitbucket._type,
|
||||
input: z.infer<typeof apiCreateBitbucket>,
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
) => {
|
||||
@@ -65,7 +66,7 @@ export const findBitbucketById = async (bitbucketId: string) => {
|
||||
|
||||
export const updateBitbucket = async (
|
||||
bitbucketId: string,
|
||||
input: typeof apiUpdateBitbucket._type,
|
||||
input: z.infer<typeof apiUpdateBitbucket>,
|
||||
) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
// First get the current bitbucket provider to get gitProviderId
|
||||
|
||||
@@ -33,6 +33,7 @@ import { cloneGitlabRepository } from "@dokploy/server/utils/providers/gitlab";
|
||||
import { getCreateComposeFileCommand } from "@dokploy/server/utils/providers/raw";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { encodeBase64 } from "../utils/docker/utils";
|
||||
import { getDokployUrl } from "./admin";
|
||||
import {
|
||||
@@ -45,7 +46,7 @@ import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export type Compose = typeof compose.$inferSelect;
|
||||
|
||||
export const createCompose = async (input: typeof apiCreateCompose._type) => {
|
||||
export const createCompose = async (input: z.infer<typeof apiCreateCompose>) => {
|
||||
const appName = buildAppName("compose", input.appName);
|
||||
|
||||
const valid = await validUniqueServerAppName(appName);
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { format } from "date-fns";
|
||||
import { desc, eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import {
|
||||
type Application,
|
||||
findApplicationById,
|
||||
@@ -72,7 +73,7 @@ export const findDeploymentByApplicationId = async (applicationId: string) => {
|
||||
|
||||
export const createDeployment = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeployment._type,
|
||||
z.infer<typeof apiCreateDeployment>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
@@ -153,7 +154,7 @@ export const createDeployment = async (
|
||||
|
||||
export const createDeploymentPreview = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeploymentPreview._type,
|
||||
z.infer<typeof apiCreateDeploymentPreview>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
@@ -236,7 +237,7 @@ export const createDeploymentPreview = async (
|
||||
|
||||
export const createDeploymentCompose = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeploymentCompose._type,
|
||||
z.infer<typeof apiCreateDeploymentCompose>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
@@ -313,7 +314,7 @@ echo "Initializing deployment\n" >> ${logFilePath};
|
||||
|
||||
export const createDeploymentBackup = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeploymentBackup._type,
|
||||
z.infer<typeof apiCreateDeploymentBackup>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
@@ -393,7 +394,7 @@ echo "Initializing backup\n" >> ${logFilePath};
|
||||
|
||||
export const createDeploymentSchedule = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeploymentSchedule._type,
|
||||
z.infer<typeof apiCreateDeploymentSchedule>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
@@ -469,7 +470,7 @@ export const createDeploymentSchedule = async (
|
||||
|
||||
export const createDeploymentVolumeBackup = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeploymentVolumeBackup._type,
|
||||
z.infer<typeof apiCreateDeploymentVolumeBackup>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
@@ -773,7 +774,7 @@ export const updateDeploymentStatus = async (
|
||||
|
||||
export const createServerDeployment = async (
|
||||
deployment: Omit<
|
||||
typeof apiCreateDeploymentServer._type,
|
||||
z.infer<typeof apiCreateDeploymentServer>,
|
||||
"deploymentId" | "createdAt" | "status" | "logPath"
|
||||
>,
|
||||
) => {
|
||||
|
||||
@@ -5,11 +5,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Destination = typeof destinations.$inferSelect;
|
||||
|
||||
export const createDestintation = async (
|
||||
input: typeof apiCreateDestination._type,
|
||||
input: z.infer<typeof apiCreateDestination>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
const newDestination = await db
|
||||
|
||||
@@ -6,6 +6,7 @@ import { generateRandomDomain } from "@dokploy/server/templates";
|
||||
import { manageDomain } from "@dokploy/server/utils/traefik/domain";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { type apiCreateDomain, domains } from "../db/schema";
|
||||
import { findApplicationById } from "./application";
|
||||
import { detectCDNProvider } from "./cdn";
|
||||
@@ -13,14 +14,14 @@ import { findServerById } from "./server";
|
||||
|
||||
export type Domain = typeof domains.$inferSelect;
|
||||
|
||||
export const createDomain = async (input: typeof apiCreateDomain._type) => {
|
||||
export const createDomain = async (input: z.infer<typeof apiCreateDomain>) => {
|
||||
const result = await db.transaction(async (tx) => {
|
||||
const domain = await tx
|
||||
.insert(domains)
|
||||
.values({
|
||||
...input,
|
||||
host: input.host?.trim(),
|
||||
})
|
||||
} as typeof domains.$inferInsert)
|
||||
.returning()
|
||||
.then((response) => response[0]);
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { asc, eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Environment = typeof environments.$inferSelect;
|
||||
|
||||
export const createEnvironment = async (
|
||||
input: typeof apiCreateEnvironment._type,
|
||||
input: z.infer<typeof apiCreateEnvironment>,
|
||||
) => {
|
||||
const newEnvironment = await db
|
||||
.insert(environments)
|
||||
@@ -156,7 +157,7 @@ export const updateEnvironmentById = async (
|
||||
};
|
||||
|
||||
export const duplicateEnvironment = async (
|
||||
input: typeof apiDuplicateEnvironment._type,
|
||||
input: z.infer<typeof apiDuplicateEnvironment>,
|
||||
) => {
|
||||
// Find the original environment
|
||||
const originalEnvironment = await findEnvironmentById(input.environmentId);
|
||||
|
||||
@@ -6,11 +6,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Gitea = typeof gitea.$inferSelect;
|
||||
|
||||
export const createGitea = async (
|
||||
input: typeof apiCreateGitea._type,
|
||||
input: z.infer<typeof apiCreateGitea>,
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
) => {
|
||||
|
||||
@@ -6,12 +6,13 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { authGithub } from "../utils/providers/github";
|
||||
import { updatePreviewDeployment } from "./preview-deployment";
|
||||
|
||||
export type Github = typeof github.$inferSelect;
|
||||
export const createGithub = async (
|
||||
input: typeof apiCreateGithub._type,
|
||||
input: z.infer<typeof apiCreateGithub>,
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
) => {
|
||||
|
||||
@@ -6,11 +6,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Gitlab = typeof gitlab.$inferSelect;
|
||||
|
||||
export const createGitlab = async (
|
||||
input: typeof apiCreateGitlab._type,
|
||||
input: z.infer<typeof apiCreateGitlab>,
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
) => {
|
||||
|
||||
@@ -11,11 +11,12 @@ import { pullImage } from "@dokploy/server/utils/docker/utils";
|
||||
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq, getTableColumns } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export type Mariadb = typeof mariadb.$inferSelect;
|
||||
|
||||
export const createMariadb = async (input: typeof apiCreateMariaDB._type) => {
|
||||
export const createMariadb = async (input: z.infer<typeof apiCreateMariaDB>) => {
|
||||
const appName = buildAppName("mariadb", input.appName);
|
||||
|
||||
const valid = await validUniqueServerAppName(appName);
|
||||
|
||||
@@ -12,11 +12,12 @@ import { pullImage } from "@dokploy/server/utils/docker/utils";
|
||||
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq, getTableColumns } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export type Mongo = typeof mongo.$inferSelect;
|
||||
|
||||
export const createMongo = async (input: typeof apiCreateMongo._type) => {
|
||||
export const createMongo = async (input: z.infer<typeof apiCreateMongo>) => {
|
||||
const appName = buildAppName("mongo", input.appName);
|
||||
|
||||
const valid = await validUniqueServerAppName(appName);
|
||||
|
||||
@@ -18,10 +18,11 @@ import {
|
||||
} from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq, type SQL, sql } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Mount = typeof mounts.$inferSelect;
|
||||
|
||||
export const createMount = async (input: typeof apiCreateMount._type) => {
|
||||
export const createMount = async (input: z.infer<typeof apiCreateMount>) => {
|
||||
try {
|
||||
const { serviceId, ...rest } = input;
|
||||
const value = await db
|
||||
|
||||
@@ -11,11 +11,12 @@ import { pullImage } from "@dokploy/server/utils/docker/utils";
|
||||
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq, getTableColumns } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export type MySql = typeof mysql.$inferSelect;
|
||||
|
||||
export const createMysql = async (input: typeof apiCreateMySql._type) => {
|
||||
export const createMysql = async (input: z.infer<typeof apiCreateMySql>) => {
|
||||
const appName = buildAppName("mysql", input.appName);
|
||||
|
||||
const valid = await validUniqueServerAppName(appName);
|
||||
|
||||
@@ -37,11 +37,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Notification = typeof notifications.$inferSelect;
|
||||
|
||||
export const createSlackNotification = async (
|
||||
input: typeof apiCreateSlack._type,
|
||||
input: z.infer<typeof apiCreateSlack>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -91,7 +92,7 @@ export const createSlackNotification = async (
|
||||
};
|
||||
|
||||
export const updateSlackNotification = async (
|
||||
input: typeof apiUpdateSlack._type,
|
||||
input: z.infer<typeof apiUpdateSlack>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -133,7 +134,7 @@ export const updateSlackNotification = async (
|
||||
};
|
||||
|
||||
export const createTelegramNotification = async (
|
||||
input: typeof apiCreateTelegram._type,
|
||||
input: z.infer<typeof apiCreateTelegram>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -184,7 +185,7 @@ export const createTelegramNotification = async (
|
||||
};
|
||||
|
||||
export const updateTelegramNotification = async (
|
||||
input: typeof apiUpdateTelegram._type,
|
||||
input: z.infer<typeof apiUpdateTelegram>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -227,7 +228,7 @@ export const updateTelegramNotification = async (
|
||||
};
|
||||
|
||||
export const createDiscordNotification = async (
|
||||
input: typeof apiCreateDiscord._type,
|
||||
input: z.infer<typeof apiCreateDiscord>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -277,7 +278,7 @@ export const createDiscordNotification = async (
|
||||
};
|
||||
|
||||
export const updateDiscordNotification = async (
|
||||
input: typeof apiUpdateDiscord._type,
|
||||
input: z.infer<typeof apiUpdateDiscord>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -319,7 +320,7 @@ export const updateDiscordNotification = async (
|
||||
};
|
||||
|
||||
export const createEmailNotification = async (
|
||||
input: typeof apiCreateEmail._type,
|
||||
input: z.infer<typeof apiCreateEmail>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -373,7 +374,7 @@ export const createEmailNotification = async (
|
||||
};
|
||||
|
||||
export const updateEmailNotification = async (
|
||||
input: typeof apiUpdateEmail._type,
|
||||
input: z.infer<typeof apiUpdateEmail>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -419,7 +420,7 @@ export const updateEmailNotification = async (
|
||||
};
|
||||
|
||||
export const createResendNotification = async (
|
||||
input: typeof apiCreateResend._type,
|
||||
input: z.infer<typeof apiCreateResend>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -470,7 +471,7 @@ export const createResendNotification = async (
|
||||
};
|
||||
|
||||
export const updateResendNotification = async (
|
||||
input: typeof apiUpdateResend._type,
|
||||
input: z.infer<typeof apiUpdateResend>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -513,7 +514,7 @@ export const updateResendNotification = async (
|
||||
};
|
||||
|
||||
export const createGotifyNotification = async (
|
||||
input: typeof apiCreateGotify._type,
|
||||
input: z.infer<typeof apiCreateGotify>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -564,7 +565,7 @@ export const createGotifyNotification = async (
|
||||
};
|
||||
|
||||
export const updateGotifyNotification = async (
|
||||
input: typeof apiUpdateGotify._type,
|
||||
input: z.infer<typeof apiUpdateGotify>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -605,7 +606,7 @@ export const updateGotifyNotification = async (
|
||||
};
|
||||
|
||||
export const createNtfyNotification = async (
|
||||
input: typeof apiCreateNtfy._type,
|
||||
input: z.infer<typeof apiCreateNtfy>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -656,7 +657,7 @@ export const createNtfyNotification = async (
|
||||
};
|
||||
|
||||
export const updateNtfyNotification = async (
|
||||
input: typeof apiUpdateNtfy._type,
|
||||
input: z.infer<typeof apiUpdateNtfy>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -697,7 +698,7 @@ export const updateNtfyNotification = async (
|
||||
};
|
||||
|
||||
export const createCustomNotification = async (
|
||||
input: typeof apiCreateCustom._type,
|
||||
input: z.infer<typeof apiCreateCustom>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -746,7 +747,7 @@ export const createCustomNotification = async (
|
||||
};
|
||||
|
||||
export const updateCustomNotification = async (
|
||||
input: typeof apiUpdateCustom._type,
|
||||
input: z.infer<typeof apiUpdateCustom>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -821,7 +822,7 @@ export const removeNotificationById = async (notificationId: string) => {
|
||||
};
|
||||
|
||||
export const createLarkNotification = async (
|
||||
input: typeof apiCreateLark._type,
|
||||
input: z.infer<typeof apiCreateLark>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -869,7 +870,7 @@ export const createLarkNotification = async (
|
||||
};
|
||||
|
||||
export const updateLarkNotification = async (
|
||||
input: typeof apiUpdateLark._type,
|
||||
input: z.infer<typeof apiUpdateLark>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -910,7 +911,7 @@ export const updateLarkNotification = async (
|
||||
};
|
||||
|
||||
export const createTeamsNotification = async (
|
||||
input: typeof apiCreateTeams._type,
|
||||
input: z.infer<typeof apiCreateTeams>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -959,7 +960,7 @@ export const createTeamsNotification = async (
|
||||
};
|
||||
|
||||
export const updateTeamsNotification = async (
|
||||
input: typeof apiUpdateTeams._type,
|
||||
input: z.infer<typeof apiUpdateTeams>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
@@ -1015,7 +1016,7 @@ export const updateNotificationById = async (
|
||||
};
|
||||
|
||||
export const createPushoverNotification = async (
|
||||
input: typeof apiCreatePushover._type,
|
||||
input: z.infer<typeof apiCreatePushover>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
@@ -1068,7 +1069,7 @@ export const createPushoverNotification = async (
|
||||
};
|
||||
|
||||
export const updatePushoverNotification = async (
|
||||
input: typeof apiUpdatePushover._type,
|
||||
input: z.infer<typeof apiUpdatePushover>,
|
||||
) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const newDestination = await tx
|
||||
|
||||
@@ -4,13 +4,14 @@ import { db } from "@dokploy/server/db";
|
||||
import { type apiCreatePatch, patch } from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { and, eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { encodeBase64 } from "../utils/docker/utils";
|
||||
import { findApplicationById } from "./application";
|
||||
import { findComposeById } from "./compose";
|
||||
|
||||
export type Patch = typeof patch.$inferSelect;
|
||||
|
||||
export const createPatch = async (input: typeof apiCreatePatch._type) => {
|
||||
export const createPatch = async (input: z.infer<typeof apiCreatePatch>) => {
|
||||
if (!input.applicationId && !input.composeId) {
|
||||
throw new TRPCError({
|
||||
code: "BAD_REQUEST",
|
||||
|
||||
@@ -2,10 +2,11 @@ import { db } from "@dokploy/server/db";
|
||||
import { type apiCreatePort, ports } from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Port = typeof ports.$inferSelect;
|
||||
|
||||
export const createPort = async (input: typeof apiCreatePort._type) => {
|
||||
export const createPort = async (input: z.infer<typeof apiCreatePort>) => {
|
||||
const newPort = await db
|
||||
.insert(ports)
|
||||
.values({
|
||||
|
||||
@@ -11,6 +11,7 @@ import { pullImage } from "@dokploy/server/utils/docker/utils";
|
||||
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq, getTableColumns } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export function getMountPath(dockerImage: string): string {
|
||||
@@ -28,7 +29,7 @@ export function getMountPath(dockerImage: string): string {
|
||||
|
||||
export type Postgres = typeof postgres.$inferSelect;
|
||||
|
||||
export const createPostgres = async (input: typeof apiCreatePostgres._type) => {
|
||||
export const createPostgres = async (input: z.infer<typeof apiCreatePostgres>) => {
|
||||
const appName = buildAppName("postgres", input.appName);
|
||||
|
||||
const valid = await validUniqueServerAppName(appName);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { and, desc, eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { generatePassword } from "../templates";
|
||||
import { removeService } from "../utils/docker/utils";
|
||||
import { removeDirectoryCode } from "../utils/filesystem/directory";
|
||||
@@ -130,7 +131,7 @@ export const findPreviewDeploymentsByApplicationId = async (
|
||||
};
|
||||
|
||||
export const createPreviewDeployment = async (
|
||||
schema: typeof apiCreatePreviewDeployment._type,
|
||||
schema: z.infer<typeof apiCreatePreviewDeployment>,
|
||||
) => {
|
||||
const application = await findApplicationById(schema.applicationId);
|
||||
const appName = `preview-${application.appName}-${generatePassword(6)}`;
|
||||
|
||||
@@ -11,12 +11,13 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { createProductionEnvironment } from "./environment";
|
||||
|
||||
export type Project = typeof projects.$inferSelect;
|
||||
|
||||
export const createProject = async (
|
||||
input: typeof apiCreateProject._type,
|
||||
input: z.infer<typeof apiCreateProject>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
const newProject = await db
|
||||
|
||||
@@ -10,12 +10,13 @@ import { pullImage } from "@dokploy/server/utils/docker/utils";
|
||||
import { execAsyncRemote } from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { validUniqueServerAppName } from "./project";
|
||||
|
||||
export type Redis = typeof redis.$inferSelect;
|
||||
|
||||
// https://github.com/drizzle-team/drizzle-orm/discussions/1483#discussioncomment-7523881
|
||||
export const createRedis = async (input: typeof apiCreateRedis._type) => {
|
||||
export const createRedis = async (input: z.infer<typeof apiCreateRedis>) => {
|
||||
const appName = buildAppName("redis", input.appName);
|
||||
|
||||
const valid = await validUniqueServerAppName(appName);
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
} from "@dokploy/server/utils/process/execAsync";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
import { IS_CLOUD } from "../constants";
|
||||
|
||||
export type Registry = typeof registry.$inferSelect;
|
||||
@@ -27,7 +28,7 @@ function safeDockerLoginCommand(
|
||||
}
|
||||
|
||||
export const createRegistry = async (
|
||||
input: typeof apiCreateRegistry._type,
|
||||
input: z.infer<typeof apiCreateRegistry>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
return await db.transaction(async (tx) => {
|
||||
|
||||
@@ -18,7 +18,10 @@ export const createSchedule = async (
|
||||
input: z.infer<typeof createScheduleSchema>,
|
||||
) => {
|
||||
const { scheduleId, ...rest } = input;
|
||||
const [newSchedule] = await db.insert(schedules).values(rest).returning();
|
||||
const [newSchedule] = await db
|
||||
.insert(schedules)
|
||||
.values(rest as typeof schedules.$inferInsert)
|
||||
.returning();
|
||||
|
||||
if (
|
||||
newSchedule &&
|
||||
@@ -120,7 +123,7 @@ export const updateSchedule = async (
|
||||
const { scheduleId, ...rest } = input;
|
||||
const [updatedSchedule] = await db
|
||||
.update(schedules)
|
||||
.set(rest)
|
||||
.set(rest as Partial<typeof schedules.$inferInsert>)
|
||||
.where(eq(schedules.scheduleId, scheduleId))
|
||||
.returning();
|
||||
|
||||
|
||||
@@ -6,11 +6,12 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type Server = typeof server.$inferSelect;
|
||||
|
||||
export const createServer = async (
|
||||
input: typeof apiCreateServer._type,
|
||||
input: z.infer<typeof apiCreateServer>,
|
||||
organizationId: string,
|
||||
) => {
|
||||
const newServer = await db
|
||||
@@ -19,7 +20,7 @@ export const createServer = async (
|
||||
...input,
|
||||
organizationId: organizationId,
|
||||
createdAt: new Date().toISOString(),
|
||||
})
|
||||
} as typeof server.$inferInsert)
|
||||
.returning()
|
||||
.then((value) => value[0]);
|
||||
|
||||
|
||||
@@ -8,8 +8,9 @@ import {
|
||||
} from "@dokploy/server/db/schema";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { z } from "zod";
|
||||
|
||||
export const createSshKey = async (input: typeof apiCreateSshKey._type) => {
|
||||
export const createSshKey = async (input: z.infer<typeof apiCreateSshKey>) => {
|
||||
await db.transaction(async (tx) => {
|
||||
const sshKey = await tx
|
||||
.insert(sshKeys)
|
||||
@@ -29,7 +30,7 @@ export const createSshKey = async (input: typeof apiCreateSshKey._type) => {
|
||||
};
|
||||
|
||||
export const removeSSHKeyById = async (
|
||||
sshKeyId: (typeof apiRemoveSshKey._type)["sshKeyId"],
|
||||
sshKeyId: z.infer<typeof apiRemoveSshKey>["sshKeyId"],
|
||||
) => {
|
||||
const result = await db
|
||||
.delete(sshKeys)
|
||||
@@ -42,7 +43,7 @@ export const removeSSHKeyById = async (
|
||||
export const updateSSHKeyById = async ({
|
||||
sshKeyId,
|
||||
...input
|
||||
}: typeof apiUpdateSshKey._type) => {
|
||||
}: z.infer<typeof apiUpdateSshKey>) => {
|
||||
const result = await db
|
||||
.update(sshKeys)
|
||||
.set(input)
|
||||
@@ -53,7 +54,7 @@ export const updateSSHKeyById = async ({
|
||||
};
|
||||
|
||||
export const findSSHKeyById = async (
|
||||
sshKeyId: (typeof apiFindOneSshKey._type)["sshKeyId"],
|
||||
sshKeyId: z.infer<typeof apiFindOneSshKey>["sshKeyId"],
|
||||
) => {
|
||||
const sshKey = await db.query.sshKeys.findFirst({
|
||||
where: eq(sshKeys.sshKeyId, sshKeyId),
|
||||
|
||||
@@ -94,7 +94,7 @@ export const createVolumeBackup = async (
|
||||
) => {
|
||||
const newVolumeBackup = await db
|
||||
.insert(volumeBackups)
|
||||
.values(volumeBackup)
|
||||
.values(volumeBackup as typeof volumeBackups.$inferInsert)
|
||||
.returning()
|
||||
.then((e) => e[0]);
|
||||
|
||||
@@ -113,7 +113,7 @@ export const updateVolumeBackup = async (
|
||||
) => {
|
||||
return await db
|
||||
.update(volumeBackups)
|
||||
.set(volumeBackup)
|
||||
.set(volumeBackup as Partial<typeof volumeBackups.$inferInsert>)
|
||||
.where(eq(volumeBackups.volumeBackupId, volumeBackupId))
|
||||
.returning()
|
||||
.then((e) => e[0]);
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "@dokploy/server/services/bitbucket";
|
||||
import type { InferResultType } from "@dokploy/server/types/with";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import type { z } from "zod";
|
||||
|
||||
export type ApplicationWithBitbucket = InferResultType<
|
||||
"applications",
|
||||
@@ -179,7 +180,7 @@ export const getBitbucketRepositories = async (bitbucketId?: string) => {
|
||||
};
|
||||
|
||||
export const getBitbucketBranches = async (
|
||||
input: typeof apiFindBitbucketBranches._type,
|
||||
input: z.infer<typeof apiFindBitbucketBranches>,
|
||||
) => {
|
||||
if (!input.bitbucketId) {
|
||||
return [];
|
||||
@@ -234,7 +235,7 @@ export const getBitbucketBranches = async (
|
||||
};
|
||||
|
||||
export const testBitbucketConnection = async (
|
||||
input: typeof apiBitbucketTestConnection._type,
|
||||
input: z.infer<typeof apiBitbucketTestConnection>,
|
||||
) => {
|
||||
const bitbucketProvider = await findBitbucketById(input.bitbucketId);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { findGithubById, type Github } from "@dokploy/server/services/github";
|
||||
import type { InferResultType } from "@dokploy/server/types/with";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
import { TRPCError } from "@trpc/server";
|
||||
import type { z } from "zod";
|
||||
import { Octokit } from "octokit";
|
||||
|
||||
export const authGithub = (githubProvider: Github): Octokit => {
|
||||
@@ -197,7 +198,7 @@ export const getGithubRepositories = async (githubId?: string) => {
|
||||
};
|
||||
|
||||
export const getGithubBranches = async (
|
||||
input: typeof apiFindGithubBranches._type,
|
||||
input: z.infer<typeof apiFindGithubBranches>,
|
||||
) => {
|
||||
if (!input.githubId) {
|
||||
return [];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { join } from "node:path";
|
||||
import { paths } from "@dokploy/server/constants";
|
||||
import type { apiGitlabTestConnection } from "@dokploy/server/db/schema";
|
||||
import type { z } from "zod";
|
||||
import {
|
||||
findGitlabById,
|
||||
type Gitlab,
|
||||
@@ -171,7 +172,7 @@ export const getGitlabRepositories = async (gitlabId?: string) => {
|
||||
if (groupName) {
|
||||
return groupName
|
||||
.split(",")
|
||||
.some((name) =>
|
||||
.some((name: string) =>
|
||||
full_path.toLowerCase().startsWith(name.trim().toLowerCase()),
|
||||
);
|
||||
}
|
||||
@@ -256,7 +257,7 @@ export const getGitlabBranches = async (input: {
|
||||
};
|
||||
|
||||
export const testGitlabConnection = async (
|
||||
input: typeof apiGitlabTestConnection._type,
|
||||
input: z.infer<typeof apiGitlabTestConnection>,
|
||||
) => {
|
||||
const { gitlabId, groupName } = input;
|
||||
|
||||
@@ -276,7 +277,7 @@ export const testGitlabConnection = async (
|
||||
if (groupName) {
|
||||
return groupName
|
||||
.split(",")
|
||||
.some((name) =>
|
||||
.some((name: string) =>
|
||||
full_path.toLowerCase().startsWith(name.trim().toLowerCase()),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user