//native
import * as wmill from "windmill-client"
// windmill-client errors only carry the status text: throw the response body, which says why
wmill.OpenAPI.interceptors.response.use(async (response) => {
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return response
})
export type DynSelect_path = string
export async function path() {
const resources = await wmill.ResourceService.listResource({
workspace: wmill.getWorkspace(),
perPage: 1000,
})
return resources.map((r) => ({
value: r.path,
label: `${r.path} (${r.resource_type})`,
}))
}
/**
* Get Resource
* Get a resource by path: resource type, description and raw value (references to variables and other resources are left as `$var:`/`$res:` strings).
*/
export async function main(path: DynSelect_path) {
return await wmill.ResourceService.getResource({
workspace: wmill.getWorkspace(),
path,
})
}
Submitted by hugo989 5 hours ago