mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-22 21:38:05 -05:00
* my test changes for branch protection * feat(api): introduced 'deploy as an API' button and updated workflows db to include status of deployment * feat(api): added 'trigger' column for logs table to indicate source of workflow run, persist logs from API executions, removed session validation in favor of API key * fix(bug): cleanup old reference to JSX element in favor of ReactElement * feat(api): added persistent notification for one-click deployment with copy boxes for url, keys, & ex curl * fix(ui/notifications): cleaned up deploy with one-click button ui
31 lines
800 B
TypeScript
31 lines
800 B
TypeScript
import { eq } from 'drizzle-orm'
|
|
import { db } from '@/db'
|
|
import { workflow as workflowTable } from '@/db/schema'
|
|
|
|
export async function getWorkflowById(id: string) {
|
|
const workflows = await db.select().from(workflowTable).where(eq(workflowTable.id, id)).limit(1)
|
|
|
|
return workflows[0]
|
|
}
|
|
|
|
export async function updateWorkflowDeploymentStatus(
|
|
id: string,
|
|
isDeployed: boolean,
|
|
apiKey?: string
|
|
) {
|
|
return db
|
|
.update(workflowTable)
|
|
.set({
|
|
isDeployed,
|
|
deployedAt: isDeployed ? new Date() : null,
|
|
updatedAt: new Date(),
|
|
apiKey: apiKey || null,
|
|
})
|
|
.where(eq(workflowTable.id, id))
|
|
}
|
|
|
|
export function getWorkflowEndpoint(id: string) {
|
|
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'
|
|
return `${baseUrl}/api/workflow/${id}`
|
|
}
|