[FEAT] many renaming
This commit is contained in:
parent
3b27edfa3b
commit
21d53b77f2
@ -5,7 +5,7 @@ version_file="../version.txt"
|
|||||||
# update new release dependency
|
# update new release dependency
|
||||||
cd back
|
cd back
|
||||||
# update the Maven version number
|
# update the Maven version number
|
||||||
mvn versions:set -DnewVersion=$(sed 's/DEV/SNAPSHOT/g' $version_file)
|
mvn versions:set -DnewVersion=$(sed 's/dev/SNAPSHOT/g' $version_file)
|
||||||
if grep -q "DEV" "$version_file"; then
|
if grep -q "DEV" "$version_file"; then
|
||||||
# update all versions release of dependency
|
# update all versions release of dependency
|
||||||
mvn versions:use-latest-releases
|
mvn versions:use-latest-releases
|
||||||
@ -19,11 +19,14 @@ cd -
|
|||||||
|
|
||||||
|
|
||||||
cd front
|
cd front
|
||||||
if grep -q "DEV" "$version_file"; then
|
if grep -q "dev" "$version_file"; then
|
||||||
# update all dependency
|
# update all dependency
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm run update_packages
|
pnpm run update_packages
|
||||||
else
|
else
|
||||||
# in case of release ==> can not do it automatically ...
|
# in case of release ==> can not do it automatically ...
|
||||||
|
echo not implemented
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
45
back/pom.xml
45
back/pom.xml
@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.7.1</version>
|
<version>0.13.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
@ -49,6 +49,16 @@
|
|||||||
<version>5.10.1</version>
|
<version>5.10.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
|
<version>2.24.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
@ -186,23 +196,10 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Check the style of the code -->
|
<!-- Check the style of the code -->
|
||||||
<!--
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
|
||||||
<version>3.1.0</version>
|
|
||||||
<configuration>
|
|
||||||
<configLocation>CheckStyle.xml</configLocation>
|
|
||||||
<consoleOutput>true</consoleOutput>
|
|
||||||
<failOnViolation>true</failOnViolation>
|
|
||||||
<failsOnError>true</failsOnError>
|
|
||||||
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>net.revelc.code.formatter</groupId>
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
<artifactId>formatter-maven-plugin</artifactId>
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
<version>2.12.2</version>
|
<version>2.23.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
@ -226,7 +223,23 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
-->
|
<plugin>
|
||||||
|
<groupId>com.github.spotbugs</groupId>
|
||||||
|
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||||
|
<version>4.8.5.0</version>
|
||||||
|
<configuration>
|
||||||
|
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
|
||||||
|
<excludeFilterFile>spotbugs-security-exclude.xml</excludeFilterFile>
|
||||||
|
<!--<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.h3xstream.findsecbugs</groupId>
|
||||||
|
<artifactId>findsecbugs-plugin</artifactId>
|
||||||
|
<version>1.12.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
-->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<!-- Generate Java-docs As Part Of Project Reports -->
|
<!-- Generate Java-docs As Part Of Project Reports -->
|
||||||
|
@ -10,11 +10,7 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||||||
import org.kar.archidata.GlobalConfiguration;
|
import org.kar.archidata.GlobalConfiguration;
|
||||||
import org.kar.archidata.UpdateJwtPublicKey;
|
import org.kar.archidata.UpdateJwtPublicKey;
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
import org.kar.archidata.catcher.GenericCatcher;
|
||||||
import org.kar.archidata.catcher.FailExceptionCatcher;
|
|
||||||
import org.kar.archidata.catcher.InputExceptionCatcher;
|
|
||||||
import org.kar.archidata.catcher.JacksonCatcher;
|
|
||||||
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
|
||||||
import org.kar.archidata.filter.CORSFilter;
|
import org.kar.archidata.filter.CORSFilter;
|
||||||
import org.kar.archidata.filter.OptionFilter;
|
import org.kar.archidata.filter.OptionFilter;
|
||||||
import org.kar.archidata.migration.MigrationEngine;
|
import org.kar.archidata.migration.MigrationEngine;
|
||||||
@ -92,11 +88,7 @@ public class WebLauncher {
|
|||||||
// global authentication system
|
// global authentication system
|
||||||
rc.register(KarusicAuthenticationFilter.class);
|
rc.register(KarusicAuthenticationFilter.class);
|
||||||
// register exception catcher
|
// register exception catcher
|
||||||
rc.register(JacksonCatcher.class);
|
GenericCatcher.addAll(rc);
|
||||||
rc.register(InputExceptionCatcher.class);
|
|
||||||
rc.register(SystemExceptionCatcher.class);
|
|
||||||
rc.register(FailExceptionCatcher.class);
|
|
||||||
rc.register(ExceptionCatcher.class);
|
|
||||||
// add default resource:
|
// add default resource:
|
||||||
rc.register(UserResource.class);
|
rc.register(UserResource.class);
|
||||||
rc.register(AlbumResource.class);
|
rc.register(AlbumResource.class);
|
||||||
|
@ -3,7 +3,8 @@ package org.kar.karusic;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.dataAccess.DataFactoryTsApi;
|
import org.kar.archidata.externalRestApi.AnalyzeApi;
|
||||||
|
import org.kar.archidata.externalRestApi.TsGenerateApi;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.karusic.api.AlbumResource;
|
import org.kar.karusic.api.AlbumResource;
|
||||||
import org.kar.karusic.api.ArtistResource;
|
import org.kar.karusic.api.ArtistResource;
|
||||||
@ -13,7 +14,6 @@ import org.kar.karusic.api.HealthCheck;
|
|||||||
import org.kar.karusic.api.PlaylistResource;
|
import org.kar.karusic.api.PlaylistResource;
|
||||||
import org.kar.karusic.api.TrackResource;
|
import org.kar.karusic.api.TrackResource;
|
||||||
import org.kar.karusic.api.UserResource;
|
import org.kar.karusic.api.UserResource;
|
||||||
import org.kar.karusic.migration.Initialization;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -22,18 +22,19 @@ public class WebLauncherLocal extends WebLauncher {
|
|||||||
|
|
||||||
private WebLauncherLocal() {}
|
private WebLauncherLocal() {}
|
||||||
|
|
||||||
|
public static void generateObjects() throws Exception {
|
||||||
|
LOGGER.info("Generate APIs");
|
||||||
|
final List<Class<?>> listOfResources = List.of(AlbumResource.class, ArtistResource.class, Front.class,
|
||||||
|
GenderResource.class, HealthCheck.class, PlaylistResource.class, UserResource.class,
|
||||||
|
TrackResource.class, DataResource.class);
|
||||||
|
final AnalyzeApi api = new AnalyzeApi();
|
||||||
|
api.addAllApi(listOfResources);
|
||||||
|
TsGenerateApi.generateApi(api, "../front/src/app/back-api/");
|
||||||
|
LOGGER.info("Generate APIs (DONE)");
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
DataFactoryTsApi.generatePackage(List.of(
|
generateObjects();
|
||||||
AlbumResource.class,
|
|
||||||
ArtistResource.class,
|
|
||||||
Front.class,
|
|
||||||
GenderResource.class,
|
|
||||||
HealthCheck.class,
|
|
||||||
PlaylistResource.class,
|
|
||||||
UserResource.class,
|
|
||||||
TrackResource.class,
|
|
||||||
DataResource.class),
|
|
||||||
Initialization.CLASSES_BASE, "../front/src/app/back-api/");
|
|
||||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||||
launcher.process();
|
launcher.process();
|
||||||
launcher.LOGGER.info("end-configure the server & wait finish process:");
|
launcher.LOGGER.info("end-configure the server & wait finish process:");
|
||||||
|
@ -27,7 +27,6 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/album")
|
@Path("/album")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
@ -62,7 +61,8 @@ public class AlbumResource {
|
|||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@Operation(description = "Update a specific album")
|
@Operation(description = "Update a specific album")
|
||||||
public Album patch(@PathParam("id") final Long id, @AsyncType(Album.class) final String jsonRequest) throws Exception {
|
public Album patch(@PathParam("id") final Long id, @AsyncType(Album.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Album.class, id, jsonRequest);
|
DataAccess.updateWithJson(Album.class, id, jsonRequest);
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
@ -89,7 +89,8 @@ public class AlbumResource {
|
|||||||
@Path("{id}/track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a Track on a specific album")
|
@Operation(description = "Remove a Track on a specific album")
|
||||||
public Album removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Album removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId)
|
||||||
|
throws Exception {
|
||||||
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Album.class, id, "track", trackId);
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
@ -101,16 +102,19 @@ public class AlbumResource {
|
|||||||
@Operation(description = "Add a cover on a specific album")
|
@Operation(description = "Add a cover on a specific album")
|
||||||
@AsyncType(Album.class)
|
@AsyncType(Album.class)
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public void uploadCover(
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@PathParam("id") final Long id,
|
||||||
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final InputStream fileInputStream,
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Album.class, id, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a cover on a specific album")
|
@Operation(description = "Remove a cover on a specific album")
|
||||||
public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Album removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId)
|
||||||
|
throws Exception {
|
||||||
AddOnDataJson.removeLink(Album.class, id, "covers", coverId);
|
AddOnDataJson.removeLink(Album.class, id, "covers", coverId);
|
||||||
return DataAccess.get(Album.class, id);
|
return DataAccess.get(Album.class, id);
|
||||||
}
|
}
|
||||||
|
@ -25,64 +25,67 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/artist")
|
@Path("/artist")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class ArtistResource {
|
public class ArtistResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Artist get(@PathParam("id") final Long id) throws Exception {
|
public static Artist get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Artist.class, id);
|
return DataAccess.get(Artist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Artist> gets() throws Exception {
|
public List<Artist> gets() throws Exception {
|
||||||
return DataAccess.gets(Artist.class);
|
return DataAccess.gets(Artist.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Artist post(@AsyncType(Artist.class) final String jsonRequest) throws Exception {
|
public Artist post(@AsyncType(Artist.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Artist.class, jsonRequest);
|
return DataAccess.insertWithJson(Artist.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Artist patch(@PathParam("id") final Long id, @AsyncType(Artist.class) final String jsonRequest) throws Exception {
|
public Artist patch(@PathParam("id") final Long id, @AsyncType(Artist.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Artist.class, id, jsonRequest);
|
DataAccess.updateWithJson(Artist.class, id, jsonRequest);
|
||||||
return DataAccess.get(Artist.class, id);
|
return DataAccess.get(Artist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Artist.class, id);
|
DataAccess.delete(Artist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@AsyncType(Artist.class)
|
@AsyncType(Artist.class)
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public void uploadCover(
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@PathParam("id") final Long id,
|
||||||
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final InputStream fileInputStream,
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Artist.class, id, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Artist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId)
|
||||||
|
throws Exception {
|
||||||
LOGGER.error("klmlmkmlkmlklmklmk");
|
LOGGER.error("klmlmkmlkmlklmklmk");
|
||||||
AddOnDataJson.removeLink(Artist.class, id, "covers", coverId);
|
AddOnDataJson.removeLink(Artist.class, id, "covers", coverId);
|
||||||
return DataAccess.get(Artist.class, id);
|
return DataAccess.get(Artist.class, id);
|
||||||
|
@ -25,64 +25,67 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/gender")
|
@Path("/gender")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class GenderResource {
|
public class GenderResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Gender get(@PathParam("id") final Long id) throws Exception {
|
public static Gender get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Gender> gets() throws Exception {
|
public List<Gender> gets() throws Exception {
|
||||||
return DataAccess.gets(Gender.class);
|
return DataAccess.gets(Gender.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Gender post(@AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
public Gender post(@AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Gender patch(@PathParam("id") final Long id, @AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
public Gender patch(@PathParam("id") final Long id, @AsyncType(Gender.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Gender.class, id, jsonRequest);
|
DataAccess.updateWithJson(Gender.class, id, jsonRequest);
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Gender.class, id);
|
DataAccess.delete(Gender.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@AsyncType(Gender.class)
|
@AsyncType(Gender.class)
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public void uploadCover(
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@PathParam("id") final Long id,
|
||||||
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final InputStream fileInputStream,
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Gender.class, id, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Gender removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId)
|
||||||
|
throws Exception {
|
||||||
AddOnDataJson.removeLink(Gender.class, id, "covers", coverId);
|
AddOnDataJson.removeLink(Gender.class, id, "covers", coverId);
|
||||||
return DataAccess.get(Gender.class, id);
|
return DataAccess.get(Gender.class, id);
|
||||||
}
|
}
|
||||||
|
@ -25,80 +25,85 @@ import jakarta.ws.rs.Path;
|
|||||||
import jakarta.ws.rs.PathParam;
|
import jakarta.ws.rs.PathParam;
|
||||||
import jakarta.ws.rs.Produces;
|
import jakarta.ws.rs.Produces;
|
||||||
import jakarta.ws.rs.core.MediaType;
|
import jakarta.ws.rs.core.MediaType;
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
@Path("/playlist")
|
@Path("/playlist")
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public class PlaylistResource {
|
public class PlaylistResource {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public static Playlist get(@PathParam("id") final Long id) throws Exception {
|
public static Playlist get(@PathParam("id") final Long id) throws Exception {
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
public List<Playlist> gets() throws Exception {
|
public List<Playlist> gets() throws Exception {
|
||||||
return DataAccess.gets(Playlist.class);
|
return DataAccess.gets(Playlist.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Playlist post(@AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
public Playlist post(@AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
||||||
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Playlist patch(@PathParam("id") final Long id, @AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
public Playlist patch(@PathParam("id") final Long id, @AsyncType(Playlist.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Playlist.class, id, jsonRequest);
|
DataAccess.updateWithJson(Playlist.class, id, jsonRequest);
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||||
DataAccess.delete(Playlist.class, id);
|
DataAccess.delete(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Playlist addTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId)
|
||||||
|
throws Exception {
|
||||||
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/track/{trackId}")
|
@Path("{id}/track/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Playlist removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId) throws Exception {
|
public Playlist removeTrack(@PathParam("id") final Long id, @PathParam("trackId") final Long trackId)
|
||||||
|
throws Exception {
|
||||||
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
AddOnManyToMany.removeLink(Playlist.class, id, "track", trackId);
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/cover")
|
@Path("{id}/cover")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@AsyncType(Playlist.class)
|
@AsyncType(Playlist.class)
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public void uploadCover(
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@PathParam("id") final Long id,
|
||||||
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final InputStream fileInputStream,
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Playlist.class, id, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Playlist removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId)
|
||||||
|
throws Exception {
|
||||||
AddOnDataJson.removeLink(Playlist.class, id, "covers", coverId);
|
AddOnDataJson.removeLink(Playlist.class, id, "covers", coverId);
|
||||||
return DataAccess.get(Playlist.class, id);
|
return DataAccess.get(Playlist.class, id);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,8 @@ public class TrackResource {
|
|||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Track patch(@PathParam("id") final Long id, @AsyncType(Track.class) final String jsonRequest) throws Exception {
|
public Track patch(@PathParam("id") final Long id, @AsyncType(Track.class) final String jsonRequest)
|
||||||
|
throws Exception {
|
||||||
DataAccess.updateWithJson(Track.class, id, jsonRequest);
|
DataAccess.updateWithJson(Track.class, id, jsonRequest);
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
@ -90,7 +91,8 @@ public class TrackResource {
|
|||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/artist/{trackId}")
|
@Path("{id}/artist/{trackId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Track removeTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId) throws Exception {
|
public Track removeTrack(@PathParam("id") final Long id, @PathParam("artistId") final Long artistId)
|
||||||
|
throws Exception {
|
||||||
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
|
AddOnManyToMany.removeLink(Track.class, id, "artist", artistId);
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
@ -101,15 +103,18 @@ public class TrackResource {
|
|||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@AsyncType(Track.class)
|
@AsyncType(Track.class)
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
public void uploadCover(
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
@PathParam("id") final Long id,
|
||||||
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
@FormDataParam("file") final InputStream fileInputStream,
|
||||||
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
|
DataTools.uploadCover(Track.class, id, fileInputStream, fileMetaData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("{id}/cover/{coverId}")
|
@Path("{id}/cover/{coverId}")
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Track removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId)
|
||||||
|
throws Exception {
|
||||||
AddOnDataJson.removeLink(Track.class, id, "covers", coverId);
|
AddOnDataJson.removeLink(Track.class, id, "covers", coverId);
|
||||||
return DataAccess.get(Track.class, id);
|
return DataAccess.get(Track.class, id);
|
||||||
}
|
}
|
||||||
@ -131,7 +136,7 @@ public class TrackResource {
|
|||||||
@FormDataParam("title") String title, //
|
@FormDataParam("title") String title, //
|
||||||
@FormDataParam("file") final InputStream fileInputStream, //
|
@FormDataParam("file") final InputStream fileInputStream, //
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
||||||
) {
|
) {
|
||||||
// Formatter:on
|
// Formatter:on
|
||||||
try {
|
try {
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
@ -180,7 +185,7 @@ public class TrackResource {
|
|||||||
}
|
}
|
||||||
} else if (data.deleted) {
|
} else if (data.deleted) {
|
||||||
LOGGER.info("Data already exist but deleted");
|
LOGGER.info("Data already exist but deleted");
|
||||||
DataTools.undelete(data.id);
|
DataTools.undelete(data.uuid);
|
||||||
data.deleted = false;
|
data.deleted = false;
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("Data already exist ... all good");
|
LOGGER.info("Data already exist ... all good");
|
||||||
@ -234,7 +239,7 @@ public class TrackResource {
|
|||||||
trackElem.track = trackId != null ? Long.parseLong(trackId) : null;
|
trackElem.track = trackId != null ? Long.parseLong(trackId) : null;
|
||||||
trackElem.albumId = albumElem != null ? albumElem.id : null;
|
trackElem.albumId = albumElem != null ? albumElem.id : null;
|
||||||
trackElem.genderId = genderElem != null ? genderElem.id : null;
|
trackElem.genderId = genderElem != null ? genderElem.id : null;
|
||||||
trackElem.dataId = data.id;
|
trackElem.dataId = data.uuid;
|
||||||
// Now list of artist has an internal management:
|
// Now list of artist has an internal management:
|
||||||
if (artistElem != null) {
|
if (artistElem != null) {
|
||||||
trackElem.artists = new ArrayList<>();
|
trackElem.artists = new ArrayList<>();
|
||||||
|
@ -2,6 +2,7 @@ package org.kar.karusic.migration;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
@ -10,27 +11,31 @@ import org.kar.karusic.model.Artist;
|
|||||||
import org.kar.karusic.model.Gender;
|
import org.kar.karusic.model.Gender;
|
||||||
import org.kar.karusic.model.Playlist;
|
import org.kar.karusic.model.Playlist;
|
||||||
import org.kar.karusic.model.Track;
|
import org.kar.karusic.model.Track;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class Initialization extends MigrationSqlStep {
|
public class Initialization extends MigrationSqlStep {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class);
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
public static final List<Class<?>> CLASSES_BASE = List.of(Album.class,Artist.class,Data.class,Gender.class,Playlist.class,Track.class,User.class);
|
public static final List<Class<?>> CLASSES_BASE = List.of(Album.class, Artist.class, Data.class, Gender.class,
|
||||||
|
Playlist.class, Track.class, User.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Initialization";
|
return "Initialization";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Initialization() {
|
public Initialization() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
for (final Class<?> elem : CLASSES_BASE) {
|
for (final Class<?> elem : CLASSES_BASE) {
|
||||||
addClass(elem);
|
addClass(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
addAction("""
|
addAction("""
|
||||||
INSERT INTO `gender` (`id`, `name`, `description`) VALUES
|
INSERT INTO `gender` (`id`, `name`, `description`) VALUES
|
||||||
(1, 'Variété française', NULL),
|
(1, 'Variété française', NULL),
|
||||||
@ -80,5 +85,26 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
ALTER TABLE `user` AUTO_INCREMENT = 1000;
|
ALTER TABLE `user` AUTO_INCREMENT = 1000;
|
||||||
""", "mysql");
|
""", "mysql");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void dropAll() {
|
||||||
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
|
try {
|
||||||
|
DataAccess.drop(element);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
LOGGER.error("Fail to drop table !!!!!!");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cleanAll() {
|
||||||
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
|
try {
|
||||||
|
DataAccess.cleanAll(element);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
LOGGER.error("Fail to clean table !!!!!!");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOn.model.LinkTable;
|
import org.kar.archidata.dataAccess.addOn.model.LinkTableLongLong;
|
||||||
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
||||||
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
@ -22,29 +22,30 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class Migration20240226 extends MigrationSqlStep {
|
public class Migration20240226 extends MigrationSqlStep {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "migration-2024-02-26: convert base with UUID";
|
return "migration-2024-02-26: convert base with UUID";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Migration20240226() {
|
public Migration20240226() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
||||||
""");
|
""");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||||
for (final UUIDConversion elem: datas) {
|
new OverrideTableName("data"));
|
||||||
|
for (final UUIDConversion elem : datas) {
|
||||||
elem.uuid = UuidUtils.nextUUID();
|
elem.uuid = UuidUtils.nextUUID();
|
||||||
}
|
}
|
||||||
for (final UUIDConversion elem: datas) {
|
for (final UUIDConversion elem : datas) {
|
||||||
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -52,18 +53,21 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
ALTER TABLE `data` CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
ALTER TABLE `data` CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
||||||
""");
|
""");
|
||||||
final List<String> tableToTransform = List.of("album", "artist", "gender", "playlist", "track", "user");
|
final List<String> tableToTransform = List.of("album", "artist", "gender", "playlist", "track", "user");
|
||||||
for (final String tableName : tableToTransform ) {
|
for (final String tableName : tableToTransform) {
|
||||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||||
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
new OverrideTableName("data"));
|
||||||
final List<LinkTable> links = DataAccess.gets(LinkTable.class, new OverrideTableName(tableName + "_link_cover"));
|
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(),
|
||||||
|
new OverrideTableName(tableName));
|
||||||
|
final List<LinkTableLongLong> links = DataAccess.gets(LinkTableLongLong.class,
|
||||||
|
new OverrideTableName(tableName + "_link_cover"));
|
||||||
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
||||||
for (final CoverConversion media: medias) {
|
for (final CoverConversion media : medias) {
|
||||||
final List<UUID> values = new ArrayList<>();
|
final List<UUID> values = new ArrayList<>();
|
||||||
for (final LinkTable link: links) {
|
for (final LinkTableLongLong link : links) {
|
||||||
if (link.object1Id.equals(media.id)) {
|
if (link.object1Id.equals(media.id)) {
|
||||||
for (final UUIDConversion data: datas) {
|
for (final UUIDConversion data : datas) {
|
||||||
if (data.id.equals(link.object2Id)) {
|
if (data.id.equals(link.object2Id)) {
|
||||||
values.add(data.uuid);
|
values.add(data.uuid);
|
||||||
break;
|
break;
|
||||||
@ -85,10 +89,12 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
|
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
|
||||||
""");
|
""");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||||
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
new OverrideTableName("data"));
|
||||||
for (final MediaConversion media: medias) {
|
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(),
|
||||||
for (final UUIDConversion data: datas) {
|
new OverrideTableName("track"));
|
||||||
|
for (final MediaConversion media : medias) {
|
||||||
|
for (final UUIDConversion data : datas) {
|
||||||
if (data.id.equals(media.dataId)) {
|
if (data.id.equals(media.dataId)) {
|
||||||
media.dataUUID = data.uuid;
|
media.dataUUID = data.uuid;
|
||||||
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
|
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
|
||||||
@ -97,7 +103,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addAction("""
|
addAction("""
|
||||||
DROP TABLE `playlist`;
|
DROP TABLE `playlist`;
|
||||||
""");
|
""");
|
||||||
@ -112,8 +118,9 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
""");
|
""");
|
||||||
// Move the files...
|
// Move the files...
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||||
for (final UUIDConversion data: datas) {
|
new OverrideTableName("data"));
|
||||||
|
for (final UUIDConversion data : datas) {
|
||||||
final String origin = DataResource.getFileDataOld(data.id);
|
final String origin = DataResource.getFileDataOld(data.id);
|
||||||
final String destination = DataResource.getFileData(data.uuid);
|
final String destination = DataResource.getFileData(data.uuid);
|
||||||
LOGGER.info("move file = {}", origin);
|
LOGGER.info("move file = {}", origin);
|
||||||
@ -131,5 +138,5 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
ALTER TABLE `data` ADD PRIMARY KEY `id` (`id`);
|
ALTER TABLE `data` ADD PRIMARY KEY `id` (`id`);
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,32 @@
|
|||||||
package org.kar.karusic.model;
|
package org.kar.karusic.model;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
import org.kar.archidata.model.Data;
|
||||||
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@Table(name = "album")
|
@Table(name = "album")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Album extends NodeSmall {
|
public class Album extends GenericDataSoftDelete {
|
||||||
|
@Column(length = 256)
|
||||||
|
public String name = null;
|
||||||
|
@Column(length = 0)
|
||||||
|
public String description = null;
|
||||||
|
@Schema(description = "List of Id of the specific covers")
|
||||||
|
@DataJson(targetEntity = Data.class)
|
||||||
|
@Nullable
|
||||||
|
public List<UUID> covers = null;
|
||||||
public LocalDate publication = null;
|
public LocalDate publication = null;
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,44 @@
|
|||||||
package org.kar.karusic.model;
|
package org.kar.karusic.model;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
import org.kar.archidata.model.Data;
|
||||||
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@Table(name = "artist")
|
@Table(name = "artist")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Artist extends NodeSmall {
|
public class Artist extends GenericDataSoftDelete {
|
||||||
|
@Column(length = 256)
|
||||||
|
public String name = null;
|
||||||
|
@Column(length = 0)
|
||||||
|
public String description = null;
|
||||||
|
@Schema(description = "List of Id of the specific covers")
|
||||||
|
@DataJson(targetEntity = Data.class)
|
||||||
|
@Nullable
|
||||||
|
public List<UUID> covers = null;
|
||||||
@Column(length = 256)
|
@Column(length = 256)
|
||||||
public String firstName = null;
|
public String firstName = null;
|
||||||
@Column(length = 256)
|
@Column(length = 256)
|
||||||
public String surname = null;
|
public String surname = null;
|
||||||
public LocalDate birth = null;
|
public LocalDate birth = null;
|
||||||
public LocalDate death = null;
|
public LocalDate death = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Artist [id=" + this.id + ", name=" + this.name + ", description=" + this.description + ", covers=" + this.covers + ", firstName=" + this.firstName + ", surname=" + this.surname
|
return "Artist [id=" + this.id + ", name=" + this.name + ", description=" + this.description + ", covers="
|
||||||
+ ", birth=" + this.birth + ", death=" + this.death + "]";
|
+ this.covers + ", firstName=" + this.firstName + ", surname=" + this.surname + ", birth=" + this.birth
|
||||||
|
+ ", death=" + this.death + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,32 @@ CREATE TABLE `node` (
|
|||||||
) AUTO_INCREMENT=10;
|
) AUTO_INCREMENT=10;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
import org.kar.archidata.model.Data;
|
||||||
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@Table(name = "gender")
|
@Table(name = "gender")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Gender extends NodeSmall {
|
public class Gender extends GenericDataSoftDelete {
|
||||||
|
@Column(length = 256)
|
||||||
|
public String name = null;
|
||||||
|
@Column(length = 0)
|
||||||
|
public String description = null;
|
||||||
|
@Schema(description = "List of Id of the specific covers")
|
||||||
|
@DataJson(targetEntity = Data.class)
|
||||||
|
@Nullable
|
||||||
|
public List<UUID> covers = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package org.kar.karusic.model;
|
|
||||||
/*
|
|
||||||
CREATE TABLE `node` (
|
|
||||||
`id` bigint NOT NULL COMMENT 'table ID' AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
`deleted` BOOLEAN NOT NULL DEFAULT false,
|
|
||||||
`create_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been created',
|
|
||||||
`modify_date` datetime NOT NULL DEFAULT now() COMMENT 'Time the element has been update',
|
|
||||||
`type` enum("TYPE", "UNIVERS", "SERIE", "SAISON", "MEDIA") NOT NULL DEFAULT 'TYPE',
|
|
||||||
`name` TEXT COLLATE 'utf8_general_ci' NOT NULL,
|
|
||||||
`description` TEXT COLLATE 'utf8_general_ci',
|
|
||||||
`parent_id` bigint
|
|
||||||
) AUTO_INCREMENT=10;
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataJson;
|
|
||||||
import org.kar.archidata.model.Data;
|
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class NodeSmall extends GenericDataSoftDelete {
|
|
||||||
@Column(length = 256)
|
|
||||||
public String name = null;
|
|
||||||
@Column(length = 0)
|
|
||||||
public String description = null;
|
|
||||||
@Schema(description = "List of Id of the specific covers")
|
|
||||||
@DataJson(targetEntity = Data.class)
|
|
||||||
public List<UUID> covers = null;
|
|
||||||
}
|
|
@ -13,11 +13,18 @@ CREATE TABLE `node` (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
import org.kar.archidata.model.Data;
|
||||||
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
@ -25,7 +32,15 @@ import jakarta.persistence.Table;
|
|||||||
@Table(name = "playlist")
|
@Table(name = "playlist")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Playlist extends NodeSmall {
|
public class Playlist extends GenericDataSoftDelete {
|
||||||
|
@Column(length = 256)
|
||||||
|
public String name = null;
|
||||||
|
@Column(length = 0)
|
||||||
|
public String description = null;
|
||||||
|
@Schema(description = "List of Id of the specific covers")
|
||||||
|
@DataJson(targetEntity = Data.class)
|
||||||
|
@Nullable
|
||||||
|
public List<UUID> covers = null;
|
||||||
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Track.class)
|
@ManyToMany(fetch = FetchType.LAZY, targetEntity = Track.class)
|
||||||
public List<Long> tracks = null;
|
public List<Long> tracks = null;
|
||||||
}
|
}
|
||||||
|
@ -17,16 +17,28 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.annotation.DataJson;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
import org.kar.archidata.model.Data;
|
||||||
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@Table(name = "track")
|
@Table(name = "track")
|
||||||
@DataIfNotExists
|
@DataIfNotExists
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Track extends NodeSmall {
|
public class Track extends GenericDataSoftDelete {
|
||||||
|
@Column(length = 256)
|
||||||
|
public String name = null;
|
||||||
|
@Column(length = 0)
|
||||||
|
public String description = null;
|
||||||
|
@Schema(description = "List of Id of the specific covers")
|
||||||
|
@DataJson(targetEntity = Data.class)
|
||||||
|
@Nullable
|
||||||
|
public List<UUID> covers = null;
|
||||||
public Long genderId = null;
|
public Long genderId = null;
|
||||||
public Long albumId = null;
|
public Long albumId = null;
|
||||||
public Long track = null;
|
public Long track = null;
|
||||||
@ -35,10 +47,12 @@ public class Track extends NodeSmall {
|
|||||||
@DataJson
|
@DataJson
|
||||||
@Column(length = 0)
|
@Column(length = 0)
|
||||||
public List<Long> artists = null;
|
public List<Long> artists = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Track [id=" + this.id + ", deleted=" + this.deleted + ", createdAt=" + this.createdAt + ", updatedAt=" + this.updatedAt + ", name=" + this.name + ", description=" + this.description
|
return "Track [id=" + this.id + ", deleted=" + this.deleted + ", createdAt=" + this.createdAt + ", updatedAt="
|
||||||
+ ", covers=" + this.covers + ", genderId=" + this.genderId + ", albumId=" + this.albumId + ", track=" + this.track + ", dataId=" + this.dataId + ", artists=" + this.artists + "]";
|
+ this.updatedAt + ", name=" + this.name + ", description=" + this.description + ", covers="
|
||||||
|
+ this.covers + ", genderId=" + this.genderId + ", albumId=" + this.albumId + ", track=" + this.track
|
||||||
|
+ ", dataId=" + this.dataId + ", artists=" + this.artists + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
back/test/src/test/kar/karusic/Common.java
Normal file
12
back/test/src/test/kar/karusic/Common.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package test.kar.karusic;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.kar.archidata.tools.JWTWrapper;
|
||||||
|
|
||||||
|
public class Common {
|
||||||
|
static String USER_TOKEN = JWTWrapper.createJwtTestToken(16512, "test_user_login", "KarAuth", "karusic",
|
||||||
|
Map.of("karusic", Map.of("USER", Boolean.TRUE)));
|
||||||
|
static String ADMIN_TOKEN = JWTWrapper.createJwtTestToken(16512, "test_admin_login", "KarAuth", "karusic",
|
||||||
|
Map.of("karusic", Map.of("USER", Boolean.TRUE, "ADMIN", Boolean.TRUE)));
|
||||||
|
}
|
@ -1,51 +1,44 @@
|
|||||||
package test.kar.karusic;
|
package test.kar.karusic;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
import org.junit.jupiter.api.Order;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
import org.junit.jupiter.api.TestMethodOrder;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
import org.kar.archidata.db.DBEntry;
|
||||||
import org.kar.archidata.model.GetToken;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.archidata.tools.JWTWrapper;
|
|
||||||
import org.kar.archidata.tools.RESTApi;
|
import org.kar.archidata.tools.RESTApi;
|
||||||
import org.kar.karusic.api.HealthCheck.HealthResult;
|
import org.kar.karusic.migration.Initialization;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.nimbusds.jwt.JWTClaimsSet;
|
|
||||||
|
|
||||||
@ExtendWith(StepwiseExtension.class)
|
@ExtendWith(StepwiseExtension.class)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
public class TestBase {
|
public class TestBase {
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestBase.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(TestBase.class);
|
||||||
|
public final static String ENDPOINT_NAME = "species/";
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
static WebLauncherTest webInterface = null;
|
||||||
static RESTApi api = null;
|
static RESTApi api = null;
|
||||||
|
|
||||||
public void login(final String login, final String password) {
|
private static UUID idTest;
|
||||||
try {
|
|
||||||
final GetToken token = api.post(GetToken.class, "users/get_token", DataGetToken.generate(login, "v1", "202515252", password));
|
|
||||||
api.setToken(token.jwt());
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
Assertions.fail("Can not get Authentication for '" + login + "' ==> " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loginAdmin() {
|
|
||||||
login("karadmin", "adminA@666");
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
public static void configureWebServer() throws Exception {
|
public static void configureWebServer() throws Exception {
|
||||||
LOGGER.info("configure server ...");
|
LOGGER.info("configure server ...");
|
||||||
webInterface = new WebLauncherTest();
|
webInterface = new WebLauncherTest();
|
||||||
|
LOGGER.info("Clean previous table");
|
||||||
|
|
||||||
|
try {
|
||||||
|
Initialization.dropAll();
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
LOGGER.error("plop: {}", ex.getLocalizedMessage());
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.info("Create DB");
|
LOGGER.info("Create DB");
|
||||||
try {
|
try {
|
||||||
webInterface.migrateDB();
|
webInterface.migrateDB();
|
||||||
@ -57,194 +50,18 @@ public class TestBase {
|
|||||||
webInterface.process();
|
webInterface.process();
|
||||||
LOGGER.info("Start REST (DONE)");
|
LOGGER.info("Start REST (DONE)");
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
||||||
|
api.setToken(Common.USER_TOKEN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
public static void stopWebServer() throws InterruptedException {
|
public static void stopWebServer() throws Exception {
|
||||||
LOGGER.info("Kill the web server");
|
LOGGER.info("Kill the web server");
|
||||||
|
webInterface.stop();
|
||||||
webInterface = null;
|
webInterface = null;
|
||||||
// TODO: do it better...
|
LOGGER.info("Remove the test db");
|
||||||
}
|
DBEntry.closeAllForceMode();
|
||||||
|
ConfigBaseVariable.clearAllValue();
|
||||||
@Order(1)
|
|
||||||
@Test
|
|
||||||
//@RepeatedTest(10)
|
|
||||||
public void checkHealthCheck() throws Exception {
|
|
||||||
final HealthResult result = api.get(HealthResult.class, "health_check");
|
|
||||||
Assertions.assertEquals(result.value(), "alive and kicking");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(2)
|
|
||||||
@Test
|
|
||||||
public void checkHealthCheckWrongAPI() throws Exception {
|
|
||||||
Assertions.assertThrows(RESTErrorResponseExeption.class, () -> api.get(HealthResult.class, "health_checks"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(3)
|
|
||||||
@Test
|
|
||||||
public void firstUserConnect() throws Exception {
|
|
||||||
final GetToken result = api.post(GetToken.class, "users/get_token", DataGetToken.generate("karadmin", "v1", "202515252", "adminA@666"));
|
|
||||||
final String[] splitted = result.jwt().split("\\.");
|
|
||||||
Assertions.assertEquals(3, splitted.length);
|
|
||||||
final String authorization = result.jwt();
|
|
||||||
LOGGER.debug(" validate token : " + authorization);
|
|
||||||
// Note with local access we get the internal key of the system.
|
|
||||||
final JWTClaimsSet ret = JWTWrapper.validateToken(authorization, "KarAuth", null);
|
|
||||||
// check the token is valid !!! (signed and coherent issuer...
|
|
||||||
Assertions.assertNotNull(ret);
|
|
||||||
// check userID
|
|
||||||
final String userUID = ret.getSubject();
|
|
||||||
final long id = Long.parseLong(userUID);
|
|
||||||
Assertions.assertEquals(1, id);
|
|
||||||
final String name = (String) ret.getClaim("login");
|
|
||||||
Assertions.assertEquals("karadmin", name);
|
|
||||||
|
|
||||||
final Object rowRight = ret.getClaim("right");
|
|
||||||
Assertions.assertNotNull(rowRight);
|
|
||||||
final Map<String, Map<String, Object>> rights = (Map<String, Map<String, Object>>) ret.getClaim("right");
|
|
||||||
// Check if the element contain the basic keys:
|
|
||||||
Assertions.assertEquals(rights.size(), 1);
|
|
||||||
Assertions.assertTrue(rights.containsKey("karusic"));
|
|
||||||
final Map<String, Object> applRight = rights.get("karusic");
|
|
||||||
//logger.error("full right: {}", applRight);
|
|
||||||
Assertions.assertEquals(applRight.size(), 2);
|
|
||||||
Assertions.assertTrue(applRight.containsKey("ADMIN"));
|
|
||||||
Assertions.assertEquals(true, applRight.get("ADMIN"));
|
|
||||||
Assertions.assertTrue(applRight.containsKey("USER"));
|
|
||||||
Assertions.assertEquals(true, applRight.get("USER"));
|
|
||||||
|
|
||||||
//logger.debug("request user: '{}' right: '{}' row='{}'", userUID, applRight, rowRight);
|
|
||||||
|
|
||||||
//Assertions.assertEquals("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9", splitted[0]);
|
|
||||||
//Assertions.assertEquals("eyJzdWIiOiIwIiwiYXBwbGljYXRpb24iOiJrYXJzbyIsImlzcyI6IkthckF1dGgiLCJyaWdodCI6eyJrYXJzbyI6eyJBRE1JTiI6dHJ1ZSwiVVNFUiI6dHJ1ZX19LCJsb2dpbiI6ImthcmFkbWluIiwiZXhwIjoxNjg0MTk5MTkzLCJpYXQiOjE2ODI3NTU0MjV9", splitted[1]);
|
|
||||||
// TODO ... Assertions.assertEquals("????", splitted[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkFail(final String type, final String urlOffset, final int errorStatus) {
|
|
||||||
checkFail(type, urlOffset, errorStatus, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkFail(final String type, final String urlOffset, final int errorStatus, final String data) {
|
|
||||||
LOGGER.info("Test API: url={} urlOffset={}", type, urlOffset);
|
|
||||||
try {
|
|
||||||
if ("GET".equals(type)) {
|
|
||||||
api.get(String.class, urlOffset);
|
|
||||||
} else if ("POST".equals(type)) {
|
|
||||||
api.post(String.class, urlOffset, data);
|
|
||||||
} else if ("PUT".equals(type)) {
|
|
||||||
api.put(String.class, urlOffset, data);
|
|
||||||
} else if ("DELETE".equals(type)) {
|
|
||||||
api.delete(String.class, urlOffset);
|
|
||||||
}
|
|
||||||
Assertions.fail("Request on URL does not fail as expected: '" + type + "' url='" + urlOffset + "'");
|
|
||||||
} catch (final RESTErrorResponseExeption ex) {
|
|
||||||
if (errorStatus != ex.status) {
|
|
||||||
LOGGER.error("Fail in test with the wrong return errors: {}", ex.toString());
|
|
||||||
}
|
|
||||||
Assertions.assertEquals(errorStatus, ex.status);
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
LOGGER.error("Unexpected throw error: {}", ex);
|
|
||||||
Assertions.fail("Unexpected throws...");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkWork(final String type, final String urlOffset) {
|
|
||||||
checkWork(type, urlOffset, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkWork(final String type, final String urlOffset, final String data) {
|
|
||||||
LOGGER.info("Test API: url={} urlOffset={}", type, urlOffset);
|
|
||||||
try {
|
|
||||||
if ("GET".equals(type)) {
|
|
||||||
api.get(String.class, urlOffset);
|
|
||||||
} else if ("POST".equals(type)) {
|
|
||||||
api.post(String.class, urlOffset, data);
|
|
||||||
} else if ("PUT".equals(type)) {
|
|
||||||
api.put(String.class, urlOffset, data);
|
|
||||||
} else if ("DELETE".equals(type)) {
|
|
||||||
api.delete(String.class, urlOffset);
|
|
||||||
}
|
|
||||||
//Assertions.fail("Request on URL does not fail as expected: '" + type + "' url='" + urlOffset + "'");
|
|
||||||
} catch (final RESTErrorResponseExeption ex) {
|
|
||||||
Assertions.fail("Must not fail ... " + ex.toString());
|
|
||||||
} catch (final Exception ex) {
|
|
||||||
LOGGER.error("Unexpected throw error: {}", ex);
|
|
||||||
Assertions.fail("Unexpected throws...");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(4)
|
|
||||||
@Test
|
|
||||||
public void checkUnAuthorizedAPI() throws Exception {
|
|
||||||
// /application/
|
|
||||||
checkFail("GET", "application/", 401);
|
|
||||||
checkFail("POST", "application/", 401, "{}");
|
|
||||||
checkFail("PUT", "application/", 405, "{}"); // does not exist
|
|
||||||
checkFail("DELETE", "application/", 405); // does not exist
|
|
||||||
// /application/{id}
|
|
||||||
checkFail("GET", "application/0", 401);
|
|
||||||
checkFail("PUT", "application/0", 401, "{}");
|
|
||||||
checkFail("POST", "application/0", 405, "{}");
|
|
||||||
checkFail("DELETE", "application/0", 401);
|
|
||||||
// /application/{id}/*
|
|
||||||
checkFail("GET", "application/0/users", 401);
|
|
||||||
// /application/*
|
|
||||||
checkFail("GET", "application/small", 401);
|
|
||||||
checkFail("GET", "application/get_token", 401);
|
|
||||||
checkFail("GET", "application/return", 401);
|
|
||||||
|
|
||||||
// /application_token/ section:
|
|
||||||
checkFail("GET", "application_token/0", 401);
|
|
||||||
checkFail("DELETE", "application_token/0/5", 401);
|
|
||||||
checkFail("DELETE", "application_token/0/create", 401);
|
|
||||||
|
|
||||||
// /front/*
|
|
||||||
checkFail("GET", "front", 404); // no index in test section
|
|
||||||
// health check
|
|
||||||
checkWork("GET", "health_check");
|
|
||||||
|
|
||||||
// public_key (only application)
|
|
||||||
checkFail("GET", "public_key", 401);
|
|
||||||
checkFail("GET", "public_key/pem", 401);
|
|
||||||
|
|
||||||
// /right
|
|
||||||
checkFail("GET", "right", 401);
|
|
||||||
checkFail("POST", "right", 401, "{}");
|
|
||||||
checkFail("GET", "right/0", 401);
|
|
||||||
checkFail("PUT", "right/0", 401, "{}");
|
|
||||||
checkFail("DELETE", "right/0", 401);
|
|
||||||
|
|
||||||
// /system_config
|
|
||||||
checkWork("GET", "system_config/is_sign_up_availlable");
|
|
||||||
checkFail("GET", "system_config/key/skjdfhkjsdhfkjsh", 401);
|
|
||||||
checkFail("PUT", "system_config/key/skjdfhkjsdhfkjsh", 401, "{}");
|
|
||||||
|
|
||||||
// /users
|
|
||||||
checkFail("GET", "users", 401);
|
|
||||||
checkFail("GET", "users/0", 401);
|
|
||||||
checkFail("POST", "users/0/application/0/link", 401, "{}");
|
|
||||||
checkFail("POST", "users/0/set_admin", 401, "{}");
|
|
||||||
checkFail("POST", "users/0/set_blocked", 401, "{}");
|
|
||||||
checkFail("POST", "users/create_new_user", 401, "{}");
|
|
||||||
checkFail("GET", "users/me", 401, "{}");
|
|
||||||
checkFail("POST", "users/password", 401, "{}");
|
|
||||||
checkWork("GET", "users/check_login?login=karadmin");
|
|
||||||
checkFail("GET", "users/check_login?login=jhkjhkjh", 404);
|
|
||||||
checkWork("GET", "users/check_email?email=admin@admin.ZZZ");
|
|
||||||
checkFail("GET", "users/check_email?email=ksjhdkjfhskjdh", 404);
|
|
||||||
// not testable : get_token
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Order(5)
|
|
||||||
@Test
|
|
||||||
public void testMeWithToken() throws Exception {
|
|
||||||
loginAdmin();
|
|
||||||
final String result = api.get(String.class, "users/me");
|
|
||||||
Assertions.assertEquals("{\"id\":1,\"login\":\"karadmin\"}", result);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,23 @@ public class WebLauncherTest extends WebLauncher {
|
|||||||
public WebLauncherTest() {
|
public WebLauncherTest() {
|
||||||
LOGGER.debug("Configure REST system");
|
LOGGER.debug("Configure REST system");
|
||||||
// for local test:
|
// for local test:
|
||||||
ConfigBaseVariable.apiAdress = "http://127.0.0.1:12345/test/api/";
|
ConfigBaseVariable.apiAdress = "http://127.0.0.1:13212/test/api/";
|
||||||
|
// Enable the test mode permit to access to the test token (never use it in production).
|
||||||
ConfigBaseVariable.dbPort = "3306";
|
ConfigBaseVariable.testMode = "true";
|
||||||
// for the test we a in memory sqlite..
|
// for the test we a in memory sqlite..
|
||||||
ConfigBaseVariable.dbType = "sqlite";
|
if (true) {
|
||||||
ConfigBaseVariable.dbHost = "memory";
|
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||||
// for test we need to connect all time the DB
|
ConfigBaseVariable.dbType = "sqlite";
|
||||||
ConfigBaseVariable.dbKeepConnected = "true";
|
ConfigBaseVariable.dbHost = "memory";
|
||||||
|
// for test we need to connect all time the DB
|
||||||
ConfigBaseVariable.dbHost = "localhost";
|
ConfigBaseVariable.dbKeepConnected = "true";
|
||||||
ConfigBaseVariable.dbUser = "root";
|
}
|
||||||
ConfigBaseVariable.dbPassword = "ZERTYSDGFVHSDFGHJYZSDFGSQxfgsqdfgsqdrf4564654";
|
} else {
|
||||||
|
// Enable this if you want to access to a local MySQL base to test with an adminer
|
||||||
|
ConfigBaseVariable.bdDatabase = "test_db";
|
||||||
|
ConfigBaseVariable.dbPort = "3309";
|
||||||
|
ConfigBaseVariable.dbUser = "root";
|
||||||
|
//ConfigBaseVariable.dbPassword = "password";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,32 +18,32 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^17.3.4",
|
"@angular/animations": "^18.1.4",
|
||||||
"@angular/cdk": "^17.3.4",
|
"@angular/cdk": "^18.1.4",
|
||||||
"@angular/common": "^17.3.4",
|
"@angular/common": "^18.1.4",
|
||||||
"@angular/compiler": "^17.3.4",
|
"@angular/compiler": "^18.1.4",
|
||||||
"@angular/core": "^17.3.4",
|
"@angular/core": "^18.1.4",
|
||||||
"@angular/forms": "^17.3.4",
|
"@angular/forms": "^18.1.4",
|
||||||
"@angular/material": "^17.3.4",
|
"@angular/material": "^18.1.4",
|
||||||
"@angular/platform-browser": "^17.3.4",
|
"@angular/platform-browser": "^18.1.4",
|
||||||
"@angular/platform-browser-dynamic": "^17.3.4",
|
"@angular/platform-browser-dynamic": "^18.1.4",
|
||||||
"@angular/router": "^17.3.4",
|
"@angular/router": "^18.1.4",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"zone.js": "^0.14.4",
|
"zone.js": "^0.14.10",
|
||||||
"zod": "3.22.4",
|
"zod": "^3.23.8",
|
||||||
"@kangaroo-and-rabbit/kar-cw": "^0.2.0"
|
"@kangaroo-and-rabbit/kar-cw": "^0.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^17.3.4",
|
"@angular-devkit/build-angular": "^18.1.4",
|
||||||
"@angular-eslint/builder": "17.3.0",
|
"@angular-eslint/builder": "18.3.0",
|
||||||
"@angular-eslint/eslint-plugin": "17.3.0",
|
"@angular-eslint/eslint-plugin": "18.3.0",
|
||||||
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
"@angular-eslint/eslint-plugin-template": "18.3.0",
|
||||||
"@angular-eslint/schematics": "17.3.0",
|
"@angular-eslint/schematics": "18.3.0",
|
||||||
"@angular-eslint/template-parser": "17.3.0",
|
"@angular-eslint/template-parser": "18.3.0",
|
||||||
"@angular/cli": "^17.3.4",
|
"@angular/cli": "^18.1.4",
|
||||||
"@angular/compiler-cli": "^17.3.4",
|
"@angular/compiler-cli": "^18.1.4",
|
||||||
"@angular/language-service": "^17.3.4",
|
"@angular/language-service": "^18.1.4",
|
||||||
"npm-check-updates": "^16.14.18",
|
"npm-check-updates": "^17.0.6",
|
||||||
"tslib": "^2.6.2"
|
"tslib": "^2.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
13778
front/pnpm-lock.yaml
generated
13778
front/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -14,4 +14,4 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<app-element-player-audio></app-element-player-audio>
|
<AppPlayerAudio></AppPlayerAudio>
|
||||||
|
@ -11,7 +11,7 @@ import { HttpClientModule } from '@angular/common/http';
|
|||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
||||||
import { ElementDataImageComponent } from './component/data-image/data-image';
|
import { ElementDataImageComponent } from './component/data-image/data-image';
|
||||||
import { ElementTypeComponent } from './component/element-type/element-type';
|
import { ElementTypeComponent } from './component/AppElementHomeType/AppElementHomeType';
|
||||||
|
|
||||||
import { PopInCreateType } from './popin/create-type/create-type';
|
import { PopInCreateType } from './popin/create-type/create-type';
|
||||||
|
|
||||||
@ -22,7 +22,12 @@ import {
|
|||||||
} from './scene';
|
} from './scene';
|
||||||
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service';
|
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service';
|
||||||
import { UploadScene } from './scene/upload/upload';
|
import { UploadScene } from './scene/upload/upload';
|
||||||
import { ElementSeriesComponent, ElementTrackComponent, ElementSeasonComponent, ElementVideoComponent, ElementPlayerAudioComponent, DescriptionAreaComponent } from './component';
|
import {
|
||||||
|
AppDescriptionArea,
|
||||||
|
AppElementAlbum,
|
||||||
|
AppElementTrack,
|
||||||
|
ElementPlayerAudioComponent,
|
||||||
|
} from './component';
|
||||||
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
import { KarCWModule } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
@ -35,12 +40,10 @@ import { CommonModule } from "@angular/common";
|
|||||||
AppComponent,
|
AppComponent,
|
||||||
ElementDataImageComponent,
|
ElementDataImageComponent,
|
||||||
ElementTypeComponent,
|
ElementTypeComponent,
|
||||||
ElementSeriesComponent,
|
AppElementTrack,
|
||||||
ElementTrackComponent,
|
AppElementAlbum,
|
||||||
ElementSeasonComponent,
|
|
||||||
ElementVideoComponent,
|
|
||||||
ElementPlayerAudioComponent,
|
ElementPlayerAudioComponent,
|
||||||
DescriptionAreaComponent,
|
AppDescriptionArea,
|
||||||
PopInCreateType,
|
PopInCreateType,
|
||||||
HomeScene,
|
HomeScene,
|
||||||
HelpScene,
|
HelpScene,
|
||||||
@ -83,9 +86,8 @@ import { CommonModule } from "@angular/common";
|
|||||||
exports: [
|
exports: [
|
||||||
AppComponent,
|
AppComponent,
|
||||||
ElementTypeComponent,
|
ElementTypeComponent,
|
||||||
ElementSeriesComponent,
|
AppElementAlbum,
|
||||||
ElementSeasonComponent,
|
AppElementTrack,
|
||||||
ElementVideoComponent,
|
|
||||||
PopInCreateType,
|
PopInCreateType,
|
||||||
],
|
],
|
||||||
bootstrap: [
|
bootstrap: [
|
||||||
|
@ -1,108 +1,34 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
import {
|
||||||
import {UUID, Long, Album, isAlbum, } from "./model"
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestVoid,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import { z as zod } from "zod"
|
||||||
|
import {
|
||||||
|
Album,
|
||||||
|
AlbumWrite,
|
||||||
|
Long,
|
||||||
|
UUID,
|
||||||
|
ZodAlbum,
|
||||||
|
isAlbum,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace AlbumResource {
|
export namespace AlbumResource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a specific album
|
|
||||||
*/
|
|
||||||
export function remove({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Get a specific Album with his ID
|
|
||||||
*/
|
|
||||||
export function get({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Album> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isAlbum);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Update a specific album
|
|
||||||
*/
|
|
||||||
export function patch({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: Album,
|
|
||||||
}): Promise<Album> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}",
|
|
||||||
requestType: HTTPRequestModel.PATCH,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}, isAlbum);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Add an album (when all the data already exist)
|
|
||||||
*/
|
|
||||||
export function post({ restConfig, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: Album,
|
|
||||||
}): Promise<Album> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}, isAlbum);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Get all the available Albums
|
|
||||||
*/
|
|
||||||
export function gets({ restConfig, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Album[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isAlbum);
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Add a Track on a specific album
|
* Add a Track on a specific album
|
||||||
*/
|
*/
|
||||||
export function addTrack({ restConfig, params, }: {
|
export function addTrack({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
trackId: Long,
|
trackId: Long,
|
||||||
@ -120,10 +46,159 @@ export namespace AlbumResource {
|
|||||||
params,
|
params,
|
||||||
}, isAlbum);
|
}, isAlbum);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Get a specific Album with his ID
|
||||||
|
*/
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodAlbum);
|
||||||
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the available Albums
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Update a specific album
|
||||||
|
*/
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: AlbumWrite,
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Add an album (when all the data already exist)
|
||||||
|
*/
|
||||||
|
export function post({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: AlbumWrite,
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific album
|
||||||
|
*/
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a cover on a specific album
|
||||||
|
*/
|
||||||
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Album> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/album/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isAlbum);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Remove a Track on a specific album
|
* Remove a Track on a specific album
|
||||||
*/
|
*/
|
||||||
export function removeTrack({ restConfig, params, }: {
|
export function removeTrack({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
trackId: Long,
|
trackId: Long,
|
||||||
@ -144,15 +219,20 @@ export namespace AlbumResource {
|
|||||||
/**
|
/**
|
||||||
* Add a cover on a specific album
|
* Add a cover on a specific album
|
||||||
*/
|
*/
|
||||||
export function uploadCover({ restConfig, params, data, }: {
|
export function uploadCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
fileName: string,
|
|
||||||
file: File,
|
file: File,
|
||||||
},
|
},
|
||||||
|
callbacks?: RESTCallbacks,
|
||||||
}): Promise<Album> {
|
}): Promise<Album> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -164,27 +244,7 @@ export namespace AlbumResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
}, isAlbum);
|
callbacks,
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Remove a cover on a specific album
|
|
||||||
*/
|
|
||||||
export function removeCover({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: UUID,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Album> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/album/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isAlbum);
|
}, isAlbum);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,28 +1,31 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
import {
|
||||||
import {Artist, UUID, Long, isArtist, } from "./model"
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestVoid,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import { z as zod } from "zod"
|
||||||
|
import {
|
||||||
|
Artist,
|
||||||
|
ArtistWrite,
|
||||||
|
Long,
|
||||||
|
UUID,
|
||||||
|
ZodArtist,
|
||||||
|
isArtist,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace ArtistResource {
|
export namespace ArtistResource {
|
||||||
|
|
||||||
export function remove({ restConfig, params, }: {
|
export function get({
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/artist/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
});
|
}: {
|
||||||
};
|
|
||||||
export function get({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
@ -38,12 +41,44 @@ export namespace ArtistResource {
|
|||||||
params,
|
params,
|
||||||
}, isArtist);
|
}, isArtist);
|
||||||
};
|
};
|
||||||
export function patch({ restConfig, params, data, }: {
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodArtist);
|
||||||
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
|
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<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: Artist,
|
data: ArtistWrite,
|
||||||
}): Promise<Artist> {
|
}): Promise<Artist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -57,13 +92,16 @@ export namespace ArtistResource {
|
|||||||
data,
|
data,
|
||||||
}, isArtist);
|
}, isArtist);
|
||||||
};
|
};
|
||||||
export function post({ restConfig, data, }: {
|
export function post({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: Artist,
|
data: ArtistWrite,
|
||||||
}): Promise<Artist> {
|
}): Promise<Artist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/artist",
|
endPoint: "/artist/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
@ -72,41 +110,29 @@ export namespace ArtistResource {
|
|||||||
data,
|
data,
|
||||||
}, isArtist);
|
}, isArtist);
|
||||||
};
|
};
|
||||||
export function gets({ restConfig, }: {
|
export function remove({
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Artist[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/artist",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isArtist);
|
params,
|
||||||
};
|
}: {
|
||||||
export function uploadCover({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
}): Promise<void> {
|
||||||
fileName: string,
|
return RESTRequestVoid({
|
||||||
file: File,
|
|
||||||
},
|
|
||||||
}): Promise<Artist> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/artist/{id}/cover",
|
endPoint: "/artist/{id}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
});
|
||||||
}, isArtist);
|
|
||||||
};
|
};
|
||||||
export function removeCover({ restConfig, params, }: {
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: UUID,
|
coverId: UUID,
|
||||||
@ -124,4 +150,32 @@ export namespace ArtistResource {
|
|||||||
params,
|
params,
|
||||||
}, isArtist);
|
}, isArtist);
|
||||||
};
|
};
|
||||||
|
export function uploadCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
callbacks?: RESTCallbacks,
|
||||||
|
}): Promise<Artist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/artist/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}, isArtist);
|
||||||
|
};
|
||||||
}
|
}
|
@ -1,47 +1,71 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
import {
|
||||||
import {UUID, } from "./model"
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestVoid,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import {
|
||||||
|
UUID,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Insert a new data in the data environment
|
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
||||||
*/
|
*/
|
||||||
export function uploadFile({ restConfig, data, }: {
|
export function retrieveDataFull({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: {
|
queries: {
|
||||||
file: File,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
}): Promise<void> {
|
params: {
|
||||||
return RESTRequestVoid({
|
name: string,
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<object> {
|
||||||
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data//upload/",
|
endPoint: "/data/{uuid}/{name}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.GET,
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get back some data from the data environment
|
* Get back some data from the data environment
|
||||||
*/
|
*/
|
||||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
export function retrieveDataId({
|
||||||
export function retrieveDataId({ restConfig, queries, params, data, }: {
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
Authorization: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
id: UUID,
|
uuid: UUID,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<void> {
|
}): Promise<object> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{id}",
|
endPoint: "/data/{uuid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -53,20 +77,24 @@ export namespace DataResource {
|
|||||||
/**
|
/**
|
||||||
* Get a thumbnail of from the data environment (if resize is possible)
|
* Get a thumbnail of from the data environment (if resize is possible)
|
||||||
*/
|
*/
|
||||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
export function retrieveDataThumbnailId({
|
||||||
export function retrieveDataThumbnailId({ restConfig, queries, params, data, }: {
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
queries: {
|
||||||
Authorization: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
id: UUID,
|
uuid: UUID,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<void> {
|
}): Promise<object> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/thumbnail/{id}",
|
endPoint: "/data/thumbnail/{uuid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -76,28 +104,24 @@ export namespace DataResource {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
* Insert a new data in the data environment
|
||||||
*/
|
*/
|
||||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
export function uploadFile({
|
||||||
export function retrieveDataFull({ restConfig, queries, params, data, }: {
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
queries: {
|
data: {
|
||||||
Authorization: string,
|
file: File,
|
||||||
},
|
},
|
||||||
params: {
|
|
||||||
name: string,
|
|
||||||
id: UUID,
|
|
||||||
},
|
|
||||||
data: string,
|
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{id}/{name}",
|
endPoint: "/data//upload/",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
|
||||||
queries,
|
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
6
front/src/app/back-api/api/front.ts
Normal file
6
front/src/app/back-api/api/front.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
export namespace Front {
|
||||||
|
|
||||||
|
}
|
@ -1,28 +1,31 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
import {
|
||||||
import {UUID, Long, Gender, isGender, } from "./model"
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestVoid,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import { z as zod } from "zod"
|
||||||
|
import {
|
||||||
|
Gender,
|
||||||
|
GenderWrite,
|
||||||
|
Long,
|
||||||
|
UUID,
|
||||||
|
ZodGender,
|
||||||
|
isGender,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace GenderResource {
|
export namespace GenderResource {
|
||||||
|
|
||||||
export function remove({ restConfig, params, }: {
|
export function get({
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/gender/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
});
|
}: {
|
||||||
};
|
|
||||||
export function get({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
@ -38,12 +41,44 @@ export namespace GenderResource {
|
|||||||
params,
|
params,
|
||||||
}, isGender);
|
}, isGender);
|
||||||
};
|
};
|
||||||
export function patch({ restConfig, params, data, }: {
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodGender);
|
||||||
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
|
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<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: Gender,
|
data: GenderWrite,
|
||||||
}): Promise<Gender> {
|
}): Promise<Gender> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -57,13 +92,16 @@ export namespace GenderResource {
|
|||||||
data,
|
data,
|
||||||
}, isGender);
|
}, isGender);
|
||||||
};
|
};
|
||||||
export function post({ restConfig, data, }: {
|
export function post({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: Gender,
|
data: GenderWrite,
|
||||||
}): Promise<Gender> {
|
}): Promise<Gender> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/gender",
|
endPoint: "/gender/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
@ -72,41 +110,29 @@ export namespace GenderResource {
|
|||||||
data,
|
data,
|
||||||
}, isGender);
|
}, isGender);
|
||||||
};
|
};
|
||||||
export function gets({ restConfig, }: {
|
export function remove({
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Gender[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/gender",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isGender);
|
params,
|
||||||
};
|
}: {
|
||||||
export function uploadCover({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
}): Promise<void> {
|
||||||
fileName: string,
|
return RESTRequestVoid({
|
||||||
file: File,
|
|
||||||
},
|
|
||||||
}): Promise<Gender> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/gender/{id}/cover",
|
endPoint: "/gender/{id}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
});
|
||||||
}, isGender);
|
|
||||||
};
|
};
|
||||||
export function removeCover({ restConfig, params, }: {
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: UUID,
|
coverId: UUID,
|
||||||
@ -124,4 +150,32 @@ export namespace GenderResource {
|
|||||||
params,
|
params,
|
||||||
}, isGender);
|
}, isGender);
|
||||||
};
|
};
|
||||||
|
export function uploadCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
callbacks?: RESTCallbacks,
|
||||||
|
}): Promise<Gender> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/gender/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}, isGender);
|
||||||
|
};
|
||||||
}
|
}
|
32
front/src/app/back-api/api/health-check.ts
Normal file
32
front/src/app/back-api/api/health-check.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import {
|
||||||
|
HealthResult,
|
||||||
|
isHealthResult,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
|
export namespace HealthCheck {
|
||||||
|
|
||||||
|
export function getHealth({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<HealthResult> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/health_check/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isHealthResult);
|
||||||
|
};
|
||||||
|
}
|
12
front/src/app/back-api/api/index.ts
Normal file
12
front/src/app/back-api/api/index.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
export * from "./album-resource"
|
||||||
|
export * from "./artist-resource"
|
||||||
|
export * from "./data-resource"
|
||||||
|
export * from "./front"
|
||||||
|
export * from "./gender-resource"
|
||||||
|
export * from "./health-check"
|
||||||
|
export * from "./playlist-resource"
|
||||||
|
export * from "./track-resource"
|
||||||
|
export * from "./user-resource"
|
@ -1,28 +1,51 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
import {
|
||||||
import {UUID, Long, Playlist, isPlaylist, } from "./model"
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestVoid,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import { z as zod } from "zod"
|
||||||
|
import {
|
||||||
|
Long,
|
||||||
|
Playlist,
|
||||||
|
PlaylistWrite,
|
||||||
|
UUID,
|
||||||
|
ZodPlaylist,
|
||||||
|
isPlaylist,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace PlaylistResource {
|
export namespace PlaylistResource {
|
||||||
|
|
||||||
export function remove({ restConfig, params, }: {
|
export function addTrack({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
|
trackId: Long,
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<void> {
|
}): Promise<Playlist> {
|
||||||
return RESTRequestVoid({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist/{id}",
|
endPoint: "/playlist/{id}/track/{trackId}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
});
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function get({ restConfig, params, }: {
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
@ -38,12 +61,44 @@ export namespace PlaylistResource {
|
|||||||
params,
|
params,
|
||||||
}, isPlaylist);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function patch({ restConfig, params, data, }: {
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodPlaylist);
|
||||||
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
|
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<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: Playlist,
|
data: PlaylistWrite,
|
||||||
}): Promise<Playlist> {
|
}): Promise<Playlist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -57,13 +112,16 @@ export namespace PlaylistResource {
|
|||||||
data,
|
data,
|
||||||
}, isPlaylist);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function post({ restConfig, data, }: {
|
export function post({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: Playlist,
|
data: PlaylistWrite,
|
||||||
}): Promise<Playlist> {
|
}): Promise<Playlist> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist",
|
endPoint: "/playlist/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
@ -72,77 +130,29 @@ export namespace PlaylistResource {
|
|||||||
data,
|
data,
|
||||||
}, isPlaylist);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
export function gets({ restConfig, }: {
|
export function remove({
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Playlist[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/playlist",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isPlaylist);
|
|
||||||
};
|
|
||||||
export function addTrack({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
trackId: Long,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Playlist> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/playlist/{id}/track/{trackId}",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isPlaylist);
|
}: {
|
||||||
};
|
|
||||||
export function removeTrack({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
trackId: Long,
|
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Playlist> {
|
}): Promise<void> {
|
||||||
return RESTRequestJson({
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/playlist/{id}/track/{trackId}",
|
endPoint: "/playlist/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isPlaylist);
|
});
|
||||||
};
|
};
|
||||||
export function uploadCover({ restConfig, params, data, }: {
|
export function removeCover({
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
fileName: string,
|
|
||||||
file: File,
|
|
||||||
},
|
|
||||||
}): Promise<Playlist> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/playlist/{id}/cover",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
}: {
|
||||||
}, isPlaylist);
|
|
||||||
};
|
|
||||||
export function removeCover({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: UUID,
|
coverId: UUID,
|
||||||
@ -160,4 +170,50 @@ export namespace PlaylistResource {
|
|||||||
params,
|
params,
|
||||||
}, isPlaylist);
|
}, isPlaylist);
|
||||||
};
|
};
|
||||||
|
export function removeTrack({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
trackId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}/track/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
|
export function uploadCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
}): Promise<Playlist> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/playlist/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isPlaylist);
|
||||||
|
};
|
||||||
}
|
}
|
@ -1,90 +1,31 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
import {
|
||||||
import {UUID, Long, Track, isTrack, } from "./model"
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTCallbacks,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
RESTRequestVoid,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import { z as zod } from "zod"
|
||||||
|
import {
|
||||||
|
Long,
|
||||||
|
Track,
|
||||||
|
TrackWrite,
|
||||||
|
UUID,
|
||||||
|
ZodTrack,
|
||||||
|
isTrack,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace TrackResource {
|
export namespace TrackResource {
|
||||||
|
|
||||||
export function remove({ restConfig, params, }: {
|
export function addTrack({
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
});
|
}: {
|
||||||
};
|
|
||||||
export function get({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Track> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isTrack);
|
|
||||||
};
|
|
||||||
export function patch({ restConfig, params, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: Track,
|
|
||||||
}): Promise<Track> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track/{id}",
|
|
||||||
requestType: HTTPRequestModel.PATCH,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}, isTrack);
|
|
||||||
};
|
|
||||||
export function post({ restConfig, data, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
data: Track,
|
|
||||||
}): Promise<Track> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track",
|
|
||||||
requestType: HTTPRequestModel.POST,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
data,
|
|
||||||
}, isTrack);
|
|
||||||
};
|
|
||||||
export function gets({ restConfig, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Track[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/track",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isTrack);
|
|
||||||
};
|
|
||||||
export function addTrack({ restConfig, params, }: {
|
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
artistId: Long,
|
artistId: Long,
|
||||||
@ -102,39 +43,69 @@ export namespace TrackResource {
|
|||||||
params,
|
params,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function removeTrack({ restConfig, params, }: {
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
artistId: Long,
|
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Track> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/track/{id}/artist/{trackId}",
|
endPoint: "/track/{id}",
|
||||||
requestType: HTTPRequestModel.DELETE,
|
requestType: HTTPRequestModel.GET,
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function uploadCover({ restConfig, params, data, }: {
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodTrack);
|
||||||
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
|
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<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
data: TrackWrite,
|
||||||
fileName: string,
|
|
||||||
file: File,
|
|
||||||
},
|
|
||||||
}): Promise<Track> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/track/{id}/cover",
|
endPoint: "/track/{id}",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.PATCH,
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -142,7 +113,47 @@ export namespace TrackResource {
|
|||||||
data,
|
data,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function removeCover({ restConfig, params, }: {
|
export function post({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
data: TrackWrite,
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function remove({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
coverId: UUID,
|
coverId: UUID,
|
||||||
@ -160,7 +171,60 @@ export namespace TrackResource {
|
|||||||
params,
|
params,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
export function uploadTrack({ restConfig, data, }: {
|
export function removeTrack({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
artistId: Long,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}/artist/{trackId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function uploadCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
file: File,
|
||||||
|
},
|
||||||
|
callbacks?: RESTCallbacks,
|
||||||
|
}): Promise<Track> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/track/{id}/cover",
|
||||||
|
requestType: HTTPRequestModel.POST,
|
||||||
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}, isTrack);
|
||||||
|
};
|
||||||
|
export function uploadTrack({
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
callbacks,
|
||||||
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: {
|
data: {
|
||||||
fileName: string,
|
fileName: string,
|
||||||
@ -171,6 +235,7 @@ export namespace TrackResource {
|
|||||||
trackId: Long,
|
trackId: Long,
|
||||||
title: string,
|
title: string,
|
||||||
},
|
},
|
||||||
|
callbacks?: RESTCallbacks,
|
||||||
}): Promise<Track> {
|
}): Promise<Track> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -181,6 +246,7 @@ export namespace TrackResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
data,
|
data,
|
||||||
|
callbacks,
|
||||||
}, isTrack);
|
}, isTrack);
|
||||||
};
|
};
|
||||||
}
|
}
|
90
front/src/app/back-api/api/user-resource.ts
Normal file
90
front/src/app/back-api/api/user-resource.ts
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
HTTPMimeType,
|
||||||
|
HTTPRequestModel,
|
||||||
|
RESTConfig,
|
||||||
|
RESTRequestJson,
|
||||||
|
} from "../rest-tools";
|
||||||
|
|
||||||
|
import { z as zod } from "zod"
|
||||||
|
import {
|
||||||
|
Long,
|
||||||
|
UserKarusic,
|
||||||
|
UserOut,
|
||||||
|
ZodUserKarusic,
|
||||||
|
isUserKarusic,
|
||||||
|
isUserOut,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
|
export namespace UserResource {
|
||||||
|
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
produce,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
|
}): Promise<UserKarusic> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: produce,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserKarusic);
|
||||||
|
};
|
||||||
|
export function getMe({
|
||||||
|
restConfig,
|
||||||
|
produce,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
|
}): Promise<UserOut> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/me",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: produce,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isUserOut);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodUserKarusic);
|
||||||
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
|
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,
|
||||||
|
produce,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
produce: HTTPMimeType.JSON,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: produce,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* API of the server (auto-generated code)
|
|
||||||
*/
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
|
||||||
import {} from "./model"
|
|
||||||
export namespace Front {
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* API of the server (auto-generated code)
|
|
||||||
*/
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
|
||||||
import {HealthResult, isHealthResult, } from "./model"
|
|
||||||
export namespace HealthCheck {
|
|
||||||
|
|
||||||
export function getHealth({ restConfig, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<HealthResult> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/health_check",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isHealthResult);
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,13 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Global import of the package
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
export * from "./model";
|
export * from "./model";
|
||||||
export * from "./album-resource";
|
export * from "./api";
|
||||||
export * from "./artist-resource";
|
export * from "./rest-tools";
|
||||||
export * from "./front";
|
|
||||||
export * from "./gender-resource";
|
|
||||||
export * from "./health-check";
|
|
||||||
export * from "./playlist-resource";
|
|
||||||
export * from "./user-resource";
|
|
||||||
export * from "./track-resource";
|
|
||||||
export * from "./data-resource";
|
|
||||||
|
@ -1,407 +0,0 @@
|
|||||||
/**
|
|
||||||
* Interface of the server (auto-generated code)
|
|
||||||
*/
|
|
||||||
import { z as zod } from "zod";
|
|
||||||
|
|
||||||
export const ZodUUID = zod.string().uuid();
|
|
||||||
export type UUID = zod.infer<typeof ZodUUID>;
|
|
||||||
export function isUUID(data: any): data is UUID {
|
|
||||||
try {
|
|
||||||
ZodUUID.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodLong = zod.number();
|
|
||||||
export type Long = zod.infer<typeof ZodLong>;
|
|
||||||
export function isLong(data: any): data is Long {
|
|
||||||
try {
|
|
||||||
ZodLong.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodInteger = zod.number().safe();
|
|
||||||
export type Integer = zod.infer<typeof ZodInteger>;
|
|
||||||
export function isInteger(data: any): data is Integer {
|
|
||||||
try {
|
|
||||||
ZodInteger.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodFloat = zod.number();
|
|
||||||
export type Float = zod.infer<typeof ZodFloat>;
|
|
||||||
export function isFloat(data: any): data is Float {
|
|
||||||
try {
|
|
||||||
ZodFloat.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodInstant = zod.string();
|
|
||||||
export type Instant = zod.infer<typeof ZodInstant>;
|
|
||||||
export function isInstant(data: any): data is Instant {
|
|
||||||
try {
|
|
||||||
ZodInstant.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodDate = zod.date();
|
|
||||||
export type Date = zod.infer<typeof ZodDate>;
|
|
||||||
export function isDate(data: any): data is Date {
|
|
||||||
try {
|
|
||||||
ZodDate.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodTimestamp = zod.date();
|
|
||||||
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
|
||||||
export function isTimestamp(data: any): data is Timestamp {
|
|
||||||
try {
|
|
||||||
ZodTimestamp.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodLocalDate = zod.date();
|
|
||||||
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
|
||||||
export function isLocalDate(data: any): data is LocalDate {
|
|
||||||
try {
|
|
||||||
ZodLocalDate.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodLocalTime = zod.date();
|
|
||||||
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
|
||||||
export function isLocalTime(data: any): data is LocalTime {
|
|
||||||
try {
|
|
||||||
ZodLocalTime.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodRestErrorResponse = zod.object({
|
|
||||||
uuid: ZodUUID.optional(),
|
|
||||||
time: zod.string().max(255).optional(),
|
|
||||||
error: zod.string().max(255).optional(),
|
|
||||||
message: zod.string().max(255).optional(),
|
|
||||||
status: ZodInteger,
|
|
||||||
statusMessage: zod.string().max(255).optional()
|
|
||||||
});
|
|
||||||
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
|
||||||
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
|
||||||
try {
|
|
||||||
ZodRestErrorResponse.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGenericTiming = zod.object({
|
|
||||||
// Create time of the object
|
|
||||||
createdAt: ZodDate.readonly().optional(),
|
|
||||||
// When update the object
|
|
||||||
updatedAt: ZodDate.readonly().optional()
|
|
||||||
});
|
|
||||||
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
|
||||||
export function isGenericTiming(data: any): data is GenericTiming {
|
|
||||||
try {
|
|
||||||
ZodGenericTiming.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGenericData = ZodGenericTiming.extend({
|
|
||||||
// Unique Id of the object
|
|
||||||
id: ZodLong.readonly().optional()
|
|
||||||
});
|
|
||||||
export type GenericData = zod.infer<typeof ZodGenericData>;
|
|
||||||
export function isGenericData(data: any): data is GenericData {
|
|
||||||
try {
|
|
||||||
ZodGenericData.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
|
||||||
// Deleted state
|
|
||||||
deleted: zod.boolean().readonly().optional()
|
|
||||||
});
|
|
||||||
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
|
||||||
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
|
||||||
try {
|
|
||||||
ZodGenericDataSoftDelete.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodNodeSmall = ZodGenericDataSoftDelete.extend({
|
|
||||||
name: zod.string().max(256).optional(),
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(ZodUUID).optional()
|
|
||||||
});
|
|
||||||
export type NodeSmall = zod.infer<typeof ZodNodeSmall>;
|
|
||||||
export function isNodeSmall(data: any): data is NodeSmall {
|
|
||||||
try {
|
|
||||||
ZodNodeSmall.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodAlbum = ZodNodeSmall.extend({
|
|
||||||
publication: ZodLocalDate.optional()
|
|
||||||
});
|
|
||||||
export type Album = zod.infer<typeof ZodAlbum>;
|
|
||||||
export function isAlbum(data: any): data is Album {
|
|
||||||
try {
|
|
||||||
ZodAlbum.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodArtist = ZodNodeSmall.extend({
|
|
||||||
firstName: zod.string().max(256).optional(),
|
|
||||||
surname: zod.string().max(256).optional(),
|
|
||||||
birth: ZodLocalDate.optional(),
|
|
||||||
death: ZodLocalDate.optional()
|
|
||||||
});
|
|
||||||
export type Artist = zod.infer<typeof ZodArtist>;
|
|
||||||
export function isArtist(data: any): data is Artist {
|
|
||||||
try {
|
|
||||||
ZodArtist.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodGender = ZodNodeSmall.extend({
|
|
||||||
});
|
|
||||||
export type Gender = zod.infer<typeof ZodGender>;
|
|
||||||
export function isGender(data: any): data is Gender {
|
|
||||||
try {
|
|
||||||
ZodGender.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodHealthResult = zod.object({
|
|
||||||
});
|
|
||||||
export type HealthResult = zod.infer<typeof ZodHealthResult>;
|
|
||||||
export function isHealthResult(data: any): data is HealthResult {
|
|
||||||
try {
|
|
||||||
ZodHealthResult.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodPlaylist = ZodNodeSmall.extend({
|
|
||||||
tracks: zod.array(ZodLong).optional()
|
|
||||||
});
|
|
||||||
export type Playlist = zod.infer<typeof ZodPlaylist>;
|
|
||||||
export function isPlaylist(data: any): data is Playlist {
|
|
||||||
try {
|
|
||||||
ZodPlaylist.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
|
||||||
login: zod.string().max(128).optional(),
|
|
||||||
lastConnection: ZodTimestamp.optional(),
|
|
||||||
admin: zod.boolean(),
|
|
||||||
blocked: zod.boolean(),
|
|
||||||
removed: zod.boolean(),
|
|
||||||
covers: zod.array(ZodLong).optional()
|
|
||||||
});
|
|
||||||
export type User = zod.infer<typeof ZodUser>;
|
|
||||||
export function isUser(data: any): data is User {
|
|
||||||
try {
|
|
||||||
ZodUser.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUserKarusic = ZodUser.extend({
|
|
||||||
});
|
|
||||||
export type UserKarusic = zod.infer<typeof ZodUserKarusic>;
|
|
||||||
export function isUserKarusic(data: any): data is UserKarusic {
|
|
||||||
try {
|
|
||||||
ZodUserKarusic.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUserOut = zod.object({
|
|
||||||
id: ZodLong,
|
|
||||||
login: zod.string().max(255).optional()
|
|
||||||
});
|
|
||||||
export type UserOut = zod.infer<typeof ZodUserOut>;
|
|
||||||
export function isUserOut(data: any): data is UserOut {
|
|
||||||
try {
|
|
||||||
ZodUserOut.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodTrack = ZodNodeSmall.extend({
|
|
||||||
genderId: ZodLong.optional(),
|
|
||||||
albumId: ZodLong.optional(),
|
|
||||||
track: ZodLong.optional(),
|
|
||||||
dataId: ZodUUID.optional(),
|
|
||||||
artists: zod.array(ZodLong).optional()
|
|
||||||
});
|
|
||||||
export type Track = zod.infer<typeof ZodTrack>;
|
|
||||||
export function isTrack(data: any): data is Track {
|
|
||||||
try {
|
|
||||||
ZodTrack.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUUIDGenericData = ZodGenericTiming.extend({
|
|
||||||
// Unique UUID of the object
|
|
||||||
id: ZodUUID.readonly().optional()
|
|
||||||
});
|
|
||||||
export type UUIDGenericData = zod.infer<typeof ZodUUIDGenericData>;
|
|
||||||
export function isUUIDGenericData(data: any): data is UUIDGenericData {
|
|
||||||
try {
|
|
||||||
ZodUUIDGenericData.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUUIDGenericDataSoftDelete = ZodUUIDGenericData.extend({
|
|
||||||
// Deleted state
|
|
||||||
deleted: zod.boolean().readonly().optional()
|
|
||||||
});
|
|
||||||
export type UUIDGenericDataSoftDelete = zod.infer<typeof ZodUUIDGenericDataSoftDelete>;
|
|
||||||
export function isUUIDGenericDataSoftDelete(data: any): data is UUIDGenericDataSoftDelete {
|
|
||||||
try {
|
|
||||||
ZodUUIDGenericDataSoftDelete.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodData = ZodUUIDGenericDataSoftDelete.extend({
|
|
||||||
// Sha512 of the data
|
|
||||||
sha512: zod.string().max(128).optional(),
|
|
||||||
// Mime -type of the media
|
|
||||||
mimeType: zod.string().max(128).optional(),
|
|
||||||
// Size in Byte of the data
|
|
||||||
size: ZodLong.optional()
|
|
||||||
});
|
|
||||||
export type Data = zod.infer<typeof ZodData>;
|
|
||||||
export function isData(data: any): data is Data {
|
|
||||||
try {
|
|
||||||
ZodData.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
53
front/src/app/back-api/model/album.ts
Normal file
53
front/src/app/back-api/model/album.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodLocalDate} from "./local-date";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodAlbum = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
publication: ZodLocalDate.optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Album = zod.infer<typeof ZodAlbum>;
|
||||||
|
|
||||||
|
export function isAlbum(data: any): data is Album {
|
||||||
|
try {
|
||||||
|
ZodAlbum.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodAlbum' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodAlbumWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
publication: ZodLocalDate.nullable().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type AlbumWrite = zod.infer<typeof ZodAlbumWrite>;
|
||||||
|
|
||||||
|
export function isAlbumWrite(data: any): data is AlbumWrite {
|
||||||
|
try {
|
||||||
|
ZodAlbumWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodAlbumWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
59
front/src/app/back-api/model/artist.ts
Normal file
59
front/src/app/back-api/model/artist.ts
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodLocalDate} from "./local-date";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodArtist = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
firstName: zod.string().max(256).optional(),
|
||||||
|
surname: zod.string().max(256).optional(),
|
||||||
|
birth: ZodLocalDate.optional(),
|
||||||
|
death: ZodLocalDate.optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Artist = zod.infer<typeof ZodArtist>;
|
||||||
|
|
||||||
|
export function isArtist(data: any): data is Artist {
|
||||||
|
try {
|
||||||
|
ZodArtist.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodArtist' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodArtistWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
firstName: zod.string().max(256).nullable().optional(),
|
||||||
|
surname: zod.string().max(256).nullable().optional(),
|
||||||
|
birth: ZodLocalDate.nullable().optional(),
|
||||||
|
death: ZodLocalDate.nullable().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ArtistWrite = zod.infer<typeof ZodArtistWrite>;
|
||||||
|
|
||||||
|
export function isArtistWrite(data: any): data is ArtistWrite {
|
||||||
|
try {
|
||||||
|
ZodArtistWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodArtistWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
50
front/src/app/back-api/model/gender.ts
Normal file
50
front/src/app/back-api/model/gender.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodGender = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Gender = zod.infer<typeof ZodGender>;
|
||||||
|
|
||||||
|
export function isGender(data: any): data is Gender {
|
||||||
|
try {
|
||||||
|
ZodGender.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGender' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenderWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenderWrite = zod.infer<typeof ZodGenderWrite>;
|
||||||
|
|
||||||
|
export function isGenderWrite(data: any): data is GenderWrite {
|
||||||
|
try {
|
||||||
|
ZodGenderWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenderWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
41
front/src/app/back-api/model/generic-data-soft-delete.ts
Normal file
41
front/src/app/back-api/model/generic-data-soft-delete.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodGenericData, ZodGenericDataWrite } from "./generic-data";
|
||||||
|
|
||||||
|
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||||
|
/**
|
||||||
|
* Deleted state
|
||||||
|
*/
|
||||||
|
deleted: zod.boolean().readonly().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
||||||
|
|
||||||
|
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
||||||
|
try {
|
||||||
|
ZodGenericDataSoftDelete.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericDataSoftDelete' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataWrite.extend({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
||||||
|
|
||||||
|
export function isGenericDataSoftDeleteWrite(data: any): data is GenericDataSoftDeleteWrite {
|
||||||
|
try {
|
||||||
|
ZodGenericDataSoftDeleteWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericDataSoftDeleteWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
42
front/src/app/back-api/model/generic-data.ts
Normal file
42
front/src/app/back-api/model/generic-data.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodGenericTiming, ZodGenericTimingWrite } from "./generic-timing";
|
||||||
|
|
||||||
|
export const ZodGenericData = ZodGenericTiming.extend({
|
||||||
|
/**
|
||||||
|
* Unique Id of the object
|
||||||
|
*/
|
||||||
|
id: ZodLong.readonly(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericData = zod.infer<typeof ZodGenericData>;
|
||||||
|
|
||||||
|
export function isGenericData(data: any): data is GenericData {
|
||||||
|
try {
|
||||||
|
ZodGenericData.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericData' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenericDataWrite = ZodGenericTimingWrite.extend({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
||||||
|
|
||||||
|
export function isGenericDataWrite(data: any): data is GenericDataWrite {
|
||||||
|
try {
|
||||||
|
ZodGenericDataWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericDataWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
45
front/src/app/back-api/model/generic-timing.ts
Normal file
45
front/src/app/back-api/model/generic-timing.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodIsoDate} from "./iso-date";
|
||||||
|
|
||||||
|
export const ZodGenericTiming = zod.object({
|
||||||
|
/**
|
||||||
|
* Create time of the object
|
||||||
|
*/
|
||||||
|
createdAt: ZodIsoDate.readonly().optional(),
|
||||||
|
/**
|
||||||
|
* When update the object
|
||||||
|
*/
|
||||||
|
updatedAt: ZodIsoDate.readonly().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
||||||
|
|
||||||
|
export function isGenericTiming(data: any): data is GenericTiming {
|
||||||
|
try {
|
||||||
|
ZodGenericTiming.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericTiming' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodGenericTimingWrite = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
||||||
|
|
||||||
|
export function isGenericTimingWrite(data: any): data is GenericTimingWrite {
|
||||||
|
try {
|
||||||
|
ZodGenericTimingWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodGenericTimingWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
36
front/src/app/back-api/model/health-result.ts
Normal file
36
front/src/app/back-api/model/health-result.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodHealthResult = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type HealthResult = zod.infer<typeof ZodHealthResult>;
|
||||||
|
|
||||||
|
export function isHealthResult(data: any): data is HealthResult {
|
||||||
|
try {
|
||||||
|
ZodHealthResult.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodHealthResult' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodHealthResultWrite = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type HealthResultWrite = zod.infer<typeof ZodHealthResultWrite>;
|
||||||
|
|
||||||
|
export function isHealthResultWrite(data: any): data is HealthResultWrite {
|
||||||
|
try {
|
||||||
|
ZodHealthResultWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodHealthResultWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
22
front/src/app/back-api/model/index.ts
Normal file
22
front/src/app/back-api/model/index.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
export * from "./album"
|
||||||
|
export * from "./artist"
|
||||||
|
export * from "./gender"
|
||||||
|
export * from "./generic-data"
|
||||||
|
export * from "./generic-data-soft-delete"
|
||||||
|
export * from "./generic-timing"
|
||||||
|
export * from "./health-result"
|
||||||
|
export * from "./int"
|
||||||
|
export * from "./iso-date"
|
||||||
|
export * from "./local-date"
|
||||||
|
export * from "./long"
|
||||||
|
export * from "./playlist"
|
||||||
|
export * from "./rest-error-response"
|
||||||
|
export * from "./timestamp"
|
||||||
|
export * from "./track"
|
||||||
|
export * from "./user"
|
||||||
|
export * from "./user-karusic"
|
||||||
|
export * from "./user-out"
|
||||||
|
export * from "./uuid"
|
36
front/src/app/back-api/model/int.ts
Normal file
36
front/src/app/back-api/model/int.ts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const Zodint = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type int = zod.infer<typeof Zodint>;
|
||||||
|
|
||||||
|
export function isint(data: any): data is int {
|
||||||
|
try {
|
||||||
|
Zodint.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='Zodint' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodintWrite = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type intWrite = zod.infer<typeof ZodintWrite>;
|
||||||
|
|
||||||
|
export function isintWrite(data: any): data is intWrite {
|
||||||
|
try {
|
||||||
|
ZodintWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodintWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
8
front/src/app/back-api/model/iso-date.ts
Normal file
8
front/src/app/back-api/model/iso-date.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodIsoDate = zod.string().datetime({ precision: 3 });
|
||||||
|
export type IsoDate = zod.infer<typeof ZodIsoDate>;
|
8
front/src/app/back-api/model/local-date.ts
Normal file
8
front/src/app/back-api/model/local-date.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLocalDate = zod.string().date();
|
||||||
|
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
8
front/src/app/back-api/model/long.ts
Normal file
8
front/src/app/back-api/model/long.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodLong = zod.number();
|
||||||
|
export type Long = zod.infer<typeof ZodLong>;
|
50
front/src/app/back-api/model/node-small.ts
Normal file
50
front/src/app/back-api/model/node-small.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodNodeSmall = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type NodeSmall = zod.infer<typeof ZodNodeSmall>;
|
||||||
|
|
||||||
|
export function isNodeSmall(data: any): data is NodeSmall {
|
||||||
|
try {
|
||||||
|
ZodNodeSmall.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodNodeSmall' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodNodeSmallWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type NodeSmallWrite = zod.infer<typeof ZodNodeSmallWrite>;
|
||||||
|
|
||||||
|
export function isNodeSmallWrite(data: any): data is NodeSmallWrite {
|
||||||
|
try {
|
||||||
|
ZodNodeSmallWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodNodeSmallWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
53
front/src/app/back-api/model/playlist.ts
Normal file
53
front/src/app/back-api/model/playlist.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodPlaylist = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
tracks: zod.array(ZodLong),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Playlist = zod.infer<typeof ZodPlaylist>;
|
||||||
|
|
||||||
|
export function isPlaylist(data: any): data is Playlist {
|
||||||
|
try {
|
||||||
|
ZodPlaylist.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodPlaylist' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodPlaylistWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
tracks: zod.array(ZodLong).optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type PlaylistWrite = zod.infer<typeof ZodPlaylistWrite>;
|
||||||
|
|
||||||
|
export function isPlaylistWrite(data: any): data is PlaylistWrite {
|
||||||
|
try {
|
||||||
|
ZodPlaylistWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodPlaylistWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
29
front/src/app/back-api/model/rest-error-response.ts
Normal file
29
front/src/app/back-api/model/rest-error-response.ts
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {Zodint, ZodintWrite } from "./int";
|
||||||
|
|
||||||
|
export const ZodRestErrorResponse = zod.object({
|
||||||
|
uuid: ZodUUID.optional(),
|
||||||
|
name: zod.string(),
|
||||||
|
message: zod.string(),
|
||||||
|
time: zod.string(),
|
||||||
|
status: Zodint,
|
||||||
|
statusMessage: zod.string(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
||||||
|
|
||||||
|
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||||
|
try {
|
||||||
|
ZodRestErrorResponse.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodRestErrorResponse' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
8
front/src/app/back-api/model/timestamp.ts
Normal file
8
front/src/app/back-api/model/timestamp.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodTimestamp = zod.string().datetime({ precision: 3 });
|
||||||
|
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
61
front/src/app/back-api/model/track.ts
Normal file
61
front/src/app/back-api/model/track.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodTrack = ZodGenericDataSoftDelete.extend({
|
||||||
|
name: zod.string().max(256).optional(),
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
genderId: ZodLong.optional(),
|
||||||
|
albumId: ZodLong.optional(),
|
||||||
|
track: ZodLong.optional(),
|
||||||
|
dataId: ZodUUID.optional(),
|
||||||
|
artists: zod.array(ZodLong),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Track = zod.infer<typeof ZodTrack>;
|
||||||
|
|
||||||
|
export function isTrack(data: any): data is Track {
|
||||||
|
try {
|
||||||
|
ZodTrack.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodTrack' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodTrackWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
genderId: ZodLong.nullable().optional(),
|
||||||
|
albumId: ZodLong.nullable().optional(),
|
||||||
|
track: ZodLong.nullable().optional(),
|
||||||
|
dataId: ZodUUID.nullable().optional(),
|
||||||
|
artists: zod.array(ZodLong).optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type TrackWrite = zod.infer<typeof ZodTrackWrite>;
|
||||||
|
|
||||||
|
export function isTrackWrite(data: any): data is TrackWrite {
|
||||||
|
try {
|
||||||
|
ZodTrackWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodTrackWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
37
front/src/app/back-api/model/user-karusic.ts
Normal file
37
front/src/app/back-api/model/user-karusic.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUser, ZodUserWrite } from "./user";
|
||||||
|
|
||||||
|
export const ZodUserKarusic = ZodUser.extend({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserKarusic = zod.infer<typeof ZodUserKarusic>;
|
||||||
|
|
||||||
|
export function isUserKarusic(data: any): data is UserKarusic {
|
||||||
|
try {
|
||||||
|
ZodUserKarusic.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserKarusic' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodUserKarusicWrite = ZodUserWrite.extend({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserKarusicWrite = zod.infer<typeof ZodUserKarusicWrite>;
|
||||||
|
|
||||||
|
export function isUserKarusicWrite(data: any): data is UserKarusicWrite {
|
||||||
|
try {
|
||||||
|
ZodUserKarusicWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserKarusicWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
41
front/src/app/back-api/model/user-out.ts
Normal file
41
front/src/app/back-api/model/user-out.ts
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
|
||||||
|
export const ZodUserOut = zod.object({
|
||||||
|
id: ZodLong,
|
||||||
|
login: zod.string().max(255).optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserOut = zod.infer<typeof ZodUserOut>;
|
||||||
|
|
||||||
|
export function isUserOut(data: any): data is UserOut {
|
||||||
|
try {
|
||||||
|
ZodUserOut.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserOut' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodUserOutWrite = zod.object({
|
||||||
|
id: ZodLong,
|
||||||
|
login: zod.string().max(255).nullable().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
||||||
|
|
||||||
|
export function isUserOutWrite(data: any): data is UserOutWrite {
|
||||||
|
try {
|
||||||
|
ZodUserOutWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserOutWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
57
front/src/app/back-api/model/user.ts
Normal file
57
front/src/app/back-api/model/user.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodTimestamp} from "./timestamp";
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||||
|
login: zod.string().max(128).optional(),
|
||||||
|
lastConnection: ZodTimestamp.optional(),
|
||||||
|
admin: zod.boolean(),
|
||||||
|
blocked: zod.boolean(),
|
||||||
|
removed: zod.boolean(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type User = zod.infer<typeof ZodUser>;
|
||||||
|
|
||||||
|
export function isUser(data: any): data is User {
|
||||||
|
try {
|
||||||
|
ZodUser.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUser' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const ZodUserWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
login: zod.string().max(128).nullable().optional(),
|
||||||
|
lastConnection: ZodTimestamp.nullable().optional(),
|
||||||
|
admin: zod.boolean(),
|
||||||
|
blocked: zod.boolean(),
|
||||||
|
removed: zod.boolean(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserWrite = zod.infer<typeof ZodUserWrite>;
|
||||||
|
|
||||||
|
export function isUserWrite(data: any): data is UserWrite {
|
||||||
|
try {
|
||||||
|
ZodUserWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
8
front/src/app/back-api/model/uuid.ts
Normal file
8
front/src/app/back-api/model/uuid.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodUUID = zod.string().uuid();
|
||||||
|
export type UUID = zod.infer<typeof ZodUUID>;
|
@ -4,243 +4,442 @@
|
|||||||
* @license MPL-2
|
* @license MPL-2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RestErrorResponse } from "./model"
|
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||||
|
|
||||||
export enum HTTPRequestModel {
|
export enum HTTPRequestModel {
|
||||||
DELETE = 'DELETE',
|
DELETE = "DELETE",
|
||||||
GET = 'GET',
|
GET = "GET",
|
||||||
PATCH = 'PATCH',
|
PATCH = "PATCH",
|
||||||
POST = 'POST',
|
POST = "POST",
|
||||||
PUT = 'PUT',
|
PUT = "PUT",
|
||||||
}
|
}
|
||||||
export enum HTTPMimeType {
|
export enum HTTPMimeType {
|
||||||
ALL = '*/*',
|
ALL = "*/*",
|
||||||
CSV = 'text/csv',
|
CSV = "text/csv",
|
||||||
IMAGE = 'image/*',
|
IMAGE = "image/*",
|
||||||
IMAGE_JPEG = 'image/jpeg',
|
IMAGE_JPEG = "image/jpeg",
|
||||||
IMAGE_PNG = 'image/png',
|
IMAGE_PNG = "image/png",
|
||||||
JSON = 'application/json',
|
JSON = "application/json",
|
||||||
MULTIPART = 'multipart/form-data',
|
MULTIPART = "multipart/form-data",
|
||||||
OCTET_STREAM = 'application/octet-stream',
|
OCTET_STREAM = "application/octet-stream",
|
||||||
TEXT_PLAIN = 'text/plain',
|
TEXT_PLAIN = "text/plain",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTConfig {
|
export interface RESTConfig {
|
||||||
// base of the server: http(s)://my.server.org/plop/api/
|
// base of the server: http(s)://my.server.org/plop/api/
|
||||||
server: string;
|
server: string;
|
||||||
// Token to access of the data.
|
// Token to access of the data.
|
||||||
token?: string;
|
token?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTModel {
|
export interface RESTModel {
|
||||||
// base of the local API request: "sheep/{id}".
|
// base of the local API request: "sheep/{id}".
|
||||||
endPoint: string;
|
endPoint: string;
|
||||||
// Type of the request.
|
// Type of the request.
|
||||||
requestType?: HTTPRequestModel;
|
requestType?: HTTPRequestModel;
|
||||||
// Input type requested.
|
// Input type requested.
|
||||||
accept?: HTTPMimeType;
|
accept?: HTTPMimeType;
|
||||||
// Content of the local data.
|
// Content of the local data.
|
||||||
contentType?: HTTPMimeType;
|
contentType?: HTTPMimeType;
|
||||||
// Mode of the TOKEN in urk or Header
|
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||||
tokenInUrl?: boolean;
|
tokenInUrl?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelResponseHttp {
|
export interface ModelResponseHttp {
|
||||||
status: number;
|
status: number;
|
||||||
data: any;
|
data: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArrayOf<TYPE>(
|
function isNullOrUndefined(data: any): data is undefined | null {
|
||||||
data: any,
|
return data === undefined || data === null;
|
||||||
typeChecker: (subData: any) => subData is TYPE,
|
|
||||||
length?: number
|
|
||||||
): data is TYPE[] {
|
|
||||||
if (!Array.isArray(data)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!data.every(typeChecker)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (length !== undefined && data.length != length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RESTRequestType = {
|
// generic progression callback
|
||||||
restModel: RESTModel,
|
export type ProgressCallback = (count: number, total: number) => void;
|
||||||
restConfig: RESTConfig,
|
|
||||||
data?: any,
|
export interface RESTAbort {
|
||||||
params?: object,
|
abort?: () => boolean;
|
||||||
queries?: object,
|
}
|
||||||
};
|
|
||||||
|
// Rest generic callback have a basic model to upload and download advancement.
|
||||||
|
export interface RESTCallbacks {
|
||||||
|
progressUpload?: ProgressCallback;
|
||||||
|
progressDownload?: ProgressCallback;
|
||||||
|
abortHandle?: RESTAbort;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RESTRequestType {
|
||||||
|
restModel: RESTModel;
|
||||||
|
restConfig: RESTConfig;
|
||||||
|
data?: any;
|
||||||
|
params?: object;
|
||||||
|
queries?: object;
|
||||||
|
callbacks?: RESTCallbacks;
|
||||||
|
}
|
||||||
|
|
||||||
|
function replaceAll(input, searchValue, replaceValue) {
|
||||||
|
return input.split(searchValue).join(replaceValue);
|
||||||
|
}
|
||||||
|
|
||||||
function removeTrailingSlashes(input: string): string {
|
function removeTrailingSlashes(input: string): string {
|
||||||
return input.replace(/\/+$/, '');
|
if (isNullOrUndefined(input)) {
|
||||||
|
return "undefined";
|
||||||
|
}
|
||||||
|
return input.replace(/\/+$/, "");
|
||||||
}
|
}
|
||||||
function removeLeadingSlashes(input: string): string {
|
function removeLeadingSlashes(input: string): string {
|
||||||
return input.replace(/^\/+/, '');
|
if (isNullOrUndefined(input)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return input.replace(/^\/+/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RESTUrl({ restModel, restConfig, data, params, queries }: RESTRequestType): string {
|
export function RESTUrl({
|
||||||
// Create the URL PATH:
|
restModel,
|
||||||
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
restConfig,
|
||||||
if (params !== undefined) {
|
params,
|
||||||
for (let key of Object.keys(params)) {
|
queries,
|
||||||
generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
|
}: RESTRequestType): string {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = `${removeTrailingSlashes(
|
||||||
|
restConfig.server
|
||||||
|
)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||||
|
if (params !== undefined) {
|
||||||
|
for (let key of Object.keys(params)) {
|
||||||
|
generateUrl = replaceAll(generateUrl, `{${key}}`, `${params[key]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
queries === undefined &&
|
||||||
|
(restConfig.token === undefined || restModel.tokenInUrl !== true)
|
||||||
|
) {
|
||||||
|
return generateUrl;
|
||||||
|
}
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
if (queries !== undefined) {
|
||||||
|
for (let key of Object.keys(queries)) {
|
||||||
|
const value = queries[key];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
for (const element of value) {
|
||||||
|
searchParams.append(`${key}`, `${element}`);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
searchParams.append(`${key}`, `${value}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
}
|
||||||
return generateUrl;
|
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||||
}
|
searchParams.append("Authorization", `Bearer ${restConfig.token}`);
|
||||||
const searchParams = new URLSearchParams();
|
}
|
||||||
if (queries !== undefined) {
|
return generateUrl + "?" + searchParams.toString();
|
||||||
for (let key of Object.keys(queries)) {
|
|
||||||
const value = queries[key];
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
for (let iii = 0; iii < value.length; iii++) {
|
|
||||||
searchParams.append(`${key}`, `${value[iii]}`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
searchParams.append(`${key}`, `${value}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
|
||||||
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
|
|
||||||
}
|
|
||||||
return generateUrl + "?" + searchParams.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RESTRequest({ restModel, restConfig, data, params, queries }: RESTRequestType): Promise<ModelResponseHttp> {
|
export function fetchProgress(
|
||||||
// Create the URL PATH:
|
generateUrl: string,
|
||||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
{
|
||||||
let headers: any = {};
|
method,
|
||||||
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
headers,
|
||||||
headers['Authorization'] = `Bearer ${restConfig.token}`;
|
body,
|
||||||
}
|
}: {
|
||||||
if (restModel.accept !== undefined) {
|
method: HTTPRequestModel;
|
||||||
headers['Accept'] = restModel.accept;
|
headers: any;
|
||||||
}
|
body: any;
|
||||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
},
|
||||||
// if Get we have not a content type, the body is empty
|
{ progressUpload, progressDownload, abortHandle }: RESTCallbacks
|
||||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
): Promise<Response> {
|
||||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
const xhr: {
|
||||||
headers['Content-Type'] = restModel.contentType;
|
io?: XMLHttpRequest;
|
||||||
|
} = {
|
||||||
|
io: new XMLHttpRequest(),
|
||||||
|
};
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// Stream the upload progress
|
||||||
|
if (progressUpload) {
|
||||||
|
xhr.io?.upload.addEventListener("progress", (dataEvent) => {
|
||||||
|
if (dataEvent.lengthComputable) {
|
||||||
|
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
let body = data;
|
// Stream the download progress
|
||||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
if (progressDownload) {
|
||||||
body = JSON.stringify(data);
|
xhr.io?.addEventListener("progress", (dataEvent) => {
|
||||||
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
if (dataEvent.lengthComputable) {
|
||||||
const formData = new FormData();
|
progressDownload(dataEvent.loaded, dataEvent.total);
|
||||||
for (const name in data) {
|
|
||||||
formData.append(name, data[name]);
|
|
||||||
}
|
}
|
||||||
body = formData
|
});
|
||||||
}
|
}
|
||||||
console.log(`Call ${generateUrl}`)
|
if (abortHandle) {
|
||||||
return new Promise((resolve, reject) => {
|
abortHandle.abort = () => {
|
||||||
fetch(generateUrl, {
|
if (xhr.io) {
|
||||||
method: restModel.requestType,
|
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||||
headers,
|
xhr.io.abort();
|
||||||
body,
|
return true;
|
||||||
}).then((response: Response) => {
|
}
|
||||||
if (response.status >= 200 && response.status <= 299) {
|
console.log(
|
||||||
const contentType = response.headers.get('Content-Type');
|
`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`
|
||||||
if (restModel.accept !== contentType) {
|
);
|
||||||
reject({
|
return false;
|
||||||
time: Date().toString(),
|
};
|
||||||
status: 901,
|
}
|
||||||
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
|
// Check if we have an internal Fail:
|
||||||
statusMessage: "Fetch error",
|
xhr.io?.addEventListener("error", () => {
|
||||||
message: "rest-tools.ts Wrong type in the message return type"
|
xhr.io = undefined;
|
||||||
} as RestErrorResponse);
|
reject(new TypeError("Failed to fetch"));
|
||||||
} else if (contentType === HTTPMimeType.JSON) {
|
});
|
||||||
response
|
|
||||||
.json()
|
// Capture the end of the stream
|
||||||
.then((value: any) => {
|
xhr.io?.addEventListener("loadend", () => {
|
||||||
//console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
|
if (xhr.io?.readyState !== XMLHttpRequest.DONE) {
|
||||||
resolve({ status: response.status, data: value });
|
return;
|
||||||
})
|
}
|
||||||
.catch((reason: any) => {
|
if (xhr.io?.status === 0) {
|
||||||
reject({
|
//the stream has been aborted
|
||||||
time: Date().toString(),
|
reject(new TypeError("Fetch has been aborted"));
|
||||||
status: 902,
|
return;
|
||||||
error: `REST parse json fail: ${reason}`,
|
}
|
||||||
statusMessage: "Fetch parse error",
|
// Stream is ended, transform in a generic response:
|
||||||
message: "rest-tools.ts Wrong message model to parse"
|
const response = new Response(xhr.io.response, {
|
||||||
} as RestErrorResponse);
|
status: xhr.io.status,
|
||||||
});
|
statusText: xhr.io.statusText,
|
||||||
} else {
|
});
|
||||||
resolve({ status: response.status, data: response.body });
|
const headersArray = replaceAll(
|
||||||
}
|
xhr.io.getAllResponseHeaders().trim(),
|
||||||
} else {
|
"\r\n",
|
||||||
|
"\n"
|
||||||
|
).split("\n");
|
||||||
|
headersArray.forEach(function (header) {
|
||||||
|
const firstColonIndex = header.indexOf(":");
|
||||||
|
if (firstColonIndex !== -1) {
|
||||||
|
const key = header.substring(0, firstColonIndex).trim();
|
||||||
|
const value = header.substring(firstColonIndex + 1).trim();
|
||||||
|
response.headers.set(key, value);
|
||||||
|
} else {
|
||||||
|
response.headers.set(header, "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
xhr.io = undefined;
|
||||||
|
resolve(response);
|
||||||
|
});
|
||||||
|
xhr.io?.open(method, generateUrl, true);
|
||||||
|
if (!isNullOrUndefined(headers)) {
|
||||||
|
for (const [key, value] of Object.entries(headers)) {
|
||||||
|
xhr.io?.setRequestHeader(key, value as string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xhr.io?.send(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function RESTRequest({
|
||||||
|
restModel,
|
||||||
|
restConfig,
|
||||||
|
data,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
callbacks,
|
||||||
|
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||||
|
let headers: any = {};
|
||||||
|
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
||||||
|
headers["Authorization"] = `Bearer ${restConfig.token}`;
|
||||||
|
}
|
||||||
|
if (restModel.accept !== undefined) {
|
||||||
|
headers["Accept"] = restModel.accept;
|
||||||
|
}
|
||||||
|
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||||
|
// if Get we have not a content type, the body is empty
|
||||||
|
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||||
|
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||||
|
headers["Content-Type"] = restModel.contentType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let body = data;
|
||||||
|
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||||
|
body = JSON.stringify(data);
|
||||||
|
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||||
|
const formData = new FormData();
|
||||||
|
for (const name in data) {
|
||||||
|
formData.append(name, data[name]);
|
||||||
|
}
|
||||||
|
body = formData;
|
||||||
|
}
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let action: undefined | Promise<Response> = undefined;
|
||||||
|
if (
|
||||||
|
isNullOrUndefined(callbacks) ||
|
||||||
|
(isNullOrUndefined(callbacks.progressDownload) &&
|
||||||
|
isNullOrUndefined(callbacks.progressUpload) &&
|
||||||
|
isNullOrUndefined(callbacks.abortHandle))
|
||||||
|
) {
|
||||||
|
// No information needed: call the generic fetch interface
|
||||||
|
action = fetch(generateUrl, {
|
||||||
|
method: restModel.requestType,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
|
||||||
|
action = fetchProgress(
|
||||||
|
generateUrl,
|
||||||
|
{
|
||||||
|
method: restModel.requestType ?? HTTPRequestModel.GET,
|
||||||
|
headers,
|
||||||
|
body,
|
||||||
|
},
|
||||||
|
callbacks
|
||||||
|
);
|
||||||
|
}
|
||||||
|
action
|
||||||
|
.then((response: Response) => {
|
||||||
|
if (response.status >= 200 && response.status <= 299) {
|
||||||
|
const contentType = response.headers.get("Content-Type");
|
||||||
|
if (
|
||||||
|
!isNullOrUndefined(restModel.accept) &&
|
||||||
|
restModel.accept !== contentType
|
||||||
|
) {
|
||||||
|
reject({
|
||||||
|
name: "Model accept type incompatible",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 901,
|
||||||
|
message: `REST Content type are not compatible: ${restModel.accept} != ${contentType}`,
|
||||||
|
statusMessage: "Fetch error",
|
||||||
|
error: "rest-tools.ts Wrong type in the message return type",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
} else if (contentType === HTTPMimeType.JSON) {
|
||||||
|
response
|
||||||
|
.json()
|
||||||
|
.then((value: any) => {
|
||||||
|
resolve({ status: response.status, data: value });
|
||||||
|
})
|
||||||
|
.catch((reason: Error) => {
|
||||||
reject({
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 902,
|
||||||
|
message: `REST parse json fail: ${reason}`,
|
||||||
|
statusMessage: "Fetch parse error",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve({ status: response.status, data: response.body });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// the answer is not correct not a 2XX
|
||||||
|
// clone the response to keep the raw data if case of error:
|
||||||
|
response
|
||||||
|
.clone()
|
||||||
|
.json()
|
||||||
|
.then((value: any) => {
|
||||||
|
if (isRestErrorResponse(value)) {
|
||||||
|
reject(value);
|
||||||
|
} else {
|
||||||
|
response
|
||||||
|
.text()
|
||||||
|
.then((dataError: string) => {
|
||||||
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 903,
|
||||||
|
message: `REST parse error json with wrong type fail. ${dataError}`,
|
||||||
|
statusMessage: "Fetch parse error",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
})
|
||||||
|
.catch((reason: any) => {
|
||||||
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: response.status,
|
||||||
|
message: `unmanaged error model: ??? with error: ${reason}`,
|
||||||
|
statusMessage: "Fetch ERROR parse error",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((reason: Error) => {
|
||||||
|
response
|
||||||
|
.text()
|
||||||
|
.then((dataError: string) => {
|
||||||
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
time: Date().toString(),
|
time: Date().toString(),
|
||||||
status: response.status,
|
status: response.status,
|
||||||
error: `${response.body}`,
|
message: `unmanaged error model: ${dataError} with error: ${reason}`,
|
||||||
statusMessage: "Fetch code error",
|
statusMessage: "Fetch ERROR TEXT parse error",
|
||||||
message: "rest-tools.ts Wrong return code"
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
} as RestErrorResponse);
|
} as RestErrorResponse);
|
||||||
}
|
})
|
||||||
}).catch((error: any) => {
|
.catch((reason: any) => {
|
||||||
reject({
|
reject({
|
||||||
time: Date(),
|
name: "API serialization error",
|
||||||
status: 999,
|
time: Date().toString(),
|
||||||
error: error,
|
status: response.status,
|
||||||
statusMessage: "Fetch catch error",
|
message: `unmanaged error model: ??? with error: ${reason}`,
|
||||||
message: "http-wrapper.ts detect an error in the fetch request"
|
statusMessage: "Fetch ERROR TEXT FAIL",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
})
|
||||||
|
.catch((error: Error) => {
|
||||||
|
if (isRestErrorResponse(error)) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
name: "Request fail",
|
||||||
|
time: Date(),
|
||||||
|
status: 999,
|
||||||
|
message: error,
|
||||||
|
statusMessage: "Fetch catch error",
|
||||||
|
error: "rest-tools.ts detect an error in the fetch request",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
export function RESTRequestJson<TYPE>(
|
||||||
return new Promise((resolve, reject) => {
|
request: RESTRequestType,
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
checker?: (data: any) => data is TYPE
|
||||||
if (checker(value.data)) {
|
): Promise<TYPE> {
|
||||||
resolve(value.data);
|
return new Promise((resolve, reject) => {
|
||||||
} else {
|
RESTRequest(request)
|
||||||
reject({
|
.then((value: ModelResponseHttp) => {
|
||||||
time: Date().toString(),
|
if (isNullOrUndefined(checker)) {
|
||||||
status: 950,
|
console.log(`Have no check of MODEL in API: ${RESTUrl(request)}`);
|
||||||
error: "REST Fail to verify the data",
|
resolve(value.data);
|
||||||
statusMessage: "API cast ERROR",
|
} else if (checker === undefined || checker(value.data)) {
|
||||||
message: "api.ts Check type as fail"
|
resolve(value.data);
|
||||||
} as RestErrorResponse);
|
} else {
|
||||||
}
|
reject({
|
||||||
}).catch((reason: RestErrorResponse) => {
|
name: "Model check fail",
|
||||||
reject(reason);
|
time: Date().toString(),
|
||||||
});
|
status: 950,
|
||||||
});
|
error: "REST Fail to verify the data",
|
||||||
}
|
statusMessage: "API cast ERROR",
|
||||||
export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
message: "api.ts Check type as fail",
|
||||||
return new Promise((resolve, reject) => {
|
} as RestErrorResponse);
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
}
|
||||||
if (isArrayOf(value.data, checker)) {
|
})
|
||||||
resolve(value.data);
|
.catch((reason: RestErrorResponse) => {
|
||||||
} else {
|
reject(reason);
|
||||||
reject({
|
});
|
||||||
time: Date().toString(),
|
});
|
||||||
status: 950,
|
|
||||||
error: "REST Fail to verify the data",
|
|
||||||
statusMessage: "API cast ERROR",
|
|
||||||
message: "api.ts Check type as fail"
|
|
||||||
} as RestErrorResponse);
|
|
||||||
}
|
|
||||||
}).catch((reason: RestErrorResponse) => {
|
|
||||||
reject(reason);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
RESTRequest(request)
|
||||||
resolve();
|
.then((value: ModelResponseHttp) => {
|
||||||
}).catch((reason: RestErrorResponse) => {
|
resolve();
|
||||||
reject(reason);
|
})
|
||||||
});
|
.catch((reason: RestErrorResponse) => {
|
||||||
});
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
/**
|
|
||||||
* API of the server (auto-generated code)
|
|
||||||
*/
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, ModelResponseHttp, RESTConfig, RESTRequestJson, RESTRequestJsonArray, RESTRequestVoid } from "./rest-tools"
|
|
||||||
import {UserOut, Long, UserKarusic, isUserOut, isUserKarusic, } from "./model"
|
|
||||||
export namespace UserResource {
|
|
||||||
|
|
||||||
export function get({ restConfig, params, produce, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
produce: HTTPMimeType.JSON,
|
|
||||||
}): Promise<UserKarusic> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: produce,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isUserKarusic);
|
|
||||||
};
|
|
||||||
export function gets({ restConfig, produce, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
produce: HTTPMimeType.JSON,
|
|
||||||
}): Promise<UserKarusic[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: produce,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isUserKarusic);
|
|
||||||
};
|
|
||||||
export function getMe({ restConfig, produce, }: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
produce: HTTPMimeType.JSON,
|
|
||||||
}): Promise<UserOut> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/me",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: produce,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isUserOut);
|
|
||||||
};
|
|
||||||
}
|
|
@ -7,11 +7,11 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'description-area',
|
selector: 'AppDescriptionArea',
|
||||||
templateUrl: './description-area.html',
|
templateUrl: './AppDescriptionArea.html',
|
||||||
styleUrls: ['./description-area.less']
|
styleUrls: ['./AppDescriptionArea.less']
|
||||||
})
|
})
|
||||||
export class DescriptionAreaComponent {
|
export class AppDescriptionArea {
|
||||||
@Input() title: string;
|
@Input() title: string;
|
||||||
@Input() name?: string;
|
@Input() name?: string;
|
||||||
@Input() description?: string;
|
@Input() description?: string;
|
@ -5,19 +5,19 @@
|
|||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { NodeSmall } from 'app/back-api';
|
import { Album } from 'app/back-api';
|
||||||
|
|
||||||
import { AlbumService, DataService } from 'app/service';
|
import { AlbumService, DataService } from 'app/service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-season',
|
selector: 'AppElementAlbum',
|
||||||
templateUrl: './element-season.html',
|
templateUrl: './AppElementAlbum.html',
|
||||||
styleUrls: ['./element-season.less']
|
styleUrls: ['./AppElementAlbum.less']
|
||||||
})
|
})
|
||||||
export class ElementSeasonComponent implements OnInit {
|
export class AppElementAlbum implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element: NodeSmall;
|
@Input() element: Album;
|
||||||
@Input() prefix: String;
|
@Input() prefix: String;
|
||||||
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
||||||
@Input() countSubType: String;
|
@Input() countSubType: String;
|
@ -6,18 +6,23 @@
|
|||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
|
|
||||||
import { DataService } from 'app/service';
|
import { DataService } from 'app/service';
|
||||||
import { NodeSmall } from 'app/back-api';
|
|
||||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
|
export interface HomeInterface {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
covers?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-type',
|
selector: 'AppElementHomeType',
|
||||||
templateUrl: './element-type.html',
|
templateUrl: './AppElementHomeType.html',
|
||||||
styleUrls: ['./element-type.less']
|
styleUrls: ['./AppElementHomeType.less']
|
||||||
})
|
})
|
||||||
export class ElementTypeComponent implements OnInit {
|
export class ElementTypeComponent implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element: NodeSmall;
|
@Input() element: HomeInterface;
|
||||||
@Input() functionVignette: (number) => Promise<Number>;
|
@Input() functionVignette: (number) => Promise<Number>;
|
||||||
|
|
||||||
public name: string = 'rr';
|
public name: string = 'rr';
|
@ -5,18 +5,18 @@
|
|||||||
*/
|
*/
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
import { NodeSmall } from 'app/back-api';
|
import { Track } from 'app/back-api';
|
||||||
|
|
||||||
import { DataService } from 'app/service';
|
import { DataService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-track',
|
selector: 'AppElementTrack',
|
||||||
templateUrl: './element-track.html',
|
templateUrl: './AppElementTrack.html',
|
||||||
styleUrls: ['./element-track.less']
|
styleUrls: ['./AppElementTrack.less']
|
||||||
})
|
})
|
||||||
export class ElementTrackComponent implements OnInit {
|
export class AppElementTrack implements OnInit {
|
||||||
// input parameters
|
// input parameters
|
||||||
@Input() element: NodeSmall;
|
@Input() element: Track;
|
||||||
@Input() prefix: String;
|
@Input() prefix: String;
|
||||||
|
|
||||||
prefixName: string = "";
|
prefixName: string = "";
|
@ -21,9 +21,9 @@ export enum PlayMode {
|
|||||||
|
|
||||||
// note: all the input is managed with the player service ...
|
// note: all the input is managed with the player service ...
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-element-player-audio',
|
selector: 'AppPlayerAudio',
|
||||||
templateUrl: './element-player-audio.html',
|
templateUrl: './AppPlayerAudio.html',
|
||||||
styleUrls: ['./element-player-audio.less']
|
styleUrls: ['./AppPlayerAudio.less']
|
||||||
})
|
})
|
||||||
export class ElementPlayerAudioComponent implements OnInit {
|
export class ElementPlayerAudioComponent implements OnInit {
|
||||||
mediaPlayer: HTMLAudioElement;
|
mediaPlayer: HTMLAudioElement;
|
||||||
@ -328,17 +328,17 @@ export class ElementPlayerAudioComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// these element is to permit to not stop music when sceen is off !!
|
// these element is to permit to not stop music when screen is off !!
|
||||||
wakeLock = null;
|
wakeLock = null;
|
||||||
unlockPlayerEnable() {
|
unlockPlayerEnable() {
|
||||||
let temporaryValue = this.wakeLock;
|
const temporaryValue = this.wakeLock;
|
||||||
this.wakeLock = null;
|
this.wakeLock = null;
|
||||||
if (!isNullOrUndefined(temporaryValue)) {
|
if (!isNullOrUndefined(temporaryValue)) {
|
||||||
console.log(`plopppp ${temporaryValue}`);
|
console.log(`plopppp ${temporaryValue}`);
|
||||||
temporaryValue.release();
|
temporaryValue.release();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let tmp = navigator as any;
|
const tmp = navigator as any;
|
||||||
this.wakeLock = tmp.wakeLock.request('screen');
|
this.wakeLock = tmp.wakeLock.request('screen');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// The Wake Lock request has failed - usually system related, such as battery.
|
// The Wake Lock request has failed - usually system related, such as battery.
|
@ -1,23 +0,0 @@
|
|||||||
<div>
|
|
||||||
<div class="count-base">
|
|
||||||
@if(countTrack) {
|
|
||||||
<div class="count">
|
|
||||||
{{countTrack}}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="imgContainer-small">
|
|
||||||
@if(covers && covers.length > 0) {
|
|
||||||
<div>
|
|
||||||
<!--<data-image id="{{cover}}"></data-image>-->
|
|
||||||
<img src="{{covers[0]}}"/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@else {
|
|
||||||
<div class="noImage"></div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
<div class="title-small">
|
|
||||||
{{name}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,63 +0,0 @@
|
|||||||
|
|
||||||
.count-base {
|
|
||||||
height: 0px;
|
|
||||||
width: 0px;
|
|
||||||
.count {
|
|
||||||
height: 30px;
|
|
||||||
width: 30px;
|
|
||||||
font-size: 17px;
|
|
||||||
line-height: 30px;
|
|
||||||
overflow:hidden;
|
|
||||||
position:relative;
|
|
||||||
z-index: 12;
|
|
||||||
left: 165px;
|
|
||||||
top: 2px;
|
|
||||||
text-align: center;
|
|
||||||
//padding: 5px 10px;
|
|
||||||
color: rgba(0, 0, 0, 1.0);
|
|
||||||
background: rgba(256, 256, 256, 0.3);
|
|
||||||
border: 1px solid;
|
|
||||||
border-color: rgba(256, 256, 256, 0.8);
|
|
||||||
border-radius: 15px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.imgContainer-small {
|
|
||||||
right: 2px;
|
|
||||||
top: 2px;
|
|
||||||
text-align: center;
|
|
||||||
width: 200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
height: 250px;
|
|
||||||
img {
|
|
||||||
//width: 100%;
|
|
||||||
max-height: 250px;
|
|
||||||
max-width: 200px;
|
|
||||||
}
|
|
||||||
.noImage {
|
|
||||||
height: 243px;
|
|
||||||
width: 193px;
|
|
||||||
border: solid 3px;
|
|
||||||
border-color: rgba(0, 0, 0, 0.7);
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-small {
|
|
||||||
height: 40px;
|
|
||||||
width: 200px;
|
|
||||||
font-size: 17px;
|
|
||||||
overflow:hidden;
|
|
||||||
display:inline-block;
|
|
||||||
text-align: center;
|
|
||||||
padding:auto;
|
|
||||||
background: rgba(256, 256, 256, 0.3);
|
|
||||||
border-radius: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description-small {
|
|
||||||
height: 30px;
|
|
||||||
font-size: 12px;
|
|
||||||
overflow:hidden;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
||||||
* @license PROPRIETARY (see license file)
|
|
||||||
*/
|
|
||||||
import { Component, OnInit, Input } from '@angular/core';
|
|
||||||
|
|
||||||
import { DataService, TrackService } from 'app/service';
|
|
||||||
import { NodeSmall } from 'app/back-api';
|
|
||||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-element-series',
|
|
||||||
templateUrl: './element-series.html',
|
|
||||||
styleUrls: ['./element-series.less']
|
|
||||||
})
|
|
||||||
export class ElementSeriesComponent implements OnInit {
|
|
||||||
// input parameters
|
|
||||||
@Input() element: NodeSmall;
|
|
||||||
|
|
||||||
name: string = 'plouf';
|
|
||||||
description: string = '';
|
|
||||||
countTrack: number = null;
|
|
||||||
|
|
||||||
covers: string[];
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private trackService: TrackService,
|
|
||||||
private dataService: DataService) {
|
|
||||||
|
|
||||||
}
|
|
||||||
ngOnInit() {
|
|
||||||
if (isNullOrUndefined(this.element)) {
|
|
||||||
this.name = '!!ERROR!!';
|
|
||||||
this.description = undefined;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.name = this.element.name;
|
|
||||||
this.description = this.element.description;
|
|
||||||
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
|
||||||
|
|
||||||
this.trackService.countTracksOfAnArtist(this.element.id)
|
|
||||||
.then((response) => {
|
|
||||||
this.countTrack = response;
|
|
||||||
}).catch((response) => {
|
|
||||||
this.countTrack = 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<div>
|
|
||||||
<div class="videoImgContainer">
|
|
||||||
@if(covers && covers.length > 0) {
|
|
||||||
<div>
|
|
||||||
<!--<data-image id="{{cover}}"></data-image>-->
|
|
||||||
<img src="{{covers[0]}}"/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@else {
|
|
||||||
<div class="noImage"></div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
@if(element) {
|
|
||||||
<div class="title-small">
|
|
||||||
{{episodeDisplay}} {{name}}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
@else {
|
|
||||||
<div class="title-small">
|
|
||||||
Error meda: {{element?.id}}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
.videoImgContainer {
|
|
||||||
text-align: center;
|
|
||||||
width: 200px;
|
|
||||||
margin: 0 auto;
|
|
||||||
height: 250px;
|
|
||||||
img {
|
|
||||||
//width: 100%;
|
|
||||||
max-height: 250px;
|
|
||||||
max-width: 200px;
|
|
||||||
}
|
|
||||||
.noImage {
|
|
||||||
height: 243px;
|
|
||||||
width: 193px;
|
|
||||||
border: solid 3px;
|
|
||||||
border-color: rgba(0, 0, 0, 0.7);
|
|
||||||
margin: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.title-small {
|
|
||||||
height: 40px;
|
|
||||||
width: 200px;
|
|
||||||
font-size: 17px;
|
|
||||||
overflow:hidden;
|
|
||||||
display:inline-block;
|
|
||||||
text-align: center;
|
|
||||||
padding:auto;
|
|
||||||
background: rgba(256, 256, 256, 0.3);
|
|
||||||
border-radius: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.description-small {
|
|
||||||
height: 30px;
|
|
||||||
font-size: 12px;
|
|
||||||
overflow:hidden;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/** @file
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
||||||
* @license PROPRIETARY (see license file)
|
|
||||||
*/
|
|
||||||
import { Injectable, Component, OnInit, Input } from '@angular/core';
|
|
||||||
import { Track } from 'app/back-api';
|
|
||||||
|
|
||||||
import { DataService } from 'app/service';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-element-video',
|
|
||||||
templateUrl: './element-video.html',
|
|
||||||
styleUrls: ['./element-video.less']
|
|
||||||
})
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ElementVideoComponent implements OnInit {
|
|
||||||
// input parameters
|
|
||||||
@Input() element: Track;
|
|
||||||
name: string = '';
|
|
||||||
description: string = '';
|
|
||||||
episodeDisplay: string = '';
|
|
||||||
|
|
||||||
cover: string = '';
|
|
||||||
covers: string[];
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private dataService: DataService) {
|
|
||||||
// nothing to do.
|
|
||||||
}
|
|
||||||
ngOnInit() {
|
|
||||||
this.name = this.element.name;
|
|
||||||
this.description = this.element.description;
|
|
||||||
this.covers = this.dataService.getListThumbnailUrl(this.element.covers);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,14 @@
|
|||||||
import { DescriptionAreaComponent } from "./description-area/description-area";
|
import { AppDescriptionArea } from "./AppDescriptionArea/AppDescriptionArea";
|
||||||
import { ElementPlayerAudioComponent } from "./element-player-audio/element-player-audio";
|
import { ElementPlayerAudioComponent } from "./AppPlayerAudio/AppPlayerAudio";
|
||||||
import { ElementSeasonComponent } from "./element-season/element-season";
|
import { AppElementAlbum } from "./AppElementAlbum/AppElementAlbum";
|
||||||
import { ElementSeriesComponent } from "./element-series/element-series";
|
import { AppElementTrack } from "./AppElementTrack/AppElementTrack";
|
||||||
import { ElementTrackComponent } from "./element-track/element-track";
|
|
||||||
import { ElementVideoComponent } from "./element-video/element-video";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ElementSeriesComponent,
|
AppDescriptionArea,
|
||||||
ElementVideoComponent,
|
AppElementAlbum,
|
||||||
ElementSeasonComponent,
|
|
||||||
ElementPlayerAudioComponent,
|
ElementPlayerAudioComponent,
|
||||||
ElementTrackComponent,
|
AppElementTrack,
|
||||||
DescriptionAreaComponent,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ export interface ElementList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-album-edit',
|
selector: 'SceneAlbumEdit',
|
||||||
templateUrl: './album-edit.html',
|
templateUrl: './SceneAlbumEdit.html',
|
||||||
styleUrls: ['./album-edit.less']
|
styleUrls: ['./SceneAlbumEdit.less']
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AlbumEditScene implements OnInit {
|
export class AlbumEditScene implements OnInit {
|
@ -1,6 +1,6 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
|
|
||||||
<description-area
|
<AppDescriptionArea
|
||||||
[title]="name"
|
[title]="name"
|
||||||
[name]="albumName"
|
[name]="albumName"
|
||||||
[description]="albumDescription"
|
[description]="albumDescription"
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
@for (data of tracks; track data.id;) {
|
@for (data of tracks; track data.id;) {
|
||||||
<app-element-track
|
<AppElementTrack
|
||||||
[element]="data"
|
[element]="data"
|
||||||
(click)="onSelectTrack($event, data.id)"
|
(click)="onSelectTrack($event, data.id)"
|
||||||
(auxclick)="onSelectTrack($event, data.id)"/>
|
(auxclick)="onSelectTrack($event, data.id)"/>
|
@ -11,8 +11,8 @@ import { arrayUnique } from '@kangaroo-and-rabbit/kar-cw';
|
|||||||
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, TrackService, PlayerService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-album',
|
selector: 'SceneAlbum',
|
||||||
templateUrl: './album.html',
|
templateUrl: './SceneAlbum.html',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AlbumScene implements OnInit {
|
export class AlbumScene implements OnInit {
|
@ -1,5 +1,5 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<description-area
|
<AppDescriptionArea
|
||||||
[title]="name"
|
[title]="name"
|
||||||
[description]="description"
|
[description]="description"
|
||||||
[cover1]="covers"
|
[cover1]="covers"
|
||||||
@ -14,7 +14,7 @@
|
|||||||
(click)="onSelectAlbum($event, data.id)"
|
(click)="onSelectAlbum($event, data.id)"
|
||||||
(auxclick)="onSelectAlbum($event, data.id)"
|
(auxclick)="onSelectAlbum($event, data.id)"
|
||||||
>
|
>
|
||||||
<app-element-season
|
<AppElementAlbum
|
||||||
[element]="data"
|
[element]="data"
|
||||||
countSubType="Track"
|
countSubType="Track"
|
||||||
[countSubTypeCallBack]="countTrack"
|
[countSubTypeCallBack]="countTrack"
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
@for (data of tracks; track data.id;) {
|
@for (data of tracks; track data.id;) {
|
||||||
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||||
<app-element-video
|
<AppElementTrack
|
||||||
[element]="data"/>
|
[element]="data"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
@ -11,8 +11,8 @@ import { Album, Artist, Track } from 'app/back-api';
|
|||||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-albums',
|
selector: 'SceneAlbums',
|
||||||
templateUrl: './albums.html'
|
templateUrl: './SceneAlbums.html'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class AlbumsScene implements OnInit {
|
export class AlbumsScene implements OnInit {
|
@ -1,5 +1,5 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<description-area
|
<AppDescriptionArea
|
||||||
[title]="name"
|
[title]="name"
|
||||||
[name]="albumName"
|
[name]="albumName"
|
||||||
[description]="albumDescription"
|
[description]="albumDescription"
|
||||||
@ -12,10 +12,10 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
@for (data of tracks; track data.id;) {
|
@for (data of tracks; track data.id;) {
|
||||||
<app-element-track
|
<AppElementTrack
|
||||||
[element]="data"
|
[element]="data"
|
||||||
(click)="onSelectTrack($event, data.id)"
|
(click)="onSelectTrack($event, data.id)"
|
||||||
(auxclick)="onSelectTrack($event, data.id)"></app-element-track>
|
(auxclick)="onSelectTrack($event, data.id)"></AppElementTrack>
|
||||||
} @empty {
|
} @empty {
|
||||||
Aucune piste accessible.
|
Aucune piste accessible.
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<description-area
|
<AppDescriptionArea
|
||||||
[title]="name"
|
[title]="name"
|
||||||
[description]="description"
|
[description]="description"
|
||||||
[cover1]="covers"
|
[cover1]="covers"
|
||||||
@ -11,11 +11,11 @@
|
|||||||
<div class="title">Album{{albums.length > 1?"s":""}}:</div>
|
<div class="title">Album{{albums.length > 1?"s":""}}:</div>
|
||||||
@for (data of albums; track data.id;) {
|
@for (data of albums; track data.id;) {
|
||||||
<div class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
|
<div class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
|
||||||
<app-element-season
|
<AppElementAlbum
|
||||||
[element]="data"
|
[element]="data"
|
||||||
countSubType="Track"
|
countSubType="Track"
|
||||||
[countSubTypeCallBack]="countTrack"
|
[countSubTypeCallBack]="countTrack"
|
||||||
></app-element-season>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@ -26,9 +26,9 @@
|
|||||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||||
@for (data of tracks; track data.id;) {
|
@for (data of tracks; track data.id;) {
|
||||||
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||||
<app-element-video
|
<AppElementTrack
|
||||||
[element]="data"
|
[element]="data"
|
||||||
></app-element-video>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div class="generic-page">
|
<div class="generic-page">
|
||||||
<description-area
|
<AppDescriptionArea
|
||||||
[title]="name"
|
[title]="name"
|
||||||
[description]="description"
|
[description]="description"
|
||||||
[cover1]="covers"
|
[cover1]="covers"
|
||||||
@ -11,13 +11,13 @@
|
|||||||
<div class="title">Artist{{artists.length > 1?"s":""}}: <app-entry placeholder="Search..." (changeValue)="onSearch($event)"></app-entry></div>
|
<div class="title">Artist{{artists.length > 1?"s":""}}: <app-entry placeholder="Search..." (changeValue)="onSearch($event)"></app-entry></div>
|
||||||
@for (data of artists; track data.id;) {
|
@for (data of artists; track data.id;) {
|
||||||
<div class="item-list" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
<div class="item-list" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
||||||
<app-element-season
|
<AppElementAlbum
|
||||||
[element]="data"
|
[element]="data"
|
||||||
countSubType="Album"
|
countSubType="Album"
|
||||||
[countSubTypeCallBack]="countAlbum"
|
[countSubTypeCallBack]="countAlbum"
|
||||||
countSubType2="Track"
|
countSubType2="Track"
|
||||||
[countSubType2CallBack]="countTrack"
|
[countSubType2CallBack]="countTrack"
|
||||||
></app-element-season>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
@for (data of tracks; track data.id;) {
|
@for (data of tracks; track data.id;) {
|
||||||
<div class="item item-track" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
<div class="item item-track" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||||
<app-element-track [element]="data"/>
|
<AppElementTrack [element]="data"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div class="fill-all colomn_mutiple">
|
<div class="fill-all colomn_mutiple">
|
||||||
@for (data of dataList; track data.id) {
|
@for (data of dataList; track data.id) {
|
||||||
<div class="item-home" (click)="onSelectType($event, data.id)" (auxclick)="onSelectType($event, data.id)">
|
<div class="item-home" (click)="onSelectType($event, data.id)" (auxclick)="onSelectType($event, data.id)">
|
||||||
<app-element-type [element]="data"/>
|
<AppElementHomeType [element]="data"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
@ -5,8 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HomeInterface } from 'app/component/AppElementHomeType/AppElementHomeType';
|
||||||
|
|
||||||
import { ArianeService, GenderService } from 'app/service';
|
import { ArianeService } from 'app/service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
@ -14,7 +15,7 @@ import { ArianeService, GenderService } from 'app/service';
|
|||||||
styleUrls: ['./home.less']
|
styleUrls: ['./home.less']
|
||||||
})
|
})
|
||||||
export class HomeScene implements OnInit {
|
export class HomeScene implements OnInit {
|
||||||
dataList = [
|
dataList: HomeInterface[] = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "Genders",
|
name: "Genders",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { GenderScene } from "./gender/gender";
|
import { GenderScene } from "./gender/gender";
|
||||||
import { HelpScene } from "./help/help";
|
import { HelpScene } from "./help/help";
|
||||||
import { HomeScene } from "./home/home";
|
import { HomeScene } from "./home/home";
|
||||||
import { AlbumEditScene } from "./album-edit/album-edit";
|
import { AlbumEditScene } from "./album-edit/SceneAlbumEdit";
|
||||||
import { AlbumScene } from "./album/album";
|
import { AlbumScene } from "./album/SceneAlbum";
|
||||||
import { AlbumsScene } from "./album/albums";
|
import { AlbumsScene } from "./album/SceneAlbums";
|
||||||
import { ArtistEditScene } from "./artist-edit/artist-edit";
|
import { ArtistEditScene } from "./artist-edit/artist-edit";
|
||||||
import { ArtistScene } from "./artist/artist";
|
import { ArtistScene } from "./artist/artist";
|
||||||
import { ArtistsScene } from "./artist/artists";
|
import { ArtistsScene } from "./artist/artists";
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div class="fill-all colomn_mutiple">
|
<div class="fill-all colomn_mutiple">
|
||||||
@for (data of tracks; track data.id) {
|
@for (data of tracks; track data.id) {
|
||||||
<div class="item item-track" (click)="onSelectTrack($event, data)" (auxclick)="onSelectTrack($event, data)">
|
<div class="item item-track" (click)="onSelectTrack($event, data)" (auxclick)="onSelectTrack($event, data)">
|
||||||
<app-element-track [element]="data"></app-element-track>
|
<AppElementTrack [element]="data"></AppElementTrack>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Album, AlbumResource, UUID } from 'app/back-api';
|
import { Album, AlbumResource, UUID } from 'app/back-api';
|
||||||
import { RESTConfig, isArrayOf } from 'app/back-api/rest-tools';
|
import { RESTConfig } from 'app/back-api/rest-tools';
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
import { GenericDataService } from './GenericDataService';
|
import { GenericDataService } from './GenericDataService';
|
||||||
import { DataTools, DataStore, SessionService, TypeCheck, isNumber } from '@kangaroo-and-rabbit/kar-cw';
|
import { DataTools, DataStore, SessionService, TypeCheck, isNumber, isArrayOf } from '@kangaroo-and-rabbit/kar-cw';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AlbumService extends GenericDataService<Album> {
|
export class AlbumService extends GenericDataService<Album> {
|
||||||
@ -110,7 +110,6 @@ export class AlbumService extends GenericDataService<Album> {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
file,
|
file,
|
||||||
fileName: file.name
|
|
||||||
}
|
}
|
||||||
}).then((value) => {
|
}).then((value) => {
|
||||||
self.dataStore.updateValue(value);
|
self.dataStore.updateValue(value);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user