|
1 | 1 | 'use server'; |
2 | 2 |
|
3 | 3 | import db from '@/lib/data/db'; |
4 | | -import { DeploymentInput, DeploymentInputSchema } from '../deployment-schema'; |
5 | 4 | import { getCurrentEnvironment } from '@/components/auth'; |
6 | 5 | import { SuccessType, UserErrorType, userError } from '../user-error'; |
7 | 6 | import Ability from '../ability/abilityHelper'; |
8 | | -import { cacheLife, cacheTag, revalidateTag } from 'next/cache'; |
| 7 | +import { cacheLife, cacheTag } from 'next/cache'; |
9 | 8 |
|
10 | 9 | export async function getDeployedProcesses(environmentId: string, withArchived = false) { |
11 | 10 | const { ability } = await getCurrentEnvironment(environmentId); |
@@ -123,52 +122,3 @@ export async function getProcessDeployments( |
123 | 122 | export type StoredDeployment = SuccessType< |
124 | 123 | Awaited<ReturnType<typeof getProcessDeployments>> |
125 | 124 | >[number]; |
126 | | - |
127 | | -export async function addDeployment( |
128 | | - spaceId: string, |
129 | | - processId: string, |
130 | | - input: DeploymentInput, |
131 | | - ability?: Ability, |
132 | | -) { |
133 | | - if (!ability) ({ ability } = await getCurrentEnvironment(spaceId)); |
134 | | - |
135 | | - if (!ability.can('create', 'Execution')) |
136 | | - return userError('Invalid Permissions', UserErrorType.PermissionError); |
137 | | - |
138 | | - const data = DeploymentInputSchema.parse(input); |
139 | | - |
140 | | - const res = await db.processDeployment.createManyAndReturn({ |
141 | | - data: data.engineIds.map((engineId) => ({ ...data, engineIds: undefined, engineId })), |
142 | | - }); |
143 | | - |
144 | | - revalidateTag(`space/${spaceId}/deployments`, 'max'); |
145 | | - revalidateTag(`deployments/process/${processId}`, 'max'); |
146 | | - |
147 | | - return res; |
148 | | -} |
149 | | - |
150 | | -export async function updateDeployment( |
151 | | - spaceId: string, |
152 | | - processId: string, |
153 | | - deploymentId: string, |
154 | | - input: Partial<DeploymentInput>, |
155 | | - ability?: Ability, |
156 | | -) { |
157 | | - if (!ability) ({ ability } = await getCurrentEnvironment(spaceId)); |
158 | | - |
159 | | - if (!ability.can('update', 'Execution')) { |
160 | | - return userError('Invalid Permissions', UserErrorType.PermissionError); |
161 | | - } |
162 | | - |
163 | | - const data = DeploymentInputSchema.partial().strict().parse(input); |
164 | | - |
165 | | - const result = await db.processDeployment.update({ |
166 | | - where: { id: deploymentId }, |
167 | | - data, |
168 | | - }); |
169 | | - |
170 | | - revalidateTag(`space/${spaceId}/deployments`, 'max'); |
171 | | - revalidateTag(`deployments/process/${processId}`, 'max'); |
172 | | - |
173 | | - return result; |
174 | | -} |
0 commit comments