[FEAT] many renaming
This commit is contained in:
parent
3b27edfa3b
commit
21d53b77f2
@ -5,7 +5,7 @@ version_file="../version.txt"
|
||||
# update new release dependency
|
||||
cd back
|
||||
# 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
|
||||
# update all versions release of dependency
|
||||
mvn versions:use-latest-releases
|
||||
@ -19,11 +19,14 @@ cd -
|
||||
|
||||
|
||||
cd front
|
||||
if grep -q "DEV" "$version_file"; then
|
||||
if grep -q "dev" "$version_file"; then
|
||||
# update all dependency
|
||||
pnpm install
|
||||
pnpm run update_packages
|
||||
else
|
||||
# in case of release ==> can not do it automatically ...
|
||||
echo not implemented
|
||||
fi
|
||||
|
||||
cd -
|
||||
|
||||
|
45
back/pom.xml
45
back/pom.xml
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.7.1</version>
|
||||
<version>0.13.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -49,6 +49,16 @@
|
||||
<version>5.10.1</version>
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
@ -186,23 +196,10 @@
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- 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>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.23.0</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<lineEnding>LF</lineEnding>
|
||||
@ -226,7 +223,23 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</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>
|
||||
</build>
|
||||
<!-- 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.UpdateJwtPublicKey;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
||||
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.catcher.GenericCatcher;
|
||||
import org.kar.archidata.filter.CORSFilter;
|
||||
import org.kar.archidata.filter.OptionFilter;
|
||||
import org.kar.archidata.migration.MigrationEngine;
|
||||
@ -92,11 +88,7 @@ public class WebLauncher {
|
||||
// global authentication system
|
||||
rc.register(KarusicAuthenticationFilter.class);
|
||||
// register exception catcher
|
||||
rc.register(JacksonCatcher.class);
|
||||
rc.register(InputExceptionCatcher.class);
|
||||
rc.register(SystemExceptionCatcher.class);
|
||||
rc.register(FailExceptionCatcher.class);
|
||||
rc.register(ExceptionCatcher.class);
|
||||
GenericCatcher.addAll(rc);
|
||||
// add default resource:
|
||||
rc.register(UserResource.class);
|
||||
rc.register(AlbumResource.class);
|
||||
|
@ -3,7 +3,8 @@ package org.kar.karusic;
|
||||
import java.util.List;
|
||||
|
||||
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.karusic.api.AlbumResource;
|
||||
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.TrackResource;
|
||||
import org.kar.karusic.api.UserResource;
|
||||
import org.kar.karusic.migration.Initialization;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -22,18 +22,19 @@ public class WebLauncherLocal extends WebLauncher {
|
||||
|
||||
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 {
|
||||
DataFactoryTsApi.generatePackage(List.of(
|
||||
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/");
|
||||
generateObjects();
|
||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||
launcher.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.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/album")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@ -62,7 +61,8 @@ public class AlbumResource {
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@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);
|
||||
return DataAccess.get(Album.class, id);
|
||||
}
|
||||
@ -89,7 +89,8 @@ public class AlbumResource {
|
||||
@Path("{id}/track/{trackId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Album.class, id);
|
||||
}
|
||||
@ -101,16 +102,19 @@ public class AlbumResource {
|
||||
@Operation(description = "Add a cover on a specific album")
|
||||
@AsyncType(Album.class)
|
||||
@TypeScriptProgress
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Album.class, id, fileName, fileInputStream, fileMetaData);
|
||||
public void uploadCover(
|
||||
@PathParam("id") final Long id,
|
||||
@FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Album.class, id, fileInputStream, fileMetaData);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Album.class, id);
|
||||
}
|
||||
|
@ -25,64 +25,67 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/artist")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public class ArtistResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ArtistResource.class);
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
public static Artist get(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Artist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
public List<Artist> gets() throws Exception {
|
||||
return DataAccess.gets(Artist.class);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Artist post(@AsyncType(Artist.class) final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Artist.class, jsonRequest);
|
||||
}
|
||||
|
||||
|
||||
@PATCH
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Artist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||
DataAccess.delete(Artist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@AsyncType(Artist.class)
|
||||
@TypeScriptProgress
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Artist.class, id, fileName, fileInputStream, fileMetaData);
|
||||
public void uploadCover(
|
||||
@PathParam("id") final Long id,
|
||||
@FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Artist.class, id, fileInputStream, fileMetaData);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@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");
|
||||
AddOnDataJson.removeLink(Artist.class, id, "covers", coverId);
|
||||
return DataAccess.get(Artist.class, id);
|
||||
|
@ -25,64 +25,67 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/gender")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public class GenderResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GenderResource.class);
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
public static Gender get(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Gender.class, id);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
public List<Gender> gets() throws Exception {
|
||||
return DataAccess.gets(Gender.class);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Gender post(@AsyncType(Gender.class) final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Gender.class, jsonRequest);
|
||||
}
|
||||
|
||||
|
||||
@PATCH
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Gender.class, id);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||
DataAccess.delete(Gender.class, id);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@AsyncType(Gender.class)
|
||||
@TypeScriptProgress
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Gender.class, id, fileName, fileInputStream, fileMetaData);
|
||||
public void uploadCover(
|
||||
@PathParam("id") final Long id,
|
||||
@FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Gender.class, id, fileInputStream, fileMetaData);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@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);
|
||||
return DataAccess.get(Gender.class, id);
|
||||
}
|
||||
|
@ -25,80 +25,85 @@ import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/playlist")
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public class PlaylistResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PlaylistResource.class);
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
@RolesAllowed("USER")
|
||||
public static Playlist get(@PathParam("id") final Long id) throws Exception {
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@RolesAllowed("USER")
|
||||
public List<Playlist> gets() throws Exception {
|
||||
return DataAccess.gets(Playlist.class);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Playlist post(@AsyncType(Playlist.class) final String jsonRequest) throws Exception {
|
||||
return DataAccess.insertWithJson(Playlist.class, jsonRequest);
|
||||
}
|
||||
|
||||
|
||||
@PATCH
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
public void remove(@PathParam("id") final Long id) throws Exception {
|
||||
DataAccess.delete(Playlist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("{id}/track/{trackId}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}/track/{trackId}")
|
||||
@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);
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("{id}/cover")
|
||||
@RolesAllowed("ADMIN")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@AsyncType(Playlist.class)
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Playlist.class, id, fileName, fileInputStream, fileMetaData);
|
||||
public void uploadCover(
|
||||
@PathParam("id") final Long id,
|
||||
@FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Playlist.class, id, fileInputStream, fileMetaData);
|
||||
}
|
||||
|
||||
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@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);
|
||||
return DataAccess.get(Playlist.class, id);
|
||||
}
|
||||
|
@ -66,7 +66,8 @@ public class TrackResource {
|
||||
@Path("{id}")
|
||||
@RolesAllowed("ADMIN")
|
||||
@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);
|
||||
return DataAccess.get(Track.class, id);
|
||||
}
|
||||
@ -90,7 +91,8 @@ public class TrackResource {
|
||||
@DELETE
|
||||
@Path("{id}/artist/{trackId}")
|
||||
@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);
|
||||
return DataAccess.get(Track.class, id);
|
||||
}
|
||||
@ -101,15 +103,18 @@ public class TrackResource {
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@AsyncType(Track.class)
|
||||
@TypeScriptProgress
|
||||
public Response uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) {
|
||||
return DataTools.uploadCover(Track.class, id, fileName, fileInputStream, fileMetaData);
|
||||
public void uploadCover(
|
||||
@PathParam("id") final Long id,
|
||||
@FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Track.class, id, fileInputStream, fileMetaData);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{id}/cover/{coverId}")
|
||||
@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);
|
||||
return DataAccess.get(Track.class, id);
|
||||
}
|
||||
@ -131,7 +136,7 @@ public class TrackResource {
|
||||
@FormDataParam("title") String title, //
|
||||
@FormDataParam("file") final InputStream fileInputStream, //
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
||||
) {
|
||||
) {
|
||||
// Formatter:on
|
||||
try {
|
||||
// correct input string stream :
|
||||
@ -180,7 +185,7 @@ public class TrackResource {
|
||||
}
|
||||
} else if (data.deleted) {
|
||||
LOGGER.info("Data already exist but deleted");
|
||||
DataTools.undelete(data.id);
|
||||
DataTools.undelete(data.uuid);
|
||||
data.deleted = false;
|
||||
} else {
|
||||
LOGGER.info("Data already exist ... all good");
|
||||
@ -234,7 +239,7 @@ public class TrackResource {
|
||||
trackElem.track = trackId != null ? Long.parseLong(trackId) : null;
|
||||
trackElem.albumId = albumElem != null ? albumElem.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:
|
||||
if (artistElem != null) {
|
||||
trackElem.artists = new ArrayList<>();
|
||||
|
@ -2,6 +2,7 @@ package org.kar.karusic.migration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.migration.MigrationSqlStep;
|
||||
import org.kar.archidata.model.Data;
|
||||
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.Playlist;
|
||||
import org.kar.karusic.model.Track;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
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 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
|
||||
public String getName() {
|
||||
return "Initialization";
|
||||
}
|
||||
|
||||
|
||||
public Initialization() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void generateStep() throws Exception {
|
||||
for (final Class<?> elem : CLASSES_BASE) {
|
||||
addClass(elem);
|
||||
}
|
||||
|
||||
|
||||
addAction("""
|
||||
INSERT INTO `gender` (`id`, `name`, `description`) VALUES
|
||||
(1, 'Variété française', NULL),
|
||||
@ -80,5 +85,26 @@ public class Initialization extends MigrationSqlStep {
|
||||
ALTER TABLE `user` AUTO_INCREMENT = 1000;
|
||||
""", "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.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.OverrideTableName;
|
||||
import org.kar.archidata.migration.MigrationSqlStep;
|
||||
@ -22,29 +22,30 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Migration20240226 extends MigrationSqlStep {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
||||
|
||||
|
||||
public static final int KARSO_INITIALISATION_ID = 1;
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "migration-2024-02-26: convert base with UUID";
|
||||
}
|
||||
|
||||
|
||||
public Migration20240226() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void generateStep() throws Exception {
|
||||
addAction("""
|
||||
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
||||
""");
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
for (final UUIDConversion elem: datas) {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||
new OverrideTableName("data"));
|
||||
for (final UUIDConversion elem : datas) {
|
||||
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"));
|
||||
}
|
||||
});
|
||||
@ -52,18 +53,21 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
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");
|
||||
for (final String tableName : tableToTransform ) {
|
||||
for (final String tableName : tableToTransform) {
|
||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
||||
final List<LinkTable> links = DataAccess.gets(LinkTable.class, new OverrideTableName(tableName + "_link_cover"));
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||
new OverrideTableName("data"));
|
||||
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());
|
||||
for (final CoverConversion media: medias) {
|
||||
for (final CoverConversion media : medias) {
|
||||
final List<UUID> values = new ArrayList<>();
|
||||
for (final LinkTable link: links) {
|
||||
for (final LinkTableLongLong link : links) {
|
||||
if (link.object1Id.equals(media.id)) {
|
||||
for (final UUIDConversion data: datas) {
|
||||
for (final UUIDConversion data : datas) {
|
||||
if (data.id.equals(link.object2Id)) {
|
||||
values.add(data.uuid);
|
||||
break;
|
||||
@ -85,10 +89,12 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
ALTER TABLE `track` ADD `dataUUID` binary(16) AFTER dataId;
|
||||
""");
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("track"));
|
||||
for (final MediaConversion media: medias) {
|
||||
for (final UUIDConversion data: datas) {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||
new OverrideTableName("data"));
|
||||
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(),
|
||||
new OverrideTableName("track"));
|
||||
for (final MediaConversion media : medias) {
|
||||
for (final UUIDConversion data : datas) {
|
||||
if (data.id.equals(media.dataId)) {
|
||||
media.dataUUID = data.uuid;
|
||||
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("track"));
|
||||
@ -97,7 +103,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
addAction("""
|
||||
DROP TABLE `playlist`;
|
||||
""");
|
||||
@ -112,8 +118,9 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
""");
|
||||
// Move the files...
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||
for (final UUIDConversion data: datas) {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||
new OverrideTableName("data"));
|
||||
for (final UUIDConversion data : datas) {
|
||||
final String origin = DataResource.getFileDataOld(data.id);
|
||||
final String destination = DataResource.getFileData(data.uuid);
|
||||
LOGGER.info("move file = {}", origin);
|
||||
@ -131,5 +138,5 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
ALTER TABLE `data` ADD PRIMARY KEY `id` (`id`);
|
||||
""");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,16 +1,32 @@
|
||||
package org.kar.karusic.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Table(name = "album")
|
||||
@DataIfNotExists
|
||||
@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;
|
||||
}
|
||||
|
@ -1,28 +1,44 @@
|
||||
package org.kar.karusic.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Table(name = "artist")
|
||||
@DataIfNotExists
|
||||
@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)
|
||||
public String firstName = null;
|
||||
@Column(length = 256)
|
||||
public String surname = null;
|
||||
public LocalDate birth = null;
|
||||
public LocalDate death = null;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Artist [id=" + this.id + ", name=" + this.name + ", description=" + this.description + ", covers=" + this.covers + ", firstName=" + this.firstName + ", surname=" + this.surname
|
||||
+ ", birth=" + this.birth + ", death=" + this.death + "]";
|
||||
return "Artist [id=" + this.id + ", name=" + this.name + ", description=" + this.description + ", covers="
|
||||
+ this.covers + ", firstName=" + this.firstName + ", surname=" + this.surname + ", birth=" + this.birth
|
||||
+ ", death=" + this.death + "]";
|
||||
}
|
||||
}
|
||||
|
@ -12,15 +12,32 @@ CREATE TABLE `node` (
|
||||
) AUTO_INCREMENT=10;
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Table(name = "gender")
|
||||
@DataIfNotExists
|
||||
@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.UUID;
|
||||
|
||||
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.Table;
|
||||
@ -25,7 +32,15 @@ import jakarta.persistence.Table;
|
||||
@Table(name = "playlist")
|
||||
@DataIfNotExists
|
||||
@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)
|
||||
public List<Long> tracks = null;
|
||||
}
|
||||
|
@ -17,16 +17,28 @@ import java.util.UUID;
|
||||
|
||||
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 io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@Table(name = "track")
|
||||
@DataIfNotExists
|
||||
@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 albumId = null;
|
||||
public Long track = null;
|
||||
@ -35,10 +47,12 @@ public class Track extends NodeSmall {
|
||||
@DataJson
|
||||
@Column(length = 0)
|
||||
public List<Long> artists = null;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Track [id=" + this.id + ", deleted=" + this.deleted + ", createdAt=" + this.createdAt + ", updatedAt=" + 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 + "]";
|
||||
return "Track [id=" + this.id + ", deleted=" + this.deleted + ", createdAt=" + this.createdAt + ", updatedAt="
|
||||
+ 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;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
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.extension.ExtendWith;
|
||||
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
||||
import org.kar.archidata.model.GetToken;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.archidata.tools.JWTWrapper;
|
||||
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.LoggerFactory;
|
||||
|
||||
import com.nimbusds.jwt.JWTClaimsSet;
|
||||
|
||||
@ExtendWith(StepwiseExtension.class)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class TestBase {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestBase.class);
|
||||
public final static String ENDPOINT_NAME = "species/";
|
||||
|
||||
static WebLauncherTest webInterface = null;
|
||||
static RESTApi api = null;
|
||||
|
||||
public void login(final String login, final String password) {
|
||||
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");
|
||||
}
|
||||
private static UUID idTest;
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
LOGGER.info("configure server ...");
|
||||
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");
|
||||
try {
|
||||
webInterface.migrateDB();
|
||||
@ -57,194 +50,18 @@ public class TestBase {
|
||||
webInterface.process();
|
||||
LOGGER.info("Start REST (DONE)");
|
||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
||||
api.setToken(Common.USER_TOKEN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@AfterAll
|
||||
public static void stopWebServer() throws InterruptedException {
|
||||
public static void stopWebServer() throws Exception {
|
||||
LOGGER.info("Kill the web server");
|
||||
webInterface.stop();
|
||||
webInterface = null;
|
||||
// TODO: do it better...
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,17 +12,23 @@ public class WebLauncherTest extends WebLauncher {
|
||||
public WebLauncherTest() {
|
||||
LOGGER.debug("Configure REST system");
|
||||
// for local test:
|
||||
ConfigBaseVariable.apiAdress = "http://127.0.0.1:12345/test/api/";
|
||||
|
||||
ConfigBaseVariable.dbPort = "3306";
|
||||
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.testMode = "true";
|
||||
// for the test we a in memory sqlite..
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
|
||||
ConfigBaseVariable.dbHost = "localhost";
|
||||
ConfigBaseVariable.dbUser = "root";
|
||||
ConfigBaseVariable.dbPassword = "ZERTYSDGFVHSDFGHJYZSDFGSQxfgsqdfgsqdrf4564654";
|
||||
if (true) {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
} 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,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.3.4",
|
||||
"@angular/cdk": "^17.3.4",
|
||||
"@angular/common": "^17.3.4",
|
||||
"@angular/compiler": "^17.3.4",
|
||||
"@angular/core": "^17.3.4",
|
||||
"@angular/forms": "^17.3.4",
|
||||
"@angular/material": "^17.3.4",
|
||||
"@angular/platform-browser": "^17.3.4",
|
||||
"@angular/platform-browser-dynamic": "^17.3.4",
|
||||
"@angular/router": "^17.3.4",
|
||||
"@angular/animations": "^18.1.4",
|
||||
"@angular/cdk": "^18.1.4",
|
||||
"@angular/common": "^18.1.4",
|
||||
"@angular/compiler": "^18.1.4",
|
||||
"@angular/core": "^18.1.4",
|
||||
"@angular/forms": "^18.1.4",
|
||||
"@angular/material": "^18.1.4",
|
||||
"@angular/platform-browser": "^18.1.4",
|
||||
"@angular/platform-browser-dynamic": "^18.1.4",
|
||||
"@angular/router": "^18.1.4",
|
||||
"rxjs": "^7.8.1",
|
||||
"zone.js": "^0.14.4",
|
||||
"zod": "3.22.4",
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.2.0"
|
||||
"zone.js": "^0.14.10",
|
||||
"zod": "^3.23.8",
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^17.3.4",
|
||||
"@angular-eslint/builder": "17.3.0",
|
||||
"@angular-eslint/eslint-plugin": "17.3.0",
|
||||
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
||||
"@angular-eslint/schematics": "17.3.0",
|
||||
"@angular-eslint/template-parser": "17.3.0",
|
||||
"@angular/cli": "^17.3.4",
|
||||
"@angular/compiler-cli": "^17.3.4",
|
||||
"@angular/language-service": "^17.3.4",
|
||||
"npm-check-updates": "^16.14.18",
|
||||
"tslib": "^2.6.2"
|
||||
"@angular-devkit/build-angular": "^18.1.4",
|
||||
"@angular-eslint/builder": "18.3.0",
|
||||
"@angular-eslint/eslint-plugin": "18.3.0",
|
||||
"@angular-eslint/eslint-plugin-template": "18.3.0",
|
||||
"@angular-eslint/schematics": "18.3.0",
|
||||
"@angular-eslint/template-parser": "18.3.0",
|
||||
"@angular/cli": "^18.1.4",
|
||||
"@angular/compiler-cli": "^18.1.4",
|
||||
"@angular/language-service": "^18.1.4",
|
||||
"npm-check-updates": "^17.0.6",
|
||||
"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>
|
||||
<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 { 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';
|
||||
|
||||
@ -22,7 +22,12 @@ import {
|
||||
} from './scene';
|
||||
import { GenderService, DataService, PlaylistService, ArtistService, AlbumService, TrackService, ArianeService, PlayerService } from './service';
|
||||
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 { environment } from 'environments/environment';
|
||||
|
||||
@ -35,12 +40,10 @@ import { CommonModule } from "@angular/common";
|
||||
AppComponent,
|
||||
ElementDataImageComponent,
|
||||
ElementTypeComponent,
|
||||
ElementSeriesComponent,
|
||||
ElementTrackComponent,
|
||||
ElementSeasonComponent,
|
||||
ElementVideoComponent,
|
||||
AppElementTrack,
|
||||
AppElementAlbum,
|
||||
ElementPlayerAudioComponent,
|
||||
DescriptionAreaComponent,
|
||||
AppDescriptionArea,
|
||||
PopInCreateType,
|
||||
HomeScene,
|
||||
HelpScene,
|
||||
@ -83,9 +86,8 @@ import { CommonModule } from "@angular/common";
|
||||
exports: [
|
||||
AppComponent,
|
||||
ElementTypeComponent,
|
||||
ElementSeriesComponent,
|
||||
ElementSeasonComponent,
|
||||
ElementVideoComponent,
|
||||
AppElementAlbum,
|
||||
AppElementTrack,
|
||||
PopInCreateType,
|
||||
],
|
||||
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 {UUID, Long, Album, isAlbum, } from "./model"
|
||||
import {
|
||||
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 {
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export function addTrack({ restConfig, params, }: {
|
||||
export function addTrack({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
trackId: Long,
|
||||
@ -120,10 +46,159 @@ export namespace AlbumResource {
|
||||
params,
|
||||
}, 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
|
||||
*/
|
||||
export function removeTrack({ restConfig, params, }: {
|
||||
export function removeTrack({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
trackId: Long,
|
||||
@ -144,15 +219,20 @@ export namespace AlbumResource {
|
||||
/**
|
||||
* Add a cover on a specific album
|
||||
*/
|
||||
export function uploadCover({ restConfig, params, data, }: {
|
||||
export function uploadCover({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
}): Promise<Album> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -164,27 +244,7 @@ export namespace AlbumResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isAlbum);
|
||||
};
|
||||
/**
|
||||
* 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,
|
||||
callbacks,
|
||||
}, 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 {Artist, UUID, Long, isArtist, } from "./model"
|
||||
import {
|
||||
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 function remove({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/artist/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
export function get({
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
};
|
||||
export function get({ restConfig, params, }: {
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
@ -38,12 +41,44 @@ export namespace ArtistResource {
|
||||
params,
|
||||
}, 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,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Artist,
|
||||
data: ArtistWrite,
|
||||
}): Promise<Artist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -57,13 +92,16 @@ export namespace ArtistResource {
|
||||
data,
|
||||
}, isArtist);
|
||||
};
|
||||
export function post({ restConfig, data, }: {
|
||||
export function post({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Artist,
|
||||
data: ArtistWrite,
|
||||
}): Promise<Artist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/artist",
|
||||
endPoint: "/artist/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
@ -72,41 +110,29 @@ export namespace ArtistResource {
|
||||
data,
|
||||
}, isArtist);
|
||||
};
|
||||
export function gets({ restConfig, }: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Artist[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/artist",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
export function remove({
|
||||
restConfig,
|
||||
}, isArtist);
|
||||
};
|
||||
export function uploadCover({ restConfig, params, data, }: {
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
}): Promise<Artist> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/artist/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
endPoint: "/artist/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isArtist);
|
||||
});
|
||||
};
|
||||
export function removeCover({ restConfig, params, }: {
|
||||
export function removeCover({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
coverId: UUID,
|
||||
@ -124,4 +150,32 @@ export namespace ArtistResource {
|
||||
params,
|
||||
}, 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 {UUID, } from "./model"
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import {
|
||||
UUID,
|
||||
} from "../model";
|
||||
|
||||
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,
|
||||
data: {
|
||||
file: File,
|
||||
queries: {
|
||||
Authorization?: string,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
params: {
|
||||
name: string,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data//upload/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
endPoint: "/data/{uuid}/{name}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
data,
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Get back some data from the data environment
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataId({ restConfig, queries, params, data, }: {
|
||||
export function retrieveDataId({
|
||||
restConfig,
|
||||
queries,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
Authorization: string,
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
id: UUID,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/{id}",
|
||||
endPoint: "/data/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
@ -53,20 +77,24 @@ export namespace DataResource {
|
||||
/**
|
||||
* 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({ restConfig, queries, params, data, }: {
|
||||
export function retrieveDataThumbnailId({
|
||||
restConfig,
|
||||
queries,
|
||||
params,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
Authorization: string,
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
id: UUID,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/thumbnail/{id}",
|
||||
endPoint: "/data/thumbnail/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
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 retrieveDataFull({ restConfig, queries, params, data, }: {
|
||||
export function uploadFile({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
queries: {
|
||||
Authorization: string,
|
||||
data: {
|
||||
file: File,
|
||||
},
|
||||
params: {
|
||||
name: string,
|
||||
id: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/data/{id}/{name}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
endPoint: "/data//upload/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
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 {UUID, Long, Gender, isGender, } from "./model"
|
||||
import {
|
||||
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 function remove({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/gender/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
export function get({
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
};
|
||||
export function get({ restConfig, params, }: {
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
@ -38,12 +41,44 @@ export namespace GenderResource {
|
||||
params,
|
||||
}, 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,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Gender,
|
||||
data: GenderWrite,
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -57,13 +92,16 @@ export namespace GenderResource {
|
||||
data,
|
||||
}, isGender);
|
||||
};
|
||||
export function post({ restConfig, data, }: {
|
||||
export function post({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Gender,
|
||||
data: GenderWrite,
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/gender",
|
||||
endPoint: "/gender/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
@ -72,41 +110,29 @@ export namespace GenderResource {
|
||||
data,
|
||||
}, isGender);
|
||||
};
|
||||
export function gets({ restConfig, }: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Gender[]> {
|
||||
return RESTRequestJsonArray({
|
||||
restModel: {
|
||||
endPoint: "/gender",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
export function remove({
|
||||
restConfig,
|
||||
}, isGender);
|
||||
};
|
||||
export function uploadCover({ restConfig, params, data, }: {
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
}): Promise<Gender> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/gender/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
endPoint: "/gender/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isGender);
|
||||
});
|
||||
};
|
||||
export function removeCover({ restConfig, params, }: {
|
||||
export function removeCover({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
coverId: UUID,
|
||||
@ -124,4 +150,32 @@ export namespace GenderResource {
|
||||
params,
|
||||
}, 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 {UUID, Long, Playlist, isPlaylist, } from "./model"
|
||||
import {
|
||||
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 function remove({ restConfig, params, }: {
|
||||
export function addTrack({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
trackId: Long,
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
endPoint: "/playlist/{id}/track/{trackId}",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
});
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function get({ restConfig, params, }: {
|
||||
export function get({
|
||||
restConfig,
|
||||
params,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
@ -38,12 +61,44 @@ export namespace PlaylistResource {
|
||||
params,
|
||||
}, 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,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Playlist,
|
||||
data: PlaylistWrite,
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -57,13 +112,16 @@ export namespace PlaylistResource {
|
||||
data,
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function post({ restConfig, data, }: {
|
||||
export function post({
|
||||
restConfig,
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Playlist,
|
||||
data: PlaylistWrite,
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/playlist",
|
||||
endPoint: "/playlist/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
@ -72,77 +130,29 @@ export namespace PlaylistResource {
|
||||
data,
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function gets({ restConfig, }: {
|
||||
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,
|
||||
},
|
||||
export function remove({
|
||||
restConfig,
|
||||
params,
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function removeTrack({ restConfig, params, }: {
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
trackId: Long,
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}/track/{trackId}",
|
||||
endPoint: "/playlist/{id}",
|
||||
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: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
}): Promise<Playlist> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/playlist/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
export function removeCover({
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, isPlaylist);
|
||||
};
|
||||
export function removeCover({ restConfig, params, }: {
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
coverId: UUID,
|
||||
@ -160,4 +170,50 @@ export namespace PlaylistResource {
|
||||
params,
|
||||
}, 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 {UUID, Long, Track, isTrack, } from "./model"
|
||||
import {
|
||||
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 function remove({ restConfig, params, }: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
endPoint: "/track/{id}",
|
||||
requestType: HTTPRequestModel.DELETE,
|
||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
export function addTrack({
|
||||
restConfig,
|
||||
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,
|
||||
params: {
|
||||
artistId: Long,
|
||||
@ -102,39 +43,69 @@ export namespace TrackResource {
|
||||
params,
|
||||
}, isTrack);
|
||||
};
|
||||
export function removeTrack({ restConfig, params, }: {
|
||||
export function get({
|
||||
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,
|
||||
endPoint: "/track/{id}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, 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,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
data: TrackWrite,
|
||||
}): Promise<Track> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/track/{id}/cover",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.MULTIPART,
|
||||
endPoint: "/track/{id}",
|
||||
requestType: HTTPRequestModel.PATCH,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
@ -142,7 +113,47 @@ export namespace TrackResource {
|
||||
data,
|
||||
}, 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,
|
||||
params: {
|
||||
coverId: UUID,
|
||||
@ -160,7 +171,60 @@ export namespace TrackResource {
|
||||
params,
|
||||
}, 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,
|
||||
data: {
|
||||
fileName: string,
|
||||
@ -171,6 +235,7 @@ export namespace TrackResource {
|
||||
trackId: Long,
|
||||
title: string,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
}): Promise<Track> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -181,6 +246,7 @@ export namespace TrackResource {
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
callbacks,
|
||||
}, 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 "./album-resource";
|
||||
export * from "./artist-resource";
|
||||
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";
|
||||
export * from "./api";
|
||||
export * from "./rest-tools";
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
import { RestErrorResponse } from "./model"
|
||||
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||
|
||||
export enum HTTPRequestModel {
|
||||
DELETE = 'DELETE',
|
||||
GET = 'GET',
|
||||
PATCH = 'PATCH',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
DELETE = "DELETE",
|
||||
GET = "GET",
|
||||
PATCH = "PATCH",
|
||||
POST = "POST",
|
||||
PUT = "PUT",
|
||||
}
|
||||
export enum HTTPMimeType {
|
||||
ALL = '*/*',
|
||||
CSV = 'text/csv',
|
||||
IMAGE = 'image/*',
|
||||
IMAGE_JPEG = 'image/jpeg',
|
||||
IMAGE_PNG = 'image/png',
|
||||
JSON = 'application/json',
|
||||
MULTIPART = 'multipart/form-data',
|
||||
OCTET_STREAM = 'application/octet-stream',
|
||||
TEXT_PLAIN = 'text/plain',
|
||||
ALL = "*/*",
|
||||
CSV = "text/csv",
|
||||
IMAGE = "image/*",
|
||||
IMAGE_JPEG = "image/jpeg",
|
||||
IMAGE_PNG = "image/png",
|
||||
JSON = "application/json",
|
||||
MULTIPART = "multipart/form-data",
|
||||
OCTET_STREAM = "application/octet-stream",
|
||||
TEXT_PLAIN = "text/plain",
|
||||
}
|
||||
|
||||
export interface RESTConfig {
|
||||
// base of the server: http(s)://my.server.org/plop/api/
|
||||
server: string;
|
||||
// Token to access of the data.
|
||||
token?: string;
|
||||
// base of the server: http(s)://my.server.org/plop/api/
|
||||
server: string;
|
||||
// Token to access of the data.
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface RESTModel {
|
||||
// base of the local API request: "sheep/{id}".
|
||||
endPoint: string;
|
||||
// Type of the request.
|
||||
requestType?: HTTPRequestModel;
|
||||
// Input type requested.
|
||||
accept?: HTTPMimeType;
|
||||
// Content of the local data.
|
||||
contentType?: HTTPMimeType;
|
||||
// Mode of the TOKEN in urk or Header
|
||||
tokenInUrl?: boolean;
|
||||
// base of the local API request: "sheep/{id}".
|
||||
endPoint: string;
|
||||
// Type of the request.
|
||||
requestType?: HTTPRequestModel;
|
||||
// Input type requested.
|
||||
accept?: HTTPMimeType;
|
||||
// Content of the local data.
|
||||
contentType?: HTTPMimeType;
|
||||
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||
tokenInUrl?: boolean;
|
||||
}
|
||||
|
||||
export interface ModelResponseHttp {
|
||||
status: number;
|
||||
data: any;
|
||||
status: number;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export function isArrayOf<TYPE>(
|
||||
data: any,
|
||||
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;
|
||||
function isNullOrUndefined(data: any): data is undefined | null {
|
||||
return data === undefined || data === null;
|
||||
}
|
||||
|
||||
export type RESTRequestType = {
|
||||
restModel: RESTModel,
|
||||
restConfig: RESTConfig,
|
||||
data?: any,
|
||||
params?: object,
|
||||
queries?: object,
|
||||
};
|
||||
// generic progression callback
|
||||
export type ProgressCallback = (count: number, total: number) => void;
|
||||
|
||||
export interface RESTAbort {
|
||||
abort?: () => boolean;
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return input.replace(/\/+$/, '');
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "undefined";
|
||||
}
|
||||
return input.replace(/\/+$/, "");
|
||||
}
|
||||
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 {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||
if (params !== undefined) {
|
||||
for (let key of Object.keys(params)) {
|
||||
generateUrl = generateUrl.replaceAll(`{${key}}`, `${params[key]}`);
|
||||
export function RESTUrl({
|
||||
restModel,
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
}: 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;
|
||||
}
|
||||
const searchParams = new URLSearchParams();
|
||||
if (queries !== undefined) {
|
||||
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();
|
||||
}
|
||||
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> {
|
||||
// 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;
|
||||
export function fetchProgress(
|
||||
generateUrl: string,
|
||||
{
|
||||
method,
|
||||
headers,
|
||||
body,
|
||||
}: {
|
||||
method: HTTPRequestModel;
|
||||
headers: any;
|
||||
body: any;
|
||||
},
|
||||
{ progressUpload, progressDownload, abortHandle }: RESTCallbacks
|
||||
): Promise<Response> {
|
||||
const xhr: {
|
||||
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;
|
||||
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]);
|
||||
// Stream the download progress
|
||||
if (progressDownload) {
|
||||
xhr.io?.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
progressDownload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
body = formData
|
||||
});
|
||||
}
|
||||
console.log(`Call ${generateUrl}`)
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(generateUrl, {
|
||||
method: restModel.requestType,
|
||||
headers,
|
||||
body,
|
||||
}).then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (restModel.accept !== contentType) {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 901,
|
||||
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
|
||||
statusMessage: "Fetch error",
|
||||
message: "rest-tools.ts Wrong type in the message return type"
|
||||
} as RestErrorResponse);
|
||||
} else if (contentType === HTTPMimeType.JSON) {
|
||||
response
|
||||
.json()
|
||||
.then((value: any) => {
|
||||
//console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
|
||||
resolve({ status: response.status, data: value });
|
||||
})
|
||||
.catch((reason: any) => {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 902,
|
||||
error: `REST parse json fail: ${reason}`,
|
||||
statusMessage: "Fetch parse error",
|
||||
message: "rest-tools.ts Wrong message model to parse"
|
||||
} as RestErrorResponse);
|
||||
});
|
||||
} else {
|
||||
resolve({ status: response.status, data: response.body });
|
||||
}
|
||||
} else {
|
||||
if (abortHandle) {
|
||||
abortHandle.abort = () => {
|
||||
if (xhr.io) {
|
||||
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||
xhr.io.abort();
|
||||
return true;
|
||||
}
|
||||
console.log(
|
||||
`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`
|
||||
);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// Check if we have an internal Fail:
|
||||
xhr.io?.addEventListener("error", () => {
|
||||
xhr.io = undefined;
|
||||
reject(new TypeError("Failed to fetch"));
|
||||
});
|
||||
|
||||
// Capture the end of the stream
|
||||
xhr.io?.addEventListener("loadend", () => {
|
||||
if (xhr.io?.readyState !== XMLHttpRequest.DONE) {
|
||||
return;
|
||||
}
|
||||
if (xhr.io?.status === 0) {
|
||||
//the stream has been aborted
|
||||
reject(new TypeError("Fetch has been aborted"));
|
||||
return;
|
||||
}
|
||||
// Stream is ended, transform in a generic response:
|
||||
const response = new Response(xhr.io.response, {
|
||||
status: xhr.io.status,
|
||||
statusText: xhr.io.statusText,
|
||||
});
|
||||
const headersArray = replaceAll(
|
||||
xhr.io.getAllResponseHeaders().trim(),
|
||||
"\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({
|
||||
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(),
|
||||
status: response.status,
|
||||
error: `${response.body}`,
|
||||
statusMessage: "Fetch code error",
|
||||
message: "rest-tools.ts Wrong return code"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((error: any) => {
|
||||
reject({
|
||||
time: Date(),
|
||||
status: 999,
|
||||
error: error,
|
||||
statusMessage: "Fetch catch error",
|
||||
message: "http-wrapper.ts detect an error in the fetch request"
|
||||
message: `unmanaged error model: ${dataError} with error: ${reason}`,
|
||||
statusMessage: "Fetch ERROR TEXT 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 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> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
if (checker(value.data)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
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 RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
if (isArrayOf(value.data, checker)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
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 RESTRequestJson<TYPE>(
|
||||
request: RESTRequestType,
|
||||
checker?: (data: any) => data is TYPE
|
||||
): Promise<TYPE> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request)
|
||||
.then((value: ModelResponseHttp) => {
|
||||
if (isNullOrUndefined(checker)) {
|
||||
console.log(`Have no check of MODEL in API: ${RESTUrl(request)}`);
|
||||
resolve(value.data);
|
||||
} else if (checker === undefined || checker(value.data)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
reject({
|
||||
name: "Model check fail",
|
||||
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> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
resolve();
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request)
|
||||
.then((value: ModelResponseHttp) => {
|
||||
resolve();
|
||||
})
|
||||
.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({
|
||||
selector: 'description-area',
|
||||
templateUrl: './description-area.html',
|
||||
styleUrls: ['./description-area.less']
|
||||
selector: 'AppDescriptionArea',
|
||||
templateUrl: './AppDescriptionArea.html',
|
||||
styleUrls: ['./AppDescriptionArea.less']
|
||||
})
|
||||
export class DescriptionAreaComponent {
|
||||
export class AppDescriptionArea {
|
||||
@Input() title: string;
|
||||
@Input() name?: string;
|
||||
@Input() description?: string;
|
@ -5,19 +5,19 @@
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
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';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-season',
|
||||
templateUrl: './element-season.html',
|
||||
styleUrls: ['./element-season.less']
|
||||
selector: 'AppElementAlbum',
|
||||
templateUrl: './AppElementAlbum.html',
|
||||
styleUrls: ['./AppElementAlbum.less']
|
||||
})
|
||||
export class ElementSeasonComponent implements OnInit {
|
||||
export class AppElementAlbum implements OnInit {
|
||||
// input parameters
|
||||
@Input() element: NodeSmall;
|
||||
@Input() element: Album;
|
||||
@Input() prefix: String;
|
||||
@Input() countSubTypeCallBack: (arg0: number) => Promise<number>;
|
||||
@Input() countSubType: String;
|
@ -6,18 +6,23 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
|
||||
import { DataService } from 'app/service';
|
||||
import { NodeSmall } from 'app/back-api';
|
||||
import { isNullOrUndefined } from '@kangaroo-and-rabbit/kar-cw';
|
||||
|
||||
export interface HomeInterface {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string;
|
||||
covers?: string[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-type',
|
||||
templateUrl: './element-type.html',
|
||||
styleUrls: ['./element-type.less']
|
||||
selector: 'AppElementHomeType',
|
||||
templateUrl: './AppElementHomeType.html',
|
||||
styleUrls: ['./AppElementHomeType.less']
|
||||
})
|
||||
export class ElementTypeComponent implements OnInit {
|
||||
// input parameters
|
||||
@Input() element: NodeSmall;
|
||||
@Input() element: HomeInterface;
|
||||
@Input() functionVignette: (number) => Promise<Number>;
|
||||
|
||||
public name: string = 'rr';
|
@ -5,18 +5,18 @@
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-element-track',
|
||||
templateUrl: './element-track.html',
|
||||
styleUrls: ['./element-track.less']
|
||||
selector: 'AppElementTrack',
|
||||
templateUrl: './AppElementTrack.html',
|
||||
styleUrls: ['./AppElementTrack.less']
|
||||
})
|
||||
export class ElementTrackComponent implements OnInit {
|
||||
export class AppElementTrack implements OnInit {
|
||||
// input parameters
|
||||
@Input() element: NodeSmall;
|
||||
@Input() element: Track;
|
||||
@Input() prefix: String;
|
||||
|
||||
prefixName: string = "";
|
@ -21,9 +21,9 @@ export enum PlayMode {
|
||||
|
||||
// note: all the input is managed with the player service ...
|
||||
@Component({
|
||||
selector: 'app-element-player-audio',
|
||||
templateUrl: './element-player-audio.html',
|
||||
styleUrls: ['./element-player-audio.less']
|
||||
selector: 'AppPlayerAudio',
|
||||
templateUrl: './AppPlayerAudio.html',
|
||||
styleUrls: ['./AppPlayerAudio.less']
|
||||
})
|
||||
export class ElementPlayerAudioComponent implements OnInit {
|
||||
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;
|
||||
unlockPlayerEnable() {
|
||||
let temporaryValue = this.wakeLock;
|
||||
const temporaryValue = this.wakeLock;
|
||||
this.wakeLock = null;
|
||||
if (!isNullOrUndefined(temporaryValue)) {
|
||||
console.log(`plopppp ${temporaryValue}`);
|
||||
temporaryValue.release();
|
||||
}
|
||||
try {
|
||||
let tmp = navigator as any;
|
||||
const tmp = navigator as any;
|
||||
this.wakeLock = tmp.wakeLock.request('screen');
|
||||
} catch (err) {
|
||||
// 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 { ElementPlayerAudioComponent } from "./element-player-audio/element-player-audio";
|
||||
import { ElementSeasonComponent } from "./element-season/element-season";
|
||||
import { ElementSeriesComponent } from "./element-series/element-series";
|
||||
import { ElementTrackComponent } from "./element-track/element-track";
|
||||
import { ElementVideoComponent } from "./element-video/element-video";
|
||||
import { AppDescriptionArea } from "./AppDescriptionArea/AppDescriptionArea";
|
||||
import { ElementPlayerAudioComponent } from "./AppPlayerAudio/AppPlayerAudio";
|
||||
import { AppElementAlbum } from "./AppElementAlbum/AppElementAlbum";
|
||||
import { AppElementTrack } from "./AppElementTrack/AppElementTrack";
|
||||
|
||||
|
||||
|
||||
export {
|
||||
ElementSeriesComponent,
|
||||
ElementVideoComponent,
|
||||
ElementSeasonComponent,
|
||||
AppDescriptionArea,
|
||||
AppElementAlbum,
|
||||
ElementPlayerAudioComponent,
|
||||
ElementTrackComponent,
|
||||
DescriptionAreaComponent,
|
||||
AppElementTrack,
|
||||
};
|
||||
|
||||
|
@ -17,9 +17,9 @@ export interface ElementList {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-album-edit',
|
||||
templateUrl: './album-edit.html',
|
||||
styleUrls: ['./album-edit.less']
|
||||
selector: 'SceneAlbumEdit',
|
||||
templateUrl: './SceneAlbumEdit.html',
|
||||
styleUrls: ['./SceneAlbumEdit.less']
|
||||
})
|
||||
|
||||
export class AlbumEditScene implements OnInit {
|
@ -1,6 +1,6 @@
|
||||
<div class="generic-page">
|
||||
|
||||
<description-area
|
||||
<AppDescriptionArea
|
||||
[title]="name"
|
||||
[name]="albumName"
|
||||
[description]="albumDescription"
|
||||
@ -13,7 +13,7 @@
|
||||
<div class="clear"></div>
|
||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||
@for (data of tracks; track data.id;) {
|
||||
<app-element-track
|
||||
<AppElementTrack
|
||||
[element]="data"
|
||||
(click)="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';
|
||||
|
||||
@Component({
|
||||
selector: 'app-album',
|
||||
templateUrl: './album.html',
|
||||
selector: 'SceneAlbum',
|
||||
templateUrl: './SceneAlbum.html',
|
||||
})
|
||||
|
||||
export class AlbumScene implements OnInit {
|
@ -1,5 +1,5 @@
|
||||
<div class="generic-page">
|
||||
<description-area
|
||||
<AppDescriptionArea
|
||||
[title]="name"
|
||||
[description]="description"
|
||||
[cover1]="covers"
|
||||
@ -14,7 +14,7 @@
|
||||
(click)="onSelectAlbum($event, data.id)"
|
||||
(auxclick)="onSelectAlbum($event, data.id)"
|
||||
>
|
||||
<app-element-season
|
||||
<AppElementAlbum
|
||||
[element]="data"
|
||||
countSubType="Track"
|
||||
[countSubTypeCallBack]="countTrack"
|
||||
@ -30,7 +30,7 @@
|
||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||
@for (data of tracks; track data.id;) {
|
||||
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||
<app-element-video
|
||||
<AppElementTrack
|
||||
[element]="data"/>
|
||||
</div>
|
||||
}
|
@ -11,8 +11,8 @@ import { Album, Artist, Track } from 'app/back-api';
|
||||
import { ArtistService, DataService, ArianeService, AlbumService, PlayerService, TrackService } from 'app/service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-albums',
|
||||
templateUrl: './albums.html'
|
||||
selector: 'SceneAlbums',
|
||||
templateUrl: './SceneAlbums.html'
|
||||
})
|
||||
|
||||
export class AlbumsScene implements OnInit {
|
@ -1,5 +1,5 @@
|
||||
<div class="generic-page">
|
||||
<description-area
|
||||
<AppDescriptionArea
|
||||
[title]="name"
|
||||
[name]="albumName"
|
||||
[description]="albumDescription"
|
||||
@ -12,10 +12,10 @@
|
||||
<div class="clear"></div>
|
||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||
@for (data of tracks; track data.id;) {
|
||||
<app-element-track
|
||||
<AppElementTrack
|
||||
[element]="data"
|
||||
(click)="onSelectTrack($event, data.id)"
|
||||
(auxclick)="onSelectTrack($event, data.id)"></app-element-track>
|
||||
(auxclick)="onSelectTrack($event, data.id)"></AppElementTrack>
|
||||
} @empty {
|
||||
Aucune piste accessible.
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div class="generic-page">
|
||||
<description-area
|
||||
<AppDescriptionArea
|
||||
[title]="name"
|
||||
[description]="description"
|
||||
[cover1]="covers"
|
||||
@ -11,11 +11,11 @@
|
||||
<div class="title">Album{{albums.length > 1?"s":""}}:</div>
|
||||
@for (data of albums; track data.id;) {
|
||||
<div class="item-list" (click)="onSelectAlbum($event, data.id)" (auxclick)="onSelectAlbum($event, data.id)">
|
||||
<app-element-season
|
||||
<AppElementAlbum
|
||||
[element]="data"
|
||||
countSubType="Track"
|
||||
[countSubTypeCallBack]="countTrack"
|
||||
></app-element-season>
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@ -26,9 +26,9 @@
|
||||
<div class="title">Track{{tracks.length > 1?"s":""}}:</div>
|
||||
@for (data of tracks; track data.id;) {
|
||||
<div class="item item-video" (click)="onSelectTrack($event, data.id)" (auxclick)="onSelectTrack($event, data.id)">
|
||||
<app-element-video
|
||||
<AppElementTrack
|
||||
[element]="data"
|
||||
></app-element-video>
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<div class="generic-page">
|
||||
<description-area
|
||||
<AppDescriptionArea
|
||||
[title]="name"
|
||||
[description]="description"
|
||||
[cover1]="covers"
|
||||
@ -11,13 +11,13 @@
|
||||
<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;) {
|
||||
<div class="item-list" (click)="onSelectArtist($event, data.id)" (auxclick)="onSelectArtist($event, data.id)">
|
||||
<app-element-season
|
||||
<AppElementAlbum
|
||||
[element]="data"
|
||||
countSubType="Album"
|
||||
[countSubTypeCallBack]="countAlbum"
|
||||
countSubType2="Track"
|
||||
[countSubType2CallBack]="countTrack"
|
||||
></app-element-season>
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
||||
<div class="clear"></div>
|
||||
@for (data of tracks; track 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>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<div class="fill-all colomn_mutiple">
|
||||
@for (data of dataList; track 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 class="clear"></div>
|
||||
|
@ -5,8 +5,9 @@
|
||||
*/
|
||||
|
||||
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({
|
||||
selector: 'app-home',
|
||||
@ -14,7 +15,7 @@ import { ArianeService, GenderService } from 'app/service';
|
||||
styleUrls: ['./home.less']
|
||||
})
|
||||
export class HomeScene implements OnInit {
|
||||
dataList = [
|
||||
dataList: HomeInterface[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Genders",
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { GenderScene } from "./gender/gender";
|
||||
import { HelpScene } from "./help/help";
|
||||
import { HomeScene } from "./home/home";
|
||||
import { AlbumEditScene } from "./album-edit/album-edit";
|
||||
import { AlbumScene } from "./album/album";
|
||||
import { AlbumsScene } from "./album/albums";
|
||||
import { AlbumEditScene } from "./album-edit/SceneAlbumEdit";
|
||||
import { AlbumScene } from "./album/SceneAlbum";
|
||||
import { AlbumsScene } from "./album/SceneAlbums";
|
||||
import { ArtistEditScene } from "./artist-edit/artist-edit";
|
||||
import { ArtistScene } from "./artist/artist";
|
||||
import { ArtistsScene } from "./artist/artists";
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="fill-all colomn_mutiple">
|
||||
@for (data of tracks; track data.id) {
|
||||
<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 class="clear"></div>
|
||||
|
@ -7,10 +7,10 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
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 { 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()
|
||||
export class AlbumService extends GenericDataService<Album> {
|
||||
@ -110,7 +110,6 @@ export class AlbumService extends GenericDataService<Album> {
|
||||
},
|
||||
data: {
|
||||
file,
|
||||
fileName: file.name
|
||||
}
|
||||
}).then((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