feat(variables): introduce variable management system
- Added a new module for managing variables, including creation, retrieval, updating, and deletion functionalities. - Implemented a new API endpoint for variable operations, allowing users to interact with variables through HTTP requests. - Enhanced the configuration reference system to support variable references, replacing the previous KV reference system. - Updated existing workflows and scripts to utilize the new variable management features, improving flexibility in configuration handling. - Introduced smoke tests to validate the functionality of the variable system, ensuring reliability and robustness. This update significantly enhances the ability to manage dynamic variables within workflows, improving overall usability and maintainability.
This commit is contained in:
@@ -336,6 +336,33 @@ export function useDeleteSecret() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useVariables(owner) {
|
||||
return useQuery({
|
||||
queryKey: ["variables", owner ?? "all"],
|
||||
queryFn: async () => {
|
||||
const params = owner ? { owner } : {};
|
||||
return (await api.get("/variables", { params })).data.variables;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpsertVariable() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (body) => (await api.put("/variables", body)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["variables"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteVariable() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (id) =>
|
||||
(await api.delete(`/variables/${encodeURIComponent(id)}`)).data,
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["variables"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useKvNamespaces() {
|
||||
return useQuery({
|
||||
queryKey: ["kv", "namespaces"],
|
||||
|
||||
Reference in New Issue
Block a user