/** * Interface of the server (auto-generated code) */ import { HTTPMimeType, HTTPRequestModel, RESTCallbacks, RESTConfig, RESTRequestJson, RESTRequestVoid, } from "../rest-tools"; import { z as zod } from "zod" import { Artist, ArtistCreate, ArtistUpdate, ObjectId, ZodArtist, isArtist, } from "../model"; export namespace ArtistResource { export function get({ restConfig, params, }: { restConfig: RESTConfig, params: { oid: ObjectId, }, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/artist/{oid}", requestType: HTTPRequestModel.GET, accept: HTTPMimeType.JSON, }, restConfig, params, }, isArtist); }; export const ZodGetsTypeReturn = zod.array(ZodArtist); export type GetsTypeReturn = zod.infer; export function isGetsTypeReturn(data: any): data is GetsTypeReturn { try { ZodGetsTypeReturn.parse(data); return true; } catch (e: any) { console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`); return false; } } export function gets({ restConfig, }: { restConfig: RESTConfig, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/artist/", requestType: HTTPRequestModel.GET, accept: HTTPMimeType.JSON, }, restConfig, }, isGetsTypeReturn); }; export function post({ restConfig, data, }: { restConfig: RESTConfig, data: ArtistCreate, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/artist/", requestType: HTTPRequestModel.POST, contentType: HTTPMimeType.JSON, accept: HTTPMimeType.JSON, }, restConfig, data, }, isArtist); }; export function put({ restConfig, params, data, }: { restConfig: RESTConfig, params: { oid: ObjectId, }, data: ArtistUpdate, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/artist/{oid}", requestType: HTTPRequestModel.PUT, contentType: HTTPMimeType.JSON, accept: HTTPMimeType.JSON, }, restConfig, params, data, }, isArtist); }; export function remove({ restConfig, params, }: { restConfig: RESTConfig, params: { oid: ObjectId, }, }): Promise { return RESTRequestVoid({ restModel: { endPoint: "/artist/{oid}", requestType: HTTPRequestModel.DELETE, contentType: HTTPMimeType.TEXT_PLAIN, }, restConfig, params, }); }; export function removeCover({ restConfig, params, }: { restConfig: RESTConfig, params: { coverId: ObjectId, oid: ObjectId, }, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/artist/{oid}/cover/{coverId}", requestType: HTTPRequestModel.DELETE, contentType: HTTPMimeType.TEXT_PLAIN, accept: HTTPMimeType.JSON, }, restConfig, params, }, isArtist); }; export function uploadCover({ restConfig, params, data, callbacks, }: { restConfig: RESTConfig, params: { oid: ObjectId, }, data: { file?: File, uri?: string, }, callbacks?: RESTCallbacks, }): Promise { return RESTRequestJson({ restModel: { endPoint: "/artist/{oid}/cover", requestType: HTTPRequestModel.POST, contentType: HTTPMimeType.MULTIPART, accept: HTTPMimeType.JSON, }, restConfig, params, data, callbacks, }, isArtist); }; }