[DEV] add capability to copy the tool file

This commit is contained in:
Edouard DUPIN 2024-03-13 00:38:28 +01:00
parent 151aa498e5
commit 6944331761
4 changed files with 33 additions and 7 deletions

View File

@ -37,8 +37,8 @@
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

View File

@ -185,6 +185,11 @@
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/resources</directory>
</resource>
</resources>
<testSourceDirectory>test/src</testSourceDirectory>
<testResources>
<testResource>

View File

@ -496,6 +496,21 @@ public class DataFactoryTsApi {
myWriter = new FileWriter(pathPackage + File.separator + "index.ts");
myWriter.write(index.toString());
myWriter.close();
final InputStream ioStream = DataFactoryTsApi.class
.getClassLoader()
.getResourceAsStream("rest-tools.ts");
if (ioStream == null) {
throw new IllegalArgumentException("rest-tools.ts is not found");
}
final BufferedReader buffer = new BufferedReader(new InputStreamReader(ioStream));
myWriter = new FileWriter(pathPackage + File.separator + "rest-tools.ts");
String line;
while( (line = buffer.readLine()) != null) {
myWriter.write(line);
myWriter.write("\n");
}
ioStream.close();
myWriter.close();
return;
}

View File

@ -1,7 +1,7 @@
/** @file
* @author Edouard DUPIN
* @copyright 2024, Edouard DUPIN, all right reserved
* @license MPL-2 (Generate file)
* @license MPL-2
*/
import { RestErrorResponse } from "./model"
@ -21,6 +21,7 @@ export enum HTTPMimeType {
JSON = 'application/json',
OCTET_STREAM = 'application/octet-stream',
MULTIPART = 'multipart/form-data',
CSV = 'text/csv',
}
export interface RESTConfig {
@ -43,11 +44,6 @@ export interface RESTModel {
tokenInUrl?: boolean;
}
export interface RESTRequest {
params?: object;
body?: any;
}
export interface ModelResponseHttp {
status: number;
data: any;
@ -222,3 +218,13 @@ export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (d
});
});
}
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
return new Promise((resolve, reject) => {
RESTRequest(request).then((value: ModelResponseHttp) => {
resolve();
}).catch((reason: RestErrorResponse) => {
reject(reason);
});
});
}