parent
62faaf6384
commit
259aacca67
|
|
@ -241,15 +241,81 @@ export class ThemesApiClient {
|
||||||
async createOrUpdateThemeFile(
|
async createOrUpdateThemeFile(
|
||||||
themeName: string,
|
themeName: string,
|
||||||
path: string,
|
path: string,
|
||||||
data: unknown
|
data: string | Record<string, unknown> | ArrayBuffer
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const response: ApiResponse = await this.#apiClient.put(
|
const response: ApiResponse = await this.#apiClient.put(
|
||||||
`${this.#THEMES_API_PREFIX}/${themeName}/files/${path}`,
|
`${this.#THEMES_API_PREFIX}/${themeName}/files/${path}`,
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw `Failed to create or update file ${path} in theme ${themeName}: ${err}`;
|
throw `Failed to create or update file ${path} in theme ${themeName}: ${err}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteThemeFile(
|
||||||
|
themeName: string,
|
||||||
|
path: string,
|
||||||
|
recursive: boolean
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const response: ApiResponse = await this.#apiClient.delete(
|
||||||
|
`${this.#THEMES_API_PREFIX}/${themeName}/files/${path}`,
|
||||||
|
{
|
||||||
|
recursive: recursive.toString(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw `Failed to delete file ${path} in theme ${themeName}:
|
||||||
|
${response.status} ${response.statusText}`;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw `Failed to delete file ${path} in theme ${themeName}: ${err}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async downloadTheme(themeName: string): Promise<ArrayBuffer> {
|
||||||
|
try {
|
||||||
|
const response: ApiResponse = await this.#apiClient.get(
|
||||||
|
`${this.#THEMES_API_PREFIX}/${themeName}/@download`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
return response.arrayBuffer();
|
||||||
|
} else {
|
||||||
|
throw `Failed to download theme ${themeName}:
|
||||||
|
${response.status} ${response.statusText}`;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw `Failed to download theme ${themeName}: ${err}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateTheme(
|
||||||
|
themeName: string,
|
||||||
|
updateTheme: ArrayBuffer
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const response: ApiResponse = await this.#apiClient.post(
|
||||||
|
`${this.#THEMES_API_PREFIX}/${themeName}/@update`,
|
||||||
|
updateTheme
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
throw `Failed to update theme ${themeName}:
|
||||||
|
${response.status} ${response.statusText}`;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw `Failed to update theme ${themeName}: ${err}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue