karso/front/src/back-api/api/data-resource.ts
Edouard DUPIN 307a091178 plop
2025-07-04 18:15:12 +02:00

135 lines
2.2 KiB
TypeScript

/**
* Interface of the server (auto-generated code)
*/
import {
HTTPMimeType,
HTTPRequestModel,
RESTConfig,
RESTRequestJson,
RESTRequestVoid,
} from "../rest-tools";
import {
ObjectId,
} from "../model";
export namespace DataResource {
/**
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
*/
export function retrieveDataFull({
restConfig,
queries,
params,
headers,
}: {
restConfig: RESTConfig,
queries: {
Authorization?: string,
},
params: {
name: string,
oid: ObjectId,
},
headers?: {
Range?: string,
},
}): Promise<object> {
return RESTRequestJson({
restModel: {
endPoint: "/data/{oid}/{name}",
requestType: HTTPRequestModel.GET,
},
restConfig,
params,
queries,
headers,
});
};
/**
* Get back some data from the data environment
*/
export function retrieveDataId({
restConfig,
queries,
params,
headers,
}: {
restConfig: RESTConfig,
queries: {
Authorization?: string,
},
params: {
oid: ObjectId,
},
headers?: {
Range: string,
},
}): Promise<object> {
return RESTRequestJson({
restModel: {
endPoint: "/data/{oid}",
requestType: HTTPRequestModel.GET,
},
restConfig,
params,
queries,
headers,
});
};
/**
* Get a thumbnail of from the data environment (if resize is possible)
*/
export function retrieveDataThumbnailId({
restConfig,
queries,
params,
headers,
}: {
restConfig: RESTConfig,
queries: {
Authorization?: string,
},
params: {
oid: ObjectId,
},
headers?: {
Range: string,
},
}): Promise<object> {
return RESTRequestJson({
restModel: {
endPoint: "/data/thumbnail/{oid}",
requestType: HTTPRequestModel.GET,
},
restConfig,
params,
queries,
headers,
});
};
/**
* Insert a new data in the data environment
*/
export function uploadFile({
restConfig,
data,
}: {
restConfig: RESTConfig,
data: {
file: File,
},
}): Promise<void> {
return RESTRequestVoid({
restModel: {
endPoint: "/data//upload/",
requestType: HTTPRequestModel.POST,
contentType: HTTPMimeType.MULTIPART,
},
restConfig,
data,
});
};
}