2021-10-03 20:23:06 +00:00
|
|
|
import http from '@/api/http';
|
|
|
|
import { EggVariable, rawDataToEggVariable } from '@/api/admin/eggs/getEgg';
|
|
|
|
|
2021-10-03 21:51:35 +00:00
|
|
|
export default (eggId: number, variables: Omit<EggVariable, 'eggId' | 'createdAt' | 'updatedAt'>[]): Promise<EggVariable[]> => {
|
2021-10-03 20:23:06 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
http.patch(
|
|
|
|
`/api/application/eggs/${eggId}/variables`,
|
2021-10-03 21:51:35 +00:00
|
|
|
variables.map(variable => ({
|
|
|
|
id: variable.id,
|
|
|
|
name: variable.name,
|
|
|
|
description: variable.description,
|
|
|
|
env_variable: variable.envVariable,
|
|
|
|
default_value: variable.defaultValue,
|
|
|
|
user_viewable: variable.userViewable,
|
|
|
|
user_editable: variable.userEditable,
|
|
|
|
rules: variable.rules,
|
|
|
|
})),
|
2021-10-03 20:23:06 +00:00
|
|
|
)
|
|
|
|
.then(({ data }) => resolve((data.data || []).map(rawDataToEggVariable)))
|
|
|
|
.catch(reject);
|
|
|
|
});
|
|
|
|
};
|