mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-09 21:45:17 +00:00
feat: add triggerType field to application schema for enhanced event handling
This commit is contained in:
@@ -43,7 +43,6 @@ import {
|
|||||||
restoreWebServerBackup,
|
restoreWebServerBackup,
|
||||||
} from "@dokploy/server/utils/restore";
|
} from "@dokploy/server/utils/restore";
|
||||||
import { TRPCError } from "@trpc/server";
|
import { TRPCError } from "@trpc/server";
|
||||||
import { observable } from "@trpc/server/observable";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { createTRPCRouter, protectedProcedure } from "@/server/api/trpc";
|
import { createTRPCRouter, protectedProcedure } from "@/server/api/trpc";
|
||||||
import {
|
import {
|
||||||
@@ -375,58 +374,59 @@ export const backupRouter = createTRPCRouter({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.input(apiRestoreBackup)
|
.input(apiRestoreBackup)
|
||||||
.subscription(async ({ input }) => {
|
.subscription(async function* ({ input, signal }) {
|
||||||
const destination = await findDestinationById(input.destinationId);
|
const destination = await findDestinationById(input.destinationId);
|
||||||
|
const queue: string[] = [];
|
||||||
|
const done = false;
|
||||||
if (input.backupType === "database") {
|
if (input.backupType === "database") {
|
||||||
if (input.databaseType === "postgres") {
|
if (input.databaseType === "postgres") {
|
||||||
const postgres = await findPostgresById(input.databaseId);
|
const postgres = await findPostgresById(input.databaseId);
|
||||||
|
|
||||||
return observable<string>((emit) => {
|
restorePostgresBackup(postgres, destination, input, (log) => {
|
||||||
restorePostgresBackup(postgres, destination, input, (log) => {
|
queue.push(log);
|
||||||
emit.next(log);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.databaseType === "mysql") {
|
if (input.databaseType === "mysql") {
|
||||||
const mysql = await findMySqlById(input.databaseId);
|
const mysql = await findMySqlById(input.databaseId);
|
||||||
return observable<string>((emit) => {
|
restoreMySqlBackup(mysql, destination, input, (log) => {
|
||||||
restoreMySqlBackup(mysql, destination, input, (log) => {
|
queue.push(log);
|
||||||
emit.next(log);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (input.databaseType === "mariadb") {
|
if (input.databaseType === "mariadb") {
|
||||||
const mariadb = await findMariadbById(input.databaseId);
|
const mariadb = await findMariadbById(input.databaseId);
|
||||||
return observable<string>((emit) => {
|
restoreMariadbBackup(mariadb, destination, input, (log) => {
|
||||||
restoreMariadbBackup(mariadb, destination, input, (log) => {
|
queue.push(log);
|
||||||
emit.next(log);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (input.databaseType === "mongo") {
|
if (input.databaseType === "mongo") {
|
||||||
const mongo = await findMongoById(input.databaseId);
|
const mongo = await findMongoById(input.databaseId);
|
||||||
return observable<string>((emit) => {
|
restoreMongoBackup(mongo, destination, input, (log) => {
|
||||||
restoreMongoBackup(mongo, destination, input, (log) => {
|
queue.push(log);
|
||||||
emit.next(log);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (input.databaseType === "web-server") {
|
if (input.databaseType === "web-server") {
|
||||||
return observable<string>((emit) => {
|
restoreWebServerBackup(destination, input.backupFile, (log) => {
|
||||||
restoreWebServerBackup(destination, input.backupFile, (log) => {
|
queue.push(log);
|
||||||
emit.next(log);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input.backupType === "compose") {
|
if (input.backupType === "compose") {
|
||||||
const compose = await findComposeById(input.databaseId);
|
const compose = await findComposeById(input.databaseId);
|
||||||
return observable<string>((emit) => {
|
restoreComposeBackup(compose, destination, input, (log) => {
|
||||||
restoreComposeBackup(compose, destination, input, (log) => {
|
queue.push(log);
|
||||||
emit.next(log);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return true;
|
while (!done || queue.length > 0) {
|
||||||
|
if (queue.length > 0) {
|
||||||
|
yield queue.shift()!;
|
||||||
|
} else {
|
||||||
|
await new Promise((r) => setTimeout(r, 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signal?.aborted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -473,6 +473,7 @@ export const projectRouter = createTRPCRouter({
|
|||||||
await createPreviewDeployment({
|
await createPreviewDeployment({
|
||||||
...rest,
|
...rest,
|
||||||
applicationId: newApplication.applicationId,
|
applicationId: newApplication.applicationId,
|
||||||
|
domainId: undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -331,6 +331,7 @@ const createSchema = createInsertSchema(applications, {
|
|||||||
sourceType: z
|
sourceType: z
|
||||||
.enum(["github", "docker", "git", "gitlab", "bitbucket", "gitea", "drop"])
|
.enum(["github", "docker", "git", "gitlab", "bitbucket", "gitea", "drop"])
|
||||||
.optional(),
|
.optional(),
|
||||||
|
triggerType: z.enum(["push", "tag"]).optional(),
|
||||||
applicationStatus: z.enum(["idle", "running", "done", "error"]),
|
applicationStatus: z.enum(["idle", "running", "done", "error"]),
|
||||||
buildType: z.enum([
|
buildType: z.enum([
|
||||||
"dockerfile",
|
"dockerfile",
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ const createSchema = createInsertSchema(compose, {
|
|||||||
composePath: z.string().min(1),
|
composePath: z.string().min(1),
|
||||||
composeType: z.enum(["docker-compose", "stack"]).optional(),
|
composeType: z.enum(["docker-compose", "stack"]).optional(),
|
||||||
watchPaths: z.array(z.string()).optional(),
|
watchPaths: z.array(z.string()).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(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCreateCompose = createSchema.pick({
|
export const apiCreateCompose = createSchema.pick({
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ const createSchema = createInsertSchema(server, {
|
|||||||
serverId: z.string().min(1),
|
serverId: z.string().min(1),
|
||||||
name: z.string().min(1),
|
name: z.string().min(1),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
|
serverType: z.enum(["deploy", "build"]).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const apiCreateServer = createSchema
|
export const apiCreateServer = createSchema
|
||||||
|
|||||||
Reference in New Issue
Block a user