This commit is contained in:
2024-08-15 16:38:50 +02:00
parent 4afd833276
commit 22f24e92c3
19 changed files with 148 additions and 69 deletions

View File

@ -18,7 +18,7 @@
*/
import {fetchWithToken, tokenStore} from "./repo.ts";
import type {SchematicInfo, SchematicList} from "@type/schem.ts";
import {type Schematic, type SchematicInfo, type SchematicList, SchematicSchema} from "@type/schem.ts";
import {SchematicInfoSchema, SchematicListSchema} from "@type/schem.ts";
import {derived} from "svelte/store";
@ -38,6 +38,14 @@ export class SchematicRepo {
return await fetchWithToken(this.token, `/schem/${id}`).then(value => value.json()).then(SchematicInfoSchema.parse);
}
public async getSchematicCodeInfo(code: string): Promise<Schematic> {
return await fetchWithToken(this.token, `/schem/download/${code}/info`).then(value => value.json()).then(SchematicSchema.parse);
}
public getSchematicDownloadUrl(code: string): string {
return `/schem/download/${code}`;
}
public async uploadSchematic(name: string, content: string) {
return await fetchWithToken(this.token, "/schem", {
method: "POST",