Files
windmill/frontend/src/lib/components/details/utils.ts
T
HugoCasaandRuben Fiszel ae8f29a4cb feat: http routing (#4339)
* feat: http routing

* all

* feat: improve UI

* final stuff

* fix: sqlx

* fix: nit

* fix: nits

* fix: error handler display

* fix: routes panel perms

* all

* fix: improve ability to paste from macos in vscode extension

* fix lock-write for deno

* all

* cleaning

* fix

* cli preprocessor

* nits

* nits

---------

Co-authored-by: Ruben Fiszel <ruben@rubenfiszel.com>
2024-09-20 15:38:38 +02:00

49 lines
1.5 KiB
TypeScript

import { ScriptService, type Script } from '$lib/gen'
export async function deleteScript(hash: string, workspace: string) {
return await ScriptService.deleteScriptByHash({ workspace: workspace, hash })
}
export async function archiveScript(hash: string, workspace: string) {
return await ScriptService.archiveScriptByHash({ workspace: workspace, hash })
}
export async function unarchiveScript(hash: string, workspace: string) {
const r = await ScriptService.getScriptByHash({ workspace: workspace, hash })
const ns = await ScriptService.createScript({
workspace: workspace,
requestBody: {
...r,
parent_hash: hash,
lock: r.lock
}
})
return ns
}
export async function getScriptDeploymentStatus(hash: string, workspace: string): Promise<any> {
return await ScriptService.getScriptDeploymentStatus({
workspace: workspace,
hash: hash
})
}
export async function loadScript(hash: string, workspace: string): Promise<any> {
let script: Script
try {
script = await ScriptService.getScriptByHash({ workspace: workspace, hash })
} catch {
script = await ScriptService.getScriptByPath({ workspace: workspace, path: hash })
hash = script.hash
}
return { script, hash }
}
export function curlCommand(async: boolean, args: any, $page: any, workspace: string, script: any) {
return `curl -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" -X POST -d '${JSON.stringify(
args
)}' ${$page.url.protocol}//${$page.url.hostname}/api/w/${workspace}/jobs/run${
async ? '' : '_wait_result'
}/p/${script?.path}`
}