import DISingleton from "@web-atoms/core/dist/di/DISingleton"; import { BaseService, Body, Get, Path, Post } from "@web-atoms/core/dist/services/http/RestService"; export interface IPackageFile { package?: string; path?: string; snapshot?: string; version?: string; localPath?: string; remoteUrl?: string; url?: string; files?: IPackageFile[]; } export interface ISaveModel { id?: string; comments?: string; files: Array<{ name: string; snapshot?: string; content?: string; url?: string; }>; } export interface IFolderStructure { root: string; host: string; start: string; contentUrl: string; downloadUrl: string; list: IPackageFile[]; } @DISingleton() export default class FileService extends BaseService { public async getFileSource(url: string) { const r = await this.ajax(url, { method: "GET"}); return r.responseText; } @Get("/source/check/{all}") public async check(@Path("all") all: string): Promise { return null; } @Post("/source/folder/create") public async create(@Body model: any): Promise { return null; } @Post("/source/save/{all}") public async saveFiles( @Path("all") root: string, @Body model: any): Promise { return null; } @Get("/source/list/1/{folder}") public async getSourceFileList( @Path("folder") folder: string ): Promise { return null; } public async getPackageFiles(p: string, version: string): Promise { const r = await this.remoteGetPackageFiles(`${p}@${version}`); return { package: p, version, files: r.map((a) => ({ path: a })) }; } @Get("/source/package/{all}") private async remoteGetPackageFiles(@Path("all") all: string): Promise { return null; } }