[DEV] update new archidata
This commit is contained in:
parent
11b8b575e4
commit
d44396ccee
@ -5,7 +5,7 @@ version_file="../version.txt"
|
|||||||
# update new release dependency
|
# update new release dependency
|
||||||
cd back
|
cd back
|
||||||
# update the Maven version number
|
# update the Maven version number
|
||||||
mvn versions:set -DnewVersion=$(sed 's/DEV/SNAPSHOT/g' $version_file)
|
mvn versions:set -DnewVersion=$(sed 's/dev/SNAPSHOT/g' $version_file)
|
||||||
if grep -q "DEV" "$version_file"; then
|
if grep -q "DEV" "$version_file"; then
|
||||||
# update all versions release of dependency
|
# update all versions release of dependency
|
||||||
mvn versions:use-latest-releases
|
mvn versions:use-latest-releases
|
||||||
@ -19,11 +19,14 @@ cd -
|
|||||||
|
|
||||||
|
|
||||||
cd front
|
cd front
|
||||||
if grep -q "DEV" "$version_file"; then
|
if grep -q "dev" "$version_file"; then
|
||||||
# update all dependency
|
# update all dependency
|
||||||
pnpm install
|
pnpm install
|
||||||
pnpm run update_packages
|
pnpm run update_packages
|
||||||
else
|
else
|
||||||
# in case of release ==> can not do it automatically ...
|
# in case of release ==> can not do it automatically ...
|
||||||
|
echo not implemented
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
@ -59,15 +59,6 @@ FROM bellsoft/liberica-openjdk-alpine:latest
|
|||||||
# add wget to manage the health check...
|
# add wget to manage the health check...
|
||||||
RUN apk add --no-cache wget
|
RUN apk add --no-cache wget
|
||||||
|
|
||||||
#FROM archlinux:base
|
|
||||||
#RUN pacman -Syu --noconfirm && pacman-db-upgrade
|
|
||||||
## install package
|
|
||||||
#RUN pacman -S --noconfirm jdk-openjdk wget
|
|
||||||
## intall npm
|
|
||||||
#RUN pacman -S --noconfirm npm
|
|
||||||
## clean all the caches Need only on the release environment
|
|
||||||
#RUN pacman -Scc --noconfirm
|
|
||||||
|
|
||||||
ENV LANG=C.UTF-8
|
ENV LANG=C.UTF-8
|
||||||
|
|
||||||
COPY --from=buildBack /tmp/out/maven/*.jar /application/application.jar
|
COPY --from=buildBack /tmp/out/maven/*.jar /application/application.jar
|
||||||
|
64
back/pom.xml
64
back/pom.xml
@ -20,17 +20,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.8.4</version>
|
<version>0.12.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
<version>2.0.9</version>
|
<version>2.1.0-alpha1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.16.1</version>
|
<version>2.17.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
************************************************************
|
************************************************************
|
||||||
@ -40,15 +40,25 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.10.1</version>
|
<version>5.11.0-M2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
<version>5.10.1</version>
|
<version>5.11.0-M2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
|
<version>2.24.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
@ -185,24 +195,10 @@
|
|||||||
<mainClass>org.kar.karideo.WebLauncher</mainClass>
|
<mainClass>org.kar.karideo.WebLauncher</mainClass>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
<plugin>
|
||||||
<groupId>net.revelc.code.formatter</groupId>
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
<artifactId>formatter-maven-plugin</artifactId>
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
<version>2.12.2</version>
|
<version>2.23.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
@ -226,7 +222,23 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
-->
|
<plugin>
|
||||||
|
<groupId>com.github.spotbugs</groupId>
|
||||||
|
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||||
|
<version>4.8.5.0</version>
|
||||||
|
<configuration>
|
||||||
|
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
|
||||||
|
<excludeFilterFile>spotbugs-security-exclude.xml</excludeFilterFile>
|
||||||
|
<!--<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>com.h3xstream.findsecbugs</groupId>
|
||||||
|
<artifactId>findsecbugs-plugin</artifactId>
|
||||||
|
<version>1.12.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
-->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<!-- Generate Java-docs As Part Of Project Reports -->
|
<!-- Generate Java-docs As Part Of Project Reports -->
|
||||||
|
@ -10,10 +10,7 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||||||
import org.kar.archidata.GlobalConfiguration;
|
import org.kar.archidata.GlobalConfiguration;
|
||||||
import org.kar.archidata.UpdateJwtPublicKey;
|
import org.kar.archidata.UpdateJwtPublicKey;
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
import org.kar.archidata.catcher.GenericCatcher;
|
||||||
import org.kar.archidata.catcher.FailExceptionCatcher;
|
|
||||||
import org.kar.archidata.catcher.InputExceptionCatcher;
|
|
||||||
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
|
||||||
import org.kar.archidata.db.DBConfig;
|
import org.kar.archidata.db.DBConfig;
|
||||||
import org.kar.archidata.filter.CORSFilter;
|
import org.kar.archidata.filter.CORSFilter;
|
||||||
import org.kar.archidata.filter.OptionFilter;
|
import org.kar.archidata.filter.OptionFilter;
|
||||||
@ -95,10 +92,7 @@ public class WebLauncher {
|
|||||||
// global authentication system
|
// global authentication system
|
||||||
rc.register(KarideoAuthenticationFilter.class);
|
rc.register(KarideoAuthenticationFilter.class);
|
||||||
// register exception catcher
|
// register exception catcher
|
||||||
rc.register(InputExceptionCatcher.class);
|
GenericCatcher.addAll(rc);
|
||||||
rc.register(SystemExceptionCatcher.class);
|
|
||||||
rc.register(FailExceptionCatcher.class);
|
|
||||||
rc.register(ExceptionCatcher.class);
|
|
||||||
// add default resource:
|
// add default resource:
|
||||||
rc.register(UserResource.class);
|
rc.register(UserResource.class);
|
||||||
rc.register(SeriesResource.class);
|
rc.register(SeriesResource.class);
|
||||||
@ -114,7 +108,7 @@ public class WebLauncher {
|
|||||||
// add jackson to be discover when we are ins stand-alone server
|
// add jackson to be discover when we are ins stand-alone server
|
||||||
rc.register(JacksonFeature.class);
|
rc.register(JacksonFeature.class);
|
||||||
// enable this to show low level request
|
// enable this to show low level request
|
||||||
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
// rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||||
|
|
||||||
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), rc);
|
||||||
final HttpServer serverLink = this.server;
|
final HttpServer serverLink = this.server;
|
||||||
|
@ -4,7 +4,8 @@ package org.kar.karideo;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.dataAccess.DataFactoryTsApi;
|
import org.kar.archidata.externalRestApi.AnalyzeApi;
|
||||||
|
import org.kar.archidata.externalRestApi.TsGenerateApi;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.karideo.api.Front;
|
import org.kar.karideo.api.Front;
|
||||||
import org.kar.karideo.api.HealthCheck;
|
import org.kar.karideo.api.HealthCheck;
|
||||||
@ -14,7 +15,6 @@ import org.kar.karideo.api.SeriesResource;
|
|||||||
import org.kar.karideo.api.TypeResource;
|
import org.kar.karideo.api.TypeResource;
|
||||||
import org.kar.karideo.api.UserMediaAdvancementResource;
|
import org.kar.karideo.api.UserMediaAdvancementResource;
|
||||||
import org.kar.karideo.api.UserResource;
|
import org.kar.karideo.api.UserResource;
|
||||||
import org.kar.karideo.migration.Initialization;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -23,18 +23,18 @@ public class WebLauncherLocal extends WebLauncher {
|
|||||||
|
|
||||||
private WebLauncherLocal() {}
|
private WebLauncherLocal() {}
|
||||||
|
|
||||||
|
public static void generateObjects() throws Exception {
|
||||||
|
LOGGER.info("Generate APIs");
|
||||||
|
final List<Class<?>> listOfResources = List.of(Front.class, HealthCheck.class, SeasonResource.class, SeriesResource.class, TypeResource.class, UserMediaAdvancementResource.class,
|
||||||
|
UserResource.class, MediaResource.class, DataResource.class);
|
||||||
|
final AnalyzeApi api = new AnalyzeApi();
|
||||||
|
api.addAllApi(listOfResources);
|
||||||
|
TsGenerateApi.generateApi(api, "../front/src/app/back-api/");
|
||||||
|
LOGGER.info("Generate APIs (DONE)");
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
DataFactoryTsApi.generatePackage(List.of(
|
generateObjects();
|
||||||
Front.class,
|
|
||||||
HealthCheck.class,
|
|
||||||
SeasonResource.class,
|
|
||||||
SeriesResource.class,
|
|
||||||
TypeResource.class,
|
|
||||||
UserMediaAdvancementResource.class,
|
|
||||||
UserResource.class,
|
|
||||||
MediaResource.class,
|
|
||||||
DataResource.class),
|
|
||||||
Initialization.CLASSES_BASE, "../front/src/app/back-api/");
|
|
||||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||||
launcher.process();
|
launcher.process();
|
||||||
LOGGER.info("end-configure the server & wait finish process:");
|
LOGGER.info("end-configure the server & wait finish process:");
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.kar.karideo.api;
|
package org.kar.karideo.api;
|
||||||
|
|
||||||
|
|
||||||
import org.kar.archidata.api.FrontGeneric;
|
import org.kar.archidata.api.FrontGeneric;
|
||||||
|
|
||||||
import jakarta.ws.rs.Path;
|
import jakarta.ws.rs.Path;
|
||||||
@ -11,6 +10,6 @@ import org.kar.karideo.util.ConfigVariable;
|
|||||||
public class Front extends FrontGeneric {
|
public class Front extends FrontGeneric {
|
||||||
public Front() {
|
public Front() {
|
||||||
this.baseFrontFolder = ConfigVariable.getFrontFolder();
|
this.baseFrontFolder = ConfigVariable.getFrontFolder();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,14 +89,14 @@ public class MediaResource {
|
|||||||
@FormDataParam("fileName") String fileName, //
|
@FormDataParam("fileName") String fileName, //
|
||||||
@FormDataParam("universe") String universe, //
|
@FormDataParam("universe") String universe, //
|
||||||
@FormDataParam("series") String series, //
|
@FormDataParam("series") String series, //
|
||||||
//@FormDataParam("seriesId") String seriesId, // Not used ...
|
// @FormDataParam("seriesId") String seriesId, // Not used ...
|
||||||
@FormDataParam("season") String season, //
|
@FormDataParam("season") String season, //
|
||||||
@FormDataParam("episode") String episode, //
|
@FormDataParam("episode") String episode, //
|
||||||
@FormDataParam("title") String title, //
|
@FormDataParam("title") String title, //
|
||||||
@FormDataParam("typeId") String typeId, //
|
@FormDataParam("typeId") String typeId, //
|
||||||
@FormDataParam("file") final InputStream fileInputStream, //
|
@FormDataParam("file") final InputStream fileInputStream, //
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
||||||
) throws FailException {
|
) throws FailException {
|
||||||
try {
|
try {
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
fileName = multipartCorrection(fileName);
|
fileName = multipartCorrection(fileName);
|
||||||
@ -107,7 +107,7 @@ public class MediaResource {
|
|||||||
title = multipartCorrection(title);
|
title = multipartCorrection(title);
|
||||||
typeId = multipartCorrection(typeId);
|
typeId = multipartCorrection(typeId);
|
||||||
|
|
||||||
//public NodeSmall uploadFile(final FormDataMultiPart form) {
|
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||||
LOGGER.info("Upload media file: {}", fileMetaData);
|
LOGGER.info("Upload media file: {}", fileMetaData);
|
||||||
LOGGER.info(" - fileName: {}", fileName);
|
LOGGER.info(" - fileName: {}", fileName);
|
||||||
LOGGER.info(" - universe: {}", universe);
|
LOGGER.info(" - universe: {}", universe);
|
||||||
@ -136,7 +136,7 @@ public class MediaResource {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
throw new FailException("can not create input media (the data model has an internal error");
|
throw new FailException("can not create input media (the data model has an internal error");
|
||||||
}
|
}
|
||||||
} else if (data!= null && data.deleted != null && data.deleted) {
|
} else if (data != null && data.deleted != null && data.deleted) {
|
||||||
LOGGER.info("Data already exist but deleted");
|
LOGGER.info("Data already exist but deleted");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
DataTools.undelete(data.uuid);
|
DataTools.undelete(data.uuid);
|
||||||
@ -222,7 +222,7 @@ public class MediaResource {
|
|||||||
@FormDataParam("fileName") final String fileName, //
|
@FormDataParam("fileName") final String fileName, //
|
||||||
@FormDataParam("file") final InputStream fileInputStream, //
|
@FormDataParam("file") final InputStream fileInputStream, //
|
||||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData//
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData//
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
return DataAccess.get(Media.class, id);
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ public class MediaResource {
|
|||||||
public Media removeCover( //
|
public Media removeCover( //
|
||||||
@PathParam("id") final Long id, //
|
@PathParam("id") final Long id, //
|
||||||
@PathParam("coverId") final UUID coverId //
|
@PathParam("coverId") final UUID coverId //
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
AddOnDataJson.removeLink(Media.class, id, "covers", coverId);
|
AddOnDataJson.removeLink(Media.class, id, "covers", coverId);
|
||||||
return DataAccess.get(Media.class, id);
|
return DataAccess.get(Media.class, id);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
public class SeasonResource {
|
public class SeasonResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(SeasonResource.class);
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@Operation(description = "Get a specific Season with his ID", tags = "GLOBAL")
|
@Operation(description = "Get a specific Season with his ID", tags = "GLOBAL")
|
||||||
@ -52,9 +51,7 @@ public class SeasonResource {
|
|||||||
return DataAccess.get(Season.class, id);
|
return DataAccess.get(Season.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* ============================================================================= ADMIN SECTION: ============================================================================= */
|
||||||
* ADMIN SECTION:
|
|
||||||
* ============================================================================= */
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
|
@ -51,9 +51,7 @@ public class SeriesResource {
|
|||||||
return DataAccess.get(Series.class, id);
|
return DataAccess.get(Series.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* ============================================================================= ADMIN SECTION: ============================================================================= */
|
||||||
* ADMIN SECTION:
|
|
||||||
* ============================================================================= */
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
|
@ -34,7 +34,6 @@ import jakarta.ws.rs.core.MediaType;
|
|||||||
public class TypeResource {
|
public class TypeResource {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(TypeResource.class);
|
||||||
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("USER")
|
@RolesAllowed("USER")
|
||||||
@Operation(description = "Get all Type", tags = "GLOBAL")
|
@Operation(description = "Get all Type", tags = "GLOBAL")
|
||||||
@ -55,9 +54,7 @@ public class TypeResource {
|
|||||||
return DataAccess.get(Type.class, id);
|
return DataAccess.get(Type.class, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* ============================================================================= ADMIN SECTION: ============================================================================= */
|
||||||
* ADMIN SECTION:
|
|
||||||
* ============================================================================= */
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
|
@ -46,19 +46,15 @@ public class UserMediaAdvancementResource {
|
|||||||
return DataAccess.getsWhere(UserMediaAdvancement.class, new Condition(new QueryCondition("userId", "=", gc.userByToken.id)));
|
return DataAccess.getsWhere(UserMediaAdvancement.class, new Condition(new QueryCondition("userId", "=", gc.userByToken.id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* ============================================================================= Modification SECTION: ============================================================================= */
|
||||||
* Modification SECTION:
|
|
||||||
* ============================================================================= */
|
|
||||||
|
|
||||||
public record MediaInformations(
|
public record MediaInformations(int time, float percent, int count) {
|
||||||
int time,
|
}
|
||||||
float percent,
|
|
||||||
int count) {}
|
|
||||||
|
|
||||||
//@POST
|
// @POST
|
||||||
//@Path("{id}")
|
// @Path("{id}")
|
||||||
//@RolesAllowed("USER")
|
// @RolesAllowed("USER")
|
||||||
//@Consumes(MediaType.APPLICATION_JSON)
|
// @Consumes(MediaType.APPLICATION_JSON)
|
||||||
public UserMediaAdvancement post(@Context final SecurityContext sc, @PathParam("id") final Long id, final MediaInformations data) throws Exception {
|
public UserMediaAdvancement post(@Context final SecurityContext sc, @PathParam("id") final Long id, final MediaInformations data) throws Exception {
|
||||||
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
final GenericContext gc = (GenericContext) sc.getUserPrincipal();
|
||||||
final UserMediaAdvancement elem = new UserMediaAdvancement();
|
final UserMediaAdvancement elem = new UserMediaAdvancement();
|
||||||
@ -70,10 +66,8 @@ public class UserMediaAdvancementResource {
|
|||||||
return DataAccess.insert(elem);
|
return DataAccess.insert(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record MediaInformationsDelta(
|
public record MediaInformationsDelta(int time, float percent, boolean addCount) {
|
||||||
int time,
|
}
|
||||||
float percent,
|
|
||||||
boolean addCount) {}
|
|
||||||
|
|
||||||
@PATCH
|
@PATCH
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
|
@ -15,9 +15,9 @@ import jakarta.annotation.Priority;
|
|||||||
@Priority(Priorities.AUTHENTICATION)
|
@Priority(Priorities.AUTHENTICATION)
|
||||||
public class KarideoAuthenticationFilter extends AuthenticationFilter {
|
public class KarideoAuthenticationFilter extends AuthenticationFilter {
|
||||||
final Logger logger = LoggerFactory.getLogger(KarideoAuthenticationFilter.class);
|
final Logger logger = LoggerFactory.getLogger(KarideoAuthenticationFilter.class);
|
||||||
|
|
||||||
public KarideoAuthenticationFilter() {
|
public KarideoAuthenticationFilter() {
|
||||||
super("karideo");
|
super("karideo");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,57 +4,57 @@ package org.kar.karideo.internal;
|
|||||||
//import io.scenarium.logger.Logger;
|
//import io.scenarium.logger.Logger;
|
||||||
|
|
||||||
public class Log {
|
public class Log {
|
||||||
// private static final String LIB_NAME = "logger";
|
// private static final String LIB_NAME = "logger";
|
||||||
// private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
|
// private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
|
||||||
// private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
|
// private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);
|
||||||
// private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
|
// private static final boolean PRINT_ERROR = Logger.getNeedPrint(LIB_NAME, LogLevel.ERROR);
|
||||||
// private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
|
// private static final boolean PRINT_WARNING = Logger.getNeedPrint(LIB_NAME, LogLevel.WARNING);
|
||||||
// private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
|
// private static final boolean PRINT_INFO = Logger.getNeedPrint(LIB_NAME, LogLevel.INFO);
|
||||||
// private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
|
// private static final boolean PRINT_DEBUG = Logger.getNeedPrint(LIB_NAME, LogLevel.DEBUG);
|
||||||
// private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
|
// private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(LIB_NAME, LogLevel.VERBOSE);
|
||||||
// private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
|
// private static final boolean PRINT_TODO = Logger.getNeedPrint(LIB_NAME, LogLevel.TODO);
|
||||||
// private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
|
// private static final boolean PRINT_PRINT = Logger.getNeedPrint(LIB_NAME, LogLevel.PRINT);
|
||||||
//
|
//
|
||||||
// private Log() {}
|
// private Log() {}
|
||||||
//
|
//
|
||||||
// public static void print(String data) {
|
// public static void print(String data) {
|
||||||
// if (PRINT_PRINT)
|
// if (PRINT_PRINT)
|
||||||
// Logger.print(LIB_NAME_DRAW, data);
|
// Logger.print(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void todo(String data) {
|
// public static void todo(String data) {
|
||||||
// if (PRINT_TODO)
|
// if (PRINT_TODO)
|
||||||
// Logger.todo(LIB_NAME_DRAW, data);
|
// Logger.todo(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void critical(String data) {
|
// public static void critical(String data) {
|
||||||
// if (PRINT_CRITICAL)
|
// if (PRINT_CRITICAL)
|
||||||
// Logger.critical(LIB_NAME_DRAW, data);
|
// Logger.critical(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void error(String data) {
|
// public static void error(String data) {
|
||||||
// if (PRINT_ERROR)
|
// if (PRINT_ERROR)
|
||||||
// Logger.error(LIB_NAME_DRAW, data);
|
// Logger.error(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void warning(String data) {
|
// public static void warning(String data) {
|
||||||
// if (PRINT_WARNING)
|
// if (PRINT_WARNING)
|
||||||
// Logger.warning(LIB_NAME_DRAW, data);
|
// Logger.warning(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void info(String data) {
|
// public static void info(String data) {
|
||||||
// if (PRINT_INFO)
|
// if (PRINT_INFO)
|
||||||
// Logger.info(LIB_NAME_DRAW, data);
|
// Logger.info(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void debug(String data) {
|
// public static void debug(String data) {
|
||||||
// if (PRINT_DEBUG)
|
// if (PRINT_DEBUG)
|
||||||
// Logger.debug(LIB_NAME_DRAW, data);
|
// Logger.debug(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// public static void verbose(String data) {
|
// public static void verbose(String data) {
|
||||||
// if (PRINT_VERBOSE)
|
// if (PRINT_VERBOSE)
|
||||||
// Logger.verbose(LIB_NAME_DRAW, data);
|
// Logger.verbose(LIB_NAME_DRAW, data);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package org.kar.karideo.migration;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.User;
|
import org.kar.archidata.model.User;
|
||||||
@ -10,12 +11,16 @@ import org.kar.karideo.model.Season;
|
|||||||
import org.kar.karideo.model.Series;
|
import org.kar.karideo.model.Series;
|
||||||
import org.kar.karideo.model.Type;
|
import org.kar.karideo.model.Type;
|
||||||
import org.kar.karideo.model.UserMediaAdvancement;
|
import org.kar.karideo.model.UserMediaAdvancement;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class Initialization extends MigrationSqlStep {
|
public class Initialization extends MigrationSqlStep {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class);
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
public static final List<Class<?>> CLASSES_BASE = List.of(Data.class, Media.class, Type.class, Series.class, Season.class, User.class, UserMediaAdvancement.class);
|
public static final List<Class<?>> CLASSES_BASE = List.of(Data.class, Media.class, Type.class, Series.class, Season.class, User.class, UserMediaAdvancement.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Initialization";
|
return "Initialization";
|
||||||
@ -27,7 +32,7 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
for(final Class<?> clazz : CLASSES_BASE) {
|
for (final Class<?> clazz : CLASSES_BASE) {
|
||||||
addClass(clazz);
|
addClass(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,4 +67,25 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
""", "mysql");
|
""", "mysql");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void dropAll() {
|
||||||
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
|
try {
|
||||||
|
DataAccess.drop(element);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
LOGGER.error("Fail to drop table !!!!!!");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void cleanAll() {
|
||||||
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
|
try {
|
||||||
|
DataAccess.cleanAll(element);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
LOGGER.error("Fail to clean table !!!!!!");
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,25 +4,25 @@ import org.kar.archidata.migration.MigrationSqlStep;
|
|||||||
import org.kar.karideo.model.UserMediaAdvancement;
|
import org.kar.karideo.model.UserMediaAdvancement;
|
||||||
|
|
||||||
public class Migration20230810 extends MigrationSqlStep {
|
public class Migration20230810 extends MigrationSqlStep {
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
public static final int KARSO_INITIALISATION_ID = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "migration-2023-08-10";
|
return "migration-2023-08-10";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Migration20230810() {
|
public Migration20230810() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
addClass(UserMediaAdvancement.class);
|
addClass(UserMediaAdvancement.class);
|
||||||
|
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `userMediaAdvancement` AUTO_INCREMENT = 1000;
|
ALTER TABLE `userMediaAdvancement` AUTO_INCREMENT = 1000;
|
||||||
""");
|
""");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {
|
public void generateStep() throws Exception {
|
||||||
|
|
||||||
// update migration update (last one)
|
// update migration update (last one)
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `KAR_migration`
|
ALTER TABLE `KAR_migration`
|
||||||
|
@ -42,10 +42,10 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
""");
|
""");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
for (final UUIDConversion elem: datas) {
|
for (final UUIDConversion elem : datas) {
|
||||||
elem.uuid = UuidUtils.nextUUID();
|
elem.uuid = UuidUtils.nextUUID();
|
||||||
}
|
}
|
||||||
for (final UUIDConversion elem: datas) {
|
for (final UUIDConversion elem : datas) {
|
||||||
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -53,18 +53,18 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
ALTER TABLE `data` CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
ALTER TABLE `data` CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
||||||
""");
|
""");
|
||||||
final List<String> tableToTransform = List.of("media", "season", "series", "type", "user");
|
final List<String> tableToTransform = List.of("media", "season", "series", "type", "user");
|
||||||
for (final String tableName : tableToTransform ) {
|
for (final String tableName : tableToTransform) {
|
||||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
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"));
|
final List<LinkTableLongLong> links = DataAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
|
||||||
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
||||||
for (final CoverConversion media: medias) {
|
for (final CoverConversion media : medias) {
|
||||||
final List<UUID> values = new ArrayList<>();
|
final List<UUID> values = new ArrayList<>();
|
||||||
for (final LinkTableLongLong link: links) {
|
for (final LinkTableLongLong link : links) {
|
||||||
if (link.object1Id.equals(media.id)) {
|
if (link.object1Id.equals(media.id)) {
|
||||||
for (final UUIDConversion data: datas) {
|
for (final UUIDConversion data : datas) {
|
||||||
if (data.id.equals(link.object2Id)) {
|
if (data.id.equals(link.object2Id)) {
|
||||||
values.add(data.uuid);
|
values.add(data.uuid);
|
||||||
break;
|
break;
|
||||||
@ -88,8 +88,8 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("media"));
|
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("media"));
|
||||||
for (final MediaConversion media: medias) {
|
for (final MediaConversion media : medias) {
|
||||||
for (final UUIDConversion data: datas) {
|
for (final UUIDConversion data : datas) {
|
||||||
if (data.id.equals(media.dataId)) {
|
if (data.id.equals(media.dataId)) {
|
||||||
media.dataUUID = data.uuid;
|
media.dataUUID = data.uuid;
|
||||||
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("media"));
|
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("media"));
|
||||||
@ -107,7 +107,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
// Move the files...
|
// Move the files...
|
||||||
addAction(() -> {
|
addAction(() -> {
|
||||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
for (final UUIDConversion data: datas) {
|
for (final UUIDConversion data : datas) {
|
||||||
final String origin = DataResource.getFileDataOld(data.id);
|
final String origin = DataResource.getFileDataOld(data.id);
|
||||||
final String destination = DataResource.getFileData(data.uuid);
|
final String destination = DataResource.getFileData(data.uuid);
|
||||||
LOGGER.info("move file = {}", origin);
|
LOGGER.info("move file = {}", origin);
|
||||||
@ -119,11 +119,7 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* I am not sure then I prefer keep the primary key for the moment
|
/* I am not sure then I prefer keep the primary key for the moment addAction(""" ALTER TABLE `data` DROP `id`; """); */
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` DROP `id`;
|
|
||||||
""");
|
|
||||||
*/
|
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `data` CHANGE `id` `idOld` bigint NOT NULL DEFAULT 0;
|
ALTER TABLE `data` CHANGE `id` `idOld` bigint NOT NULL DEFAULT 0;
|
||||||
""");
|
""");
|
||||||
|
@ -9,6 +9,7 @@ import org.kar.archidata.model.GenericDataSoftDelete;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
@ -19,43 +20,41 @@ import jakarta.persistence.Table;
|
|||||||
@Table(name = "media")
|
@Table(name = "media")
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
public class Media extends GenericDataSoftDelete {
|
public class Media extends GenericDataSoftDelete {
|
||||||
// Name of the media (this represent the title)
|
@Schema(description = "Name of the media (this represent the title)")
|
||||||
@Column(nullable = false, length = 0)
|
@Column(nullable = false, length = 0)
|
||||||
public String name;
|
public String name;
|
||||||
// Description of the media
|
@Schema(description = "Description of the media")
|
||||||
@Column(length = 0)
|
@Column(length = 0)
|
||||||
public String description;
|
public String description;
|
||||||
// Foreign Key Id of the data
|
@Schema(description = "Foreign Key Id of the data")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
public UUID dataId;
|
public UUID dataId;
|
||||||
// Type of the media")
|
@Schema(description = "Type of the media")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
||||||
public Long typeId;
|
public Long typeId;
|
||||||
// Series reference of the media
|
@Schema(description = "Series reference of the media")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Series.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Series.class)
|
||||||
public Long seriesId;
|
public Long seriesId;
|
||||||
// Season reference of the media
|
@Schema(description = "Season reference of the media")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Season.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Season.class)
|
||||||
public Long seasonId;
|
public Long seasonId;
|
||||||
// Episode Id
|
@Schema(description = "Episode Id")
|
||||||
public Integer episode;
|
public Integer episode;
|
||||||
// ")
|
// ")
|
||||||
public Integer date;
|
public Integer date;
|
||||||
// Creation years of the media
|
@Schema(description = "Creation years of the media")
|
||||||
public Integer time;
|
public Integer time;
|
||||||
// Limitation Age of the media
|
@Schema(description = "Limitation Age of the media")
|
||||||
public Integer ageLimit;
|
public Integer ageLimit;
|
||||||
// List of Id of the specific covers
|
@Schema(description = "List of Id of the specific covers")
|
||||||
@DataJson(targetEntity = Data.class)
|
@DataJson(targetEntity = Data.class)
|
||||||
public List<UUID> covers = null;
|
public List<UUID> covers = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Media [name=" + this.name + ", description=" + this.description + ", dataId=" + this.dataId + ", typeId=" + this.typeId
|
return "Media [name=" + this.name + ", description=" + this.description + ", dataId=" + this.dataId + ", typeId=" + this.typeId + ", seriesId=" + this.seriesId + ", seasonId=" + this.seasonId
|
||||||
+ ", seriesId=" + this.seriesId + ", seasonId=" + this.seasonId + ", episode=" + this.episode + ", date=" + this.date
|
+ ", episode=" + this.episode + ", date=" + this.date + ", time=" + this.time + ", ageLimit=" + this.ageLimit + ", covers=" + this.covers + "]";
|
||||||
+ ", time=" + this.time + ", ageLimit=" + this.ageLimit + ", covers=" + this.covers + "]";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,12 @@ package org.kar.karideo.util;
|
|||||||
|
|
||||||
public class ConfigVariable {
|
public class ConfigVariable {
|
||||||
public static final String BASE_NAME = "ORG_KARIDEO_";
|
public static final String BASE_NAME = "ORG_KARIDEO_";
|
||||||
|
|
||||||
public static String getFrontFolder() {
|
public static String getFrontFolder() {
|
||||||
String out = System.getenv(BASE_NAME + "FRONT_FOLDER");
|
String out = System.getenv(BASE_NAME + "FRONT_FOLDER");
|
||||||
if (out == null) {
|
if (out == null) {
|
||||||
return "/application/front";
|
return "/application/front";
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
public class TestHealthCheck {
|
public class TestHealthCheck {
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestHealthCheck.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(TestHealthCheck.class);
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
static WebLauncherTest webInterface = null;
|
||||||
static RESTApi api = null;
|
static RESTApi api = null;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class TestHealthCheck {
|
|||||||
LOGGER.info("Start REST (DONE)");
|
LOGGER.info("Start REST (DONE)");
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterAll
|
||||||
public static void stopWebServer() throws InterruptedException, IOException {
|
public static void stopWebServer() throws InterruptedException, IOException {
|
||||||
LOGGER.info("Kill the web server");
|
LOGGER.info("Kill the web server");
|
||||||
@ -52,19 +52,19 @@ public class TestHealthCheck {
|
|||||||
DBEntry.closeAllForceMode();
|
DBEntry.closeAllForceMode();
|
||||||
ConfigBaseVariable.clearAllValue();
|
ConfigBaseVariable.clearAllValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(1)
|
@Order(1)
|
||||||
@Test
|
@Test
|
||||||
//@RepeatedTest(10)
|
// @RepeatedTest(10)
|
||||||
public void checkHealthCheck() throws Exception {
|
public void checkHealthCheck() throws Exception {
|
||||||
final HealthResult result = api.get(HealthResult.class, "health_check");
|
final HealthResult result = api.get(HealthResult.class, "health_check");
|
||||||
Assertions.assertEquals(result.value(), "alive and kicking");
|
Assertions.assertEquals(result.value(), "alive and kicking");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Order(2)
|
@Order(2)
|
||||||
@Test
|
@Test
|
||||||
public void checkHealthCheckWrongAPI() throws Exception {
|
public void checkHealthCheckWrongAPI() throws Exception {
|
||||||
Assertions.assertThrows(RESTErrorResponseExeption.class, () -> api.get(HealthResult.class, "health_checks"));
|
Assertions.assertThrows(RESTErrorResponseExeption.class, () -> api.get(HealthResult.class, "health_checks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,21 +8,27 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class WebLauncherTest extends WebLauncher {
|
public class WebLauncherTest extends WebLauncher {
|
||||||
final private static Logger LOGGER = LoggerFactory.getLogger(WebLauncherTest.class);
|
final private static Logger LOGGER = LoggerFactory.getLogger(WebLauncherTest.class);
|
||||||
|
|
||||||
public WebLauncherTest() {
|
public WebLauncherTest() {
|
||||||
LOGGER.debug("Configure REST system");
|
LOGGER.debug("Configure REST system");
|
||||||
// for local test:
|
// for local test:
|
||||||
ConfigBaseVariable.apiAdress = "http://127.0.0.1:12345/test/api/";
|
ConfigBaseVariable.apiAdress = "http://127.0.0.1:12342/test/api/";
|
||||||
|
// Enable the test mode permit to access to the test token (never use it in production).
|
||||||
ConfigBaseVariable.testMode = "true";
|
ConfigBaseVariable.testMode = "true";
|
||||||
//ConfigBaseVariable.dbPort = "3306";
|
|
||||||
// for the test we a in memory sqlite..
|
// for the test we a in memory sqlite..
|
||||||
ConfigBaseVariable.dbType = "sqlite";
|
if (true) {
|
||||||
ConfigBaseVariable.dbHost = "memory";
|
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||||
// for test we need to connect all time the DB
|
ConfigBaseVariable.dbType = "sqlite";
|
||||||
ConfigBaseVariable.dbKeepConnected = "true";
|
ConfigBaseVariable.dbHost = "memory";
|
||||||
|
// for test we need to connect all time the DB
|
||||||
//ConfigBaseVariable.dbHost = "localhost";
|
ConfigBaseVariable.dbKeepConnected = "true";
|
||||||
//ConfigBaseVariable.dbUser = "root";
|
}
|
||||||
//ConfigBaseVariable.dbPassword = "ZERTYSDGFVHSDFGHJYZSDFGSQxfgsqdfgsqdrf4564654";
|
} else {
|
||||||
|
// Enable this if you want to access to a local MySQL base to test with an adminer
|
||||||
|
ConfigBaseVariable.bdDatabase = "test_db";
|
||||||
|
ConfigBaseVariable.dbPort = "3309";
|
||||||
|
ConfigBaseVariable.dbUser = "root";
|
||||||
|
ConfigBaseVariable.dbPassword = "password";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,32 +19,32 @@
|
|||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/animations": "^17.3.5",
|
"@angular/animations": "^18.0.2",
|
||||||
"@angular/cdk": "^17.3.5",
|
"@angular/cdk": "^18.0.2",
|
||||||
"@angular/common": "^17.3.5",
|
"@angular/common": "^18.0.2",
|
||||||
"@angular/compiler": "^17.3.5",
|
"@angular/compiler": "^18.0.2",
|
||||||
"@angular/core": "^17.3.5",
|
"@angular/core": "^18.0.2",
|
||||||
"@angular/forms": "^17.3.5",
|
"@angular/forms": "^18.0.2",
|
||||||
"@angular/material": "^17.3.5",
|
"@angular/material": "^18.0.2",
|
||||||
"@angular/platform-browser": "^17.3.5",
|
"@angular/platform-browser": "^18.0.2",
|
||||||
"@angular/platform-browser-dynamic": "^17.3.5",
|
"@angular/platform-browser-dynamic": "^18.0.2",
|
||||||
"@angular/router": "^17.3.5",
|
"@angular/router": "^18.0.2",
|
||||||
"rxjs": "^7.8.1",
|
"rxjs": "^7.8.1",
|
||||||
"zone.js": "^0.14.4",
|
"zone.js": "^0.14.6",
|
||||||
"zod": "3.23.0",
|
"zod": "3.23.8",
|
||||||
"@kangaroo-and-rabbit/kar-cw": "^0.2.1"
|
"@kangaroo-and-rabbit/kar-cw": "^0.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular-devkit/build-angular": "^17.3.5",
|
"@angular-devkit/build-angular": "^18.0.3",
|
||||||
"@angular-eslint/builder": "17.3.0",
|
"@angular-eslint/builder": "18.0.1",
|
||||||
"@angular-eslint/eslint-plugin": "17.3.0",
|
"@angular-eslint/eslint-plugin": "18.0.1",
|
||||||
"@angular-eslint/eslint-plugin-template": "17.3.0",
|
"@angular-eslint/eslint-plugin-template": "18.0.1",
|
||||||
"@angular-eslint/schematics": "17.3.0",
|
"@angular-eslint/schematics": "18.0.1",
|
||||||
"@angular-eslint/template-parser": "17.3.0",
|
"@angular-eslint/template-parser": "18.0.1",
|
||||||
"@angular/cli": "^17.3.5",
|
"@angular/cli": "^18.0.3",
|
||||||
"@angular/compiler-cli": "^17.3.5",
|
"@angular/compiler-cli": "^18.0.2",
|
||||||
"@angular/language-service": "^17.3.5",
|
"@angular/language-service": "^18.0.2",
|
||||||
"npm-check-updates": "^16.14.18",
|
"npm-check-updates": "^16.14.20",
|
||||||
"tslib": "^2.6.2"
|
"tslib": "^2.6.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,108 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTConfig,
|
||||||
RESTCallbacks,
|
RESTRequestJson,
|
||||||
RESTConfig,
|
RESTRequestVoid,
|
||||||
RESTRequestJson,
|
} from "../rest-tools";
|
||||||
RESTRequestJsonArray,
|
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
|
||||||
import {
|
import {
|
||||||
UUID,
|
UUID,
|
||||||
} from "./model"
|
} from "../model";
|
||||||
|
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
||||||
|
*/
|
||||||
|
export function retrieveDataFull({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
name: string,
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<object> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/{uuid}/{name}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get back some data from the data environment
|
||||||
|
*/
|
||||||
|
export function retrieveDataId({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<object> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/{uuid}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Get a thumbnail of from the data environment (if resize is possible)
|
||||||
|
*/
|
||||||
|
export function retrieveDataThumbnailId({
|
||||||
|
restConfig,
|
||||||
|
queries,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
queries: {
|
||||||
|
Authorization?: string,
|
||||||
|
},
|
||||||
|
params: {
|
||||||
|
uuid: UUID,
|
||||||
|
},
|
||||||
|
data: string,
|
||||||
|
}): Promise<object> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/data/thumbnail/{uuid}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
queries,
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Insert a new data in the data environment
|
* Insert a new data in the data environment
|
||||||
*/
|
*/
|
||||||
@ -38,95 +125,4 @@ export namespace DataResource {
|
|||||||
data,
|
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,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
queries: {
|
|
||||||
Authorization?: string,
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uuid: UUID,
|
|
||||||
},
|
|
||||||
data: string,
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/data/{uuid}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
queries,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 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,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
queries: {
|
|
||||||
Authorization?: string,
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
uuid: UUID,
|
|
||||||
},
|
|
||||||
data: string,
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/data/thumbnail/{uuid}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
queries,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
|
||||||
*/
|
|
||||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
|
||||||
export function retrieveDataFull({
|
|
||||||
restConfig,
|
|
||||||
queries,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
queries: {
|
|
||||||
Authorization?: string,
|
|
||||||
},
|
|
||||||
params: {
|
|
||||||
name: string,
|
|
||||||
uuid: UUID,
|
|
||||||
},
|
|
||||||
data: string,
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/data/{uuid}/{name}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
},
|
|
||||||
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,20 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTConfig,
|
||||||
RESTCallbacks,
|
RESTRequestJson,
|
||||||
RESTConfig,
|
} from "../rest-tools";
|
||||||
RESTRequestJson,
|
|
||||||
RESTRequestJsonArray,
|
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
|
||||||
import {
|
import {
|
||||||
HealthResult,
|
HealthResult,
|
||||||
isHealthResult,
|
isHealthResult,
|
||||||
} from "./model"
|
} from "../model";
|
||||||
|
|
||||||
export namespace HealthCheck {
|
export namespace HealthCheck {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +25,7 @@ export namespace HealthCheck {
|
|||||||
}): Promise<HealthResult> {
|
}): Promise<HealthResult> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/health_check",
|
endPoint: "/health_check/",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
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 "./data-resource"
|
||||||
|
export * from "./front"
|
||||||
|
export * from "./health-check"
|
||||||
|
export * from "./media-resource"
|
||||||
|
export * from "./season-resource"
|
||||||
|
export * from "./series-resource"
|
||||||
|
export * from "./type-resource"
|
||||||
|
export * from "./user-media-advancement-resource"
|
||||||
|
export * from "./user-resource"
|
@ -1,24 +1,106 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTCallbacks,
|
||||||
RESTCallbacks,
|
RESTConfig,
|
||||||
RESTConfig,
|
RESTRequestJson,
|
||||||
RESTRequestJson,
|
RESTRequestVoid,
|
||||||
RESTRequestJsonArray,
|
} from "../rest-tools";
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
Media,
|
Media,
|
||||||
UUID,
|
MediaWrite,
|
||||||
isMedia,
|
UUID,
|
||||||
} from "./model"
|
ZodMedia,
|
||||||
|
isMedia,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace MediaResource {
|
export namespace MediaResource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific Media with his ID
|
||||||
|
*/
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/media/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodMedia);
|
||||||
|
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 Media
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/media/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Modify a specific Media
|
||||||
|
*/
|
||||||
|
export function patch({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
data: MediaWrite,
|
||||||
|
}): Promise<Media> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/media/{id}",
|
||||||
|
requestType: HTTPRequestModel.PATCH,
|
||||||
|
contentType: HTTPMimeType.JSON,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
data,
|
||||||
|
}, isMedia);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Remove a specific Media
|
* Remove a specific Media
|
||||||
*/
|
*/
|
||||||
@ -42,70 +124,29 @@ export namespace MediaResource {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get a specific Media with his ID
|
* Remove a specific cover of a media
|
||||||
*/
|
*/
|
||||||
export function get({
|
export function removeCover({
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
}): Promise<Media> {
|
}): Promise<Media> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/media/{id}",
|
endPoint: "/media/{id}/cover/{coverId}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
}, isMedia);
|
}, isMedia);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Modify a specific Media
|
|
||||||
*/
|
|
||||||
export function patch({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
data: Media,
|
|
||||||
}): Promise<Media> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/media/{id}",
|
|
||||||
requestType: HTTPRequestModel.PATCH,
|
|
||||||
contentType: HTTPMimeType.JSON,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
data,
|
|
||||||
}, isMedia);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Get all Media
|
|
||||||
*/
|
|
||||||
export function gets({
|
|
||||||
restConfig,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<Media[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/media",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isMedia);
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Upload a new season cover media
|
* Upload a new season cover media
|
||||||
*/
|
*/
|
||||||
@ -138,30 +179,6 @@ export namespace MediaResource {
|
|||||||
callback,
|
callback,
|
||||||
}, isMedia);
|
}, isMedia);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Remove a specific cover of a media
|
|
||||||
*/
|
|
||||||
export function removeCover({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: UUID,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Media> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/media/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isMedia);
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Create a new Media
|
* Create a new Media
|
||||||
*/
|
*/
|
||||||
@ -185,7 +202,7 @@ export namespace MediaResource {
|
|||||||
}): Promise<Media> {
|
}): Promise<Media> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/media",
|
endPoint: "/media/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.MULTIPART,
|
contentType: HTTPMimeType.MULTIPART,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
@ -1,46 +1,27 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTCallbacks,
|
||||||
RESTCallbacks,
|
RESTConfig,
|
||||||
RESTConfig,
|
RESTRequestJson,
|
||||||
RESTRequestJson,
|
RESTRequestVoid,
|
||||||
RESTRequestJsonArray,
|
} from "../rest-tools";
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
Season,
|
Season,
|
||||||
UUID,
|
SeasonWrite,
|
||||||
isSeason,
|
UUID,
|
||||||
} from "./model"
|
ZodSeason,
|
||||||
|
isSeason,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace SeasonResource {
|
export namespace SeasonResource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a specific season
|
|
||||||
*/
|
|
||||||
export function remove({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/season/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get all season
|
* Get all season
|
||||||
*/
|
*/
|
||||||
@ -64,6 +45,37 @@ export namespace SeasonResource {
|
|||||||
params,
|
params,
|
||||||
}, isSeason);
|
}, isSeason);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodSeason);
|
||||||
|
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 a specific Season with his ID
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Modify a specific season
|
* Modify a specific season
|
||||||
*/
|
*/
|
||||||
@ -76,7 +88,7 @@ export namespace SeasonResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: Season,
|
data: SeasonWrite,
|
||||||
}): Promise<Season> {
|
}): Promise<Season> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -98,11 +110,11 @@ export namespace SeasonResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: Season,
|
data: SeasonWrite,
|
||||||
}): Promise<Season> {
|
}): Promise<Season> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/season",
|
endPoint: "/season/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
@ -112,20 +124,49 @@ export namespace SeasonResource {
|
|||||||
}, isSeason);
|
}, isSeason);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get a specific Season with his ID
|
* Remove a specific season
|
||||||
*/
|
*/
|
||||||
export function gets({
|
export function remove({
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<Season[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/season",
|
endPoint: "/season/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific cover of a season
|
||||||
|
*/
|
||||||
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Season> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/season/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}, isSeason);
|
}, isSeason);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -160,28 +201,4 @@ export namespace SeasonResource {
|
|||||||
callback,
|
callback,
|
||||||
}, isSeason);
|
}, isSeason);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Remove a specific cover of a season
|
|
||||||
*/
|
|
||||||
export function removeCover({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: UUID,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Season> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/season/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isSeason);
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -1,46 +1,27 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTCallbacks,
|
||||||
RESTCallbacks,
|
RESTConfig,
|
||||||
RESTConfig,
|
RESTRequestJson,
|
||||||
RESTRequestJson,
|
RESTRequestVoid,
|
||||||
RESTRequestJsonArray,
|
} from "../rest-tools";
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
Series,
|
Series,
|
||||||
UUID,
|
SeriesWrite,
|
||||||
isSeries,
|
UUID,
|
||||||
} from "./model"
|
ZodSeries,
|
||||||
|
isSeries,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace SeriesResource {
|
export namespace SeriesResource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a specific Series
|
|
||||||
*/
|
|
||||||
export function remove({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/series/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get a specific Series with his ID
|
* Get a specific Series with his ID
|
||||||
*/
|
*/
|
||||||
@ -64,6 +45,37 @@ export namespace SeriesResource {
|
|||||||
params,
|
params,
|
||||||
}, isSeries);
|
}, isSeries);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodSeries);
|
||||||
|
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 Series
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Modify a specific Series
|
* Modify a specific Series
|
||||||
*/
|
*/
|
||||||
@ -76,7 +88,7 @@ export namespace SeriesResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: Series,
|
data: SeriesWrite,
|
||||||
}): Promise<Series> {
|
}): Promise<Series> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -98,11 +110,11 @@ export namespace SeriesResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: Series,
|
data: SeriesWrite,
|
||||||
}): Promise<Series> {
|
}): Promise<Series> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/series",
|
endPoint: "/series/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
@ -112,20 +124,49 @@ export namespace SeriesResource {
|
|||||||
}, isSeries);
|
}, isSeries);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get all Series
|
* Remove a specific Series
|
||||||
*/
|
*/
|
||||||
export function gets({
|
export function remove({
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<Series[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/series",
|
endPoint: "/series/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific Series of a season
|
||||||
|
*/
|
||||||
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Series> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/series/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}, isSeries);
|
}, isSeries);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -160,28 +201,4 @@ export namespace SeriesResource {
|
|||||||
callback,
|
callback,
|
||||||
}, isSeries);
|
}, isSeries);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Remove a specific Series of a season
|
|
||||||
*/
|
|
||||||
export function removeCover({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: UUID,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Series> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/series/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isSeries);
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -1,46 +1,27 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTCallbacks,
|
||||||
RESTCallbacks,
|
RESTConfig,
|
||||||
RESTConfig,
|
RESTRequestJson,
|
||||||
RESTRequestJson,
|
RESTRequestVoid,
|
||||||
RESTRequestJsonArray,
|
} from "../rest-tools";
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
import { z as zod } from "zod"
|
||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
Type,
|
Type,
|
||||||
UUID,
|
TypeWrite,
|
||||||
isType,
|
UUID,
|
||||||
} from "./model"
|
ZodType,
|
||||||
|
isType,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace TypeResource {
|
export namespace TypeResource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a specific Type
|
|
||||||
*/
|
|
||||||
export function remove({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/type/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get a specific Type with his ID
|
* Get a specific Type with his ID
|
||||||
*/
|
*/
|
||||||
@ -64,6 +45,37 @@ export namespace TypeResource {
|
|||||||
params,
|
params,
|
||||||
}, isType);
|
}, isType);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodType);
|
||||||
|
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 Type
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Modify a specific Type
|
* Modify a specific Type
|
||||||
*/
|
*/
|
||||||
@ -76,7 +88,7 @@ export namespace TypeResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: Type,
|
data: TypeWrite,
|
||||||
}): Promise<Type> {
|
}): Promise<Type> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -98,11 +110,11 @@ export namespace TypeResource {
|
|||||||
data,
|
data,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: Type,
|
data: TypeWrite,
|
||||||
}): Promise<Type> {
|
}): Promise<Type> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/type",
|
endPoint: "/type/",
|
||||||
requestType: HTTPRequestModel.POST,
|
requestType: HTTPRequestModel.POST,
|
||||||
contentType: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.JSON,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
@ -112,20 +124,49 @@ export namespace TypeResource {
|
|||||||
}, isType);
|
}, isType);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get all Type
|
* Remove a specific Type
|
||||||
*/
|
*/
|
||||||
export function gets({
|
export function remove({
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<Type[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/type",
|
endPoint: "/type/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Remove a specific cover of a type
|
||||||
|
*/
|
||||||
|
export function removeCover({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
coverId: UUID,
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<Type> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/type/{id}/cover/{coverId}",
|
||||||
|
requestType: HTTPRequestModel.DELETE,
|
||||||
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}, isType);
|
}, isType);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -160,28 +201,4 @@ export namespace TypeResource {
|
|||||||
callback,
|
callback,
|
||||||
}, isType);
|
}, isType);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Remove a specific cover of a type
|
|
||||||
*/
|
|
||||||
export function removeCover({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
coverId: UUID,
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<Type> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/type/{id}/cover/{coverId}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isType);
|
|
||||||
};
|
|
||||||
}
|
}
|
@ -1,46 +1,25 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTConfig,
|
||||||
RESTCallbacks,
|
RESTRequestJson,
|
||||||
RESTConfig,
|
RESTRequestVoid,
|
||||||
RESTRequestJson,
|
} from "../rest-tools";
|
||||||
RESTRequestJsonArray,
|
|
||||||
RESTRequestVoid
|
import { z as zod } from "zod"
|
||||||
} from "./rest-tools"
|
|
||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
MediaInformationsDelta,
|
MediaInformationsDeltaWrite,
|
||||||
UserMediaAdvancement,
|
UserMediaAdvancement,
|
||||||
isUserMediaAdvancement,
|
ZodUserMediaAdvancement,
|
||||||
} from "./model"
|
isUserMediaAdvancement,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace UserMediaAdvancementResource {
|
export namespace UserMediaAdvancementResource {
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a specific user advancement
|
|
||||||
*/
|
|
||||||
export function remove({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<void> {
|
|
||||||
return RESTRequestVoid({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/advancement/{id}",
|
|
||||||
requestType: HTTPRequestModel.DELETE,
|
|
||||||
contentType: HTTPMimeType.TEXT_PLAIN,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get a specific user advancement with his ID
|
* Get a specific user advancement with his ID
|
||||||
*/
|
*/
|
||||||
@ -63,6 +42,37 @@ export namespace UserMediaAdvancementResource {
|
|||||||
params,
|
params,
|
||||||
}, isUserMediaAdvancement);
|
}, isUserMediaAdvancement);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodUserMediaAdvancement);
|
||||||
|
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 user advancement
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/advancement/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* Modify a user advancement
|
* Modify a user advancement
|
||||||
*/
|
*/
|
||||||
@ -75,7 +85,7 @@ export namespace UserMediaAdvancementResource {
|
|||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: MediaInformationsDelta,
|
data: MediaInformationsDeltaWrite,
|
||||||
}): Promise<UserMediaAdvancement> {
|
}): Promise<UserMediaAdvancement> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -90,20 +100,25 @@ export namespace UserMediaAdvancementResource {
|
|||||||
}, isUserMediaAdvancement);
|
}, isUserMediaAdvancement);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Get all user advancement
|
* Remove a specific user advancement
|
||||||
*/
|
*/
|
||||||
export function gets({
|
export function remove({
|
||||||
restConfig,
|
restConfig,
|
||||||
|
params,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<UserMediaAdvancement[]> {
|
params: {
|
||||||
return RESTRequestJsonArray({
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<void> {
|
||||||
|
return RESTRequestVoid({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/advancement",
|
endPoint: "/advancement/{id}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.DELETE,
|
||||||
accept: HTTPMimeType.JSON,
|
contentType: HTTPMimeType.TEXT_PLAIN,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isUserMediaAdvancement);
|
params,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,23 +1,23 @@
|
|||||||
/**
|
/**
|
||||||
* API of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
HTTPMimeType,
|
HTTPMimeType,
|
||||||
HTTPRequestModel,
|
HTTPRequestModel,
|
||||||
ModelResponseHttp,
|
RESTConfig,
|
||||||
RESTCallbacks,
|
RESTRequestJson,
|
||||||
RESTConfig,
|
} from "../rest-tools";
|
||||||
RESTRequestJson,
|
|
||||||
RESTRequestJsonArray,
|
import { z as zod } from "zod"
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
|
||||||
import {
|
import {
|
||||||
Long,
|
Long,
|
||||||
UserKarideo,
|
UserKarideo,
|
||||||
UserOut,
|
UserOut,
|
||||||
isUserKarideo,
|
ZodUserKarideo,
|
||||||
isUserOut,
|
isUserKarideo,
|
||||||
} from "./model"
|
isUserOut,
|
||||||
|
} from "../model";
|
||||||
|
|
||||||
export namespace UserResource {
|
export namespace UserResource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,23 +42,6 @@ export namespace UserResource {
|
|||||||
params,
|
params,
|
||||||
}, isUserKarideo);
|
}, isUserKarideo);
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* Get all the users
|
|
||||||
*/
|
|
||||||
export function gets({
|
|
||||||
restConfig,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
}): Promise<UserKarideo[]> {
|
|
||||||
return RESTRequestJsonArray({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
}, isUserKarideo);
|
|
||||||
};
|
|
||||||
/**
|
/**
|
||||||
* Get the user personal data
|
* Get the user personal data
|
||||||
*/
|
*/
|
||||||
@ -76,4 +59,35 @@ export namespace UserResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
}, isUserOut);
|
}, isUserOut);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ZodGetsTypeReturn = zod.array(ZodUserKarideo);
|
||||||
|
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 users
|
||||||
|
*/
|
||||||
|
export function gets({
|
||||||
|
restConfig,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
}): Promise<GetsTypeReturn> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
}, isGetsTypeReturn);
|
||||||
|
};
|
||||||
}
|
}
|
@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* API of the server (auto-generated code)
|
|
||||||
*/
|
|
||||||
import {
|
|
||||||
HTTPMimeType,
|
|
||||||
HTTPRequestModel,
|
|
||||||
ModelResponseHttp,
|
|
||||||
RESTCallbacks,
|
|
||||||
RESTConfig,
|
|
||||||
RESTRequestJson,
|
|
||||||
RESTRequestJsonArray,
|
|
||||||
RESTRequestVoid
|
|
||||||
} from "./rest-tools"
|
|
||||||
import {
|
|
||||||
} from "./model"
|
|
||||||
export namespace Front {
|
|
||||||
|
|
||||||
}
|
|
@ -1,13 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Global import of the package
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
export * from "./model";
|
export * from "./model";
|
||||||
export * from "./front";
|
export * from "./api";
|
||||||
export * from "./health-check";
|
export * from "./rest-tools";
|
||||||
export * from "./season-resource";
|
|
||||||
export * from "./series-resource";
|
|
||||||
export * from "./type-resource";
|
|
||||||
export * from "./user-media-advancement-resource";
|
|
||||||
export * from "./user-resource";
|
|
||||||
export * from "./media-resource";
|
|
||||||
export * from "./data-resource";
|
|
||||||
|
@ -1,435 +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(),
|
|
||||||
name: zod.string().max(255).optional(),
|
|
||||||
message: zod.string().max(255).optional(),
|
|
||||||
time: 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 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 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 ZodSeason = ZodGenericDataSoftDelete.extend({
|
|
||||||
// Name of the media (this represent the title)
|
|
||||||
name: zod.string().optional(),
|
|
||||||
// Description of the media
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// series parent ID
|
|
||||||
parentId: ZodLong.optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(ZodUUID).optional()
|
|
||||||
});
|
|
||||||
export type Season = zod.infer<typeof ZodSeason>;
|
|
||||||
export function isSeason(data: any): data is Season {
|
|
||||||
try {
|
|
||||||
ZodSeason.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
|
||||||
// Name of the media (this represent the title)
|
|
||||||
name: zod.string().optional(),
|
|
||||||
// Description of the media
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// series parent ID
|
|
||||||
parentId: ZodLong.optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(ZodUUID).optional()
|
|
||||||
});
|
|
||||||
export type Series = zod.infer<typeof ZodSeries>;
|
|
||||||
export function isSeries(data: any): data is Series {
|
|
||||||
try {
|
|
||||||
ZodSeries.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodType = ZodGenericDataSoftDelete.extend({
|
|
||||||
// Name of the media (this represent the title)
|
|
||||||
name: zod.string().optional(),
|
|
||||||
// Description of the media
|
|
||||||
description: zod.string().optional(),
|
|
||||||
// List of Id of the specific covers
|
|
||||||
covers: zod.array(ZodUUID).optional()
|
|
||||||
});
|
|
||||||
export type Type = zod.infer<typeof ZodType>;
|
|
||||||
export function isType(data: any): data is Type {
|
|
||||||
try {
|
|
||||||
ZodType.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
|
|
||||||
// Foreign Key Id of the user
|
|
||||||
userId: ZodLong.optional(),
|
|
||||||
// Id of the media
|
|
||||||
mediaId: ZodLong.optional(),
|
|
||||||
// Percent of advancement in the media
|
|
||||||
percent: ZodFloat.optional(),
|
|
||||||
// Number of second of advancement in the media
|
|
||||||
time: ZodInteger.optional(),
|
|
||||||
// Number of time this media has been read
|
|
||||||
count: ZodInteger.optional()
|
|
||||||
});
|
|
||||||
export type UserMediaAdvancement = zod.infer<typeof ZodUserMediaAdvancement>;
|
|
||||||
export function isUserMediaAdvancement(data: any): data is UserMediaAdvancement {
|
|
||||||
try {
|
|
||||||
ZodUserMediaAdvancement.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data ${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const ZodMediaInformationsDelta = zod.object({
|
|
||||||
});
|
|
||||||
export type MediaInformationsDelta = zod.infer<typeof ZodMediaInformationsDelta>;
|
|
||||||
export function isMediaInformationsDelta(data: any): data is MediaInformationsDelta {
|
|
||||||
try {
|
|
||||||
ZodMediaInformationsDelta.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 ZodUserKarideo = ZodUser.extend({
|
|
||||||
});
|
|
||||||
export type UserKarideo = zod.infer<typeof ZodUserKarideo>;
|
|
||||||
export function isUserKarideo(data: any): data is UserKarideo {
|
|
||||||
try {
|
|
||||||
ZodUserKarideo.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 ZodMedia = ZodGenericDataSoftDelete.extend({
|
|
||||||
name: zod.string().optional(),
|
|
||||||
description: zod.string().optional(),
|
|
||||||
dataId: ZodUUID.optional(),
|
|
||||||
typeId: ZodLong.optional(),
|
|
||||||
seriesId: ZodLong.optional(),
|
|
||||||
seasonId: ZodLong.optional(),
|
|
||||||
episode: ZodInteger.optional(),
|
|
||||||
date: ZodInteger.optional(),
|
|
||||||
time: ZodInteger.optional(),
|
|
||||||
ageLimit: ZodInteger.optional(),
|
|
||||||
covers: zod.array(ZodUUID).optional()
|
|
||||||
});
|
|
||||||
export type Media = zod.infer<typeof ZodMedia>;
|
|
||||||
export function isMedia(data: any): data is Media {
|
|
||||||
try {
|
|
||||||
ZodMedia.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
|
|
||||||
uuid: 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
8
front/src/app/back-api/model/float.ts
Normal file
8
front/src/app/back-api/model/float.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodFloat = zod.number();
|
||||||
|
export type Float = zod.infer<typeof ZodFloat>;
|
46
front/src/app/back-api/model/generic-data-soft-delete.ts
Normal file
46
front/src/app/back-api/model/generic-data-soft-delete.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodGenericData} 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 = ZodGenericDataSoftDelete.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
46
front/src/app/back-api/model/generic-data.ts
Normal file
46
front/src/app/back-api/model/generic-data.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodGenericTiming} 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 = ZodGenericData.omit({
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
48
front/src/app/back-api/model/generic-timing.ts
Normal file
48
front/src/app/back-api/model/generic-timing.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* 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 = ZodGenericTiming.omit({
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
35
front/src/app/back-api/model/health-result.ts
Normal file
35
front/src/app/back-api/model/health-result.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* 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 = ZodHealthResult.partial();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
24
front/src/app/back-api/model/index.ts
Normal file
24
front/src/app/back-api/model/index.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
export * from "./float"
|
||||||
|
export * from "./generic-data"
|
||||||
|
export * from "./generic-data-soft-delete"
|
||||||
|
export * from "./generic-timing"
|
||||||
|
export * from "./health-result"
|
||||||
|
export * from "./int"
|
||||||
|
export * from "./integer"
|
||||||
|
export * from "./iso-date"
|
||||||
|
export * from "./long"
|
||||||
|
export * from "./media"
|
||||||
|
export * from "./media-informations-delta"
|
||||||
|
export * from "./rest-error-response"
|
||||||
|
export * from "./season"
|
||||||
|
export * from "./series"
|
||||||
|
export * from "./timestamp"
|
||||||
|
export * from "./type"
|
||||||
|
export * from "./user"
|
||||||
|
export * from "./user-karideo"
|
||||||
|
export * from "./user-media-advancement"
|
||||||
|
export * from "./user-out"
|
||||||
|
export * from "./uuid"
|
35
front/src/app/back-api/model/int.ts
Normal file
35
front/src/app/back-api/model/int.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* 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 = Zodint.partial();
|
||||||
|
|
||||||
|
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/integer.ts
Normal file
8
front/src/app/back-api/model/integer.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodInteger = zod.number().safe();
|
||||||
|
export type Integer = zod.infer<typeof ZodInteger>;
|
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/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>;
|
35
front/src/app/back-api/model/media-informations-delta.ts
Normal file
35
front/src/app/back-api/model/media-informations-delta.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodMediaInformationsDelta = zod.object({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type MediaInformationsDelta = zod.infer<typeof ZodMediaInformationsDelta>;
|
||||||
|
|
||||||
|
export function isMediaInformationsDelta(data: any): data is MediaInformationsDelta {
|
||||||
|
try {
|
||||||
|
ZodMediaInformationsDelta.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodMediaInformationsDelta' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodMediaInformationsDeltaWrite = ZodMediaInformationsDelta.partial();
|
||||||
|
|
||||||
|
export type MediaInformationsDeltaWrite = zod.infer<typeof ZodMediaInformationsDeltaWrite>;
|
||||||
|
|
||||||
|
export function isMediaInformationsDeltaWrite(data: any): data is MediaInformationsDeltaWrite {
|
||||||
|
try {
|
||||||
|
ZodMediaInformationsDeltaWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodMediaInformationsDeltaWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
86
front/src/app/back-api/model/media.ts
Normal file
86
front/src/app/back-api/model/media.ts
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodInteger} from "./integer";
|
||||||
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
||||||
|
/**
|
||||||
|
* Name of the media (this represent the title)
|
||||||
|
*/
|
||||||
|
name: zod.string(),
|
||||||
|
/**
|
||||||
|
* Description of the media
|
||||||
|
*/
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* Foreign Key Id of the data
|
||||||
|
*/
|
||||||
|
dataId: ZodUUID,
|
||||||
|
/**
|
||||||
|
* Type of the media
|
||||||
|
*/
|
||||||
|
typeId: ZodLong.optional(),
|
||||||
|
/**
|
||||||
|
* Series reference of the media
|
||||||
|
*/
|
||||||
|
seriesId: ZodLong.optional(),
|
||||||
|
/**
|
||||||
|
* Season reference of the media
|
||||||
|
*/
|
||||||
|
seasonId: ZodLong.optional(),
|
||||||
|
/**
|
||||||
|
* Episode Id
|
||||||
|
*/
|
||||||
|
episode: ZodInteger.optional(),
|
||||||
|
date: ZodInteger.optional(),
|
||||||
|
/**
|
||||||
|
* Creation years of the media
|
||||||
|
*/
|
||||||
|
time: ZodInteger.optional(),
|
||||||
|
/**
|
||||||
|
* Limitation Age of the media
|
||||||
|
*/
|
||||||
|
ageLimit: ZodInteger.optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Media = zod.infer<typeof ZodMedia>;
|
||||||
|
|
||||||
|
export function isMedia(data: any): data is Media {
|
||||||
|
try {
|
||||||
|
ZodMedia.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodMedia' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodMediaWrite = ZodMedia.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
export type MediaWrite = zod.infer<typeof ZodMediaWrite>;
|
||||||
|
|
||||||
|
export function isMediaWrite(data: any): data is MediaWrite {
|
||||||
|
try {
|
||||||
|
ZodMediaWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodMediaWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
43
front/src/app/back-api/model/rest-error-response.ts
Normal file
43
front/src/app/back-api/model/rest-error-response.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {Zodint} 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodRestErrorResponseWrite = ZodRestErrorResponse.partial();
|
||||||
|
|
||||||
|
export type RestErrorResponseWrite = zod.infer<typeof ZodRestErrorResponseWrite>;
|
||||||
|
|
||||||
|
export function isRestErrorResponseWrite(data: any): data is RestErrorResponseWrite {
|
||||||
|
try {
|
||||||
|
ZodRestErrorResponseWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodRestErrorResponseWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
60
front/src/app/back-api/model/season.ts
Normal file
60
front/src/app/back-api/model/season.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodSeason = ZodGenericDataSoftDelete.extend({
|
||||||
|
/**
|
||||||
|
* Name of the media (this represent the title)
|
||||||
|
*/
|
||||||
|
name: zod.string(),
|
||||||
|
/**
|
||||||
|
* Description of the media
|
||||||
|
*/
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* series parent ID
|
||||||
|
*/
|
||||||
|
parentId: ZodLong,
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Season = zod.infer<typeof ZodSeason>;
|
||||||
|
|
||||||
|
export function isSeason(data: any): data is Season {
|
||||||
|
try {
|
||||||
|
ZodSeason.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodSeason' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodSeasonWrite = ZodSeason.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
export type SeasonWrite = zod.infer<typeof ZodSeasonWrite>;
|
||||||
|
|
||||||
|
export function isSeasonWrite(data: any): data is SeasonWrite {
|
||||||
|
try {
|
||||||
|
ZodSeasonWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodSeasonWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
60
front/src/app/back-api/model/series.ts
Normal file
60
front/src/app/back-api/model/series.ts
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
||||||
|
/**
|
||||||
|
* Name of the media (this represent the title)
|
||||||
|
*/
|
||||||
|
name: zod.string(),
|
||||||
|
/**
|
||||||
|
* Description of the media
|
||||||
|
*/
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* series parent ID
|
||||||
|
*/
|
||||||
|
parentId: ZodLong,
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Series = zod.infer<typeof ZodSeries>;
|
||||||
|
|
||||||
|
export function isSeries(data: any): data is Series {
|
||||||
|
try {
|
||||||
|
ZodSeries.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodSeries' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodSeriesWrite = ZodSeries.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
export type SeriesWrite = zod.infer<typeof ZodSeriesWrite>;
|
||||||
|
|
||||||
|
export function isSeriesWrite(data: any): data is SeriesWrite {
|
||||||
|
try {
|
||||||
|
ZodSeriesWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodSeriesWrite' 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>;
|
55
front/src/app/back-api/model/type.ts
Normal file
55
front/src/app/back-api/model/type.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodType = ZodGenericDataSoftDelete.extend({
|
||||||
|
/**
|
||||||
|
* Name of the media (this represent the title)
|
||||||
|
*/
|
||||||
|
name: zod.string(),
|
||||||
|
/**
|
||||||
|
* Description of the media
|
||||||
|
*/
|
||||||
|
description: zod.string().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Type = zod.infer<typeof ZodType>;
|
||||||
|
|
||||||
|
export function isType(data: any): data is Type {
|
||||||
|
try {
|
||||||
|
ZodType.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodType' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodTypeWrite = ZodType.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
export type TypeWrite = zod.infer<typeof ZodTypeWrite>;
|
||||||
|
|
||||||
|
export function isTypeWrite(data: any): data is TypeWrite {
|
||||||
|
try {
|
||||||
|
ZodTypeWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodTypeWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
42
front/src/app/back-api/model/user-karideo.ts
Normal file
42
front/src/app/back-api/model/user-karideo.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodUser} from "./user";
|
||||||
|
|
||||||
|
export const ZodUserKarideo = ZodUser.extend({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserKarideo = zod.infer<typeof ZodUserKarideo>;
|
||||||
|
|
||||||
|
export function isUserKarideo(data: any): data is UserKarideo {
|
||||||
|
try {
|
||||||
|
ZodUserKarideo.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserKarideo' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodUserKarideoWrite = ZodUserKarideo.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
export type UserKarideoWrite = zod.infer<typeof ZodUserKarideoWrite>;
|
||||||
|
|
||||||
|
export function isUserKarideoWrite(data: any): data is UserKarideoWrite {
|
||||||
|
try {
|
||||||
|
ZodUserKarideoWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserKarideoWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
65
front/src/app/back-api/model/user-media-advancement.ts
Normal file
65
front/src/app/back-api/model/user-media-advancement.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodLong} from "./long";
|
||||||
|
import {ZodFloat} from "./float";
|
||||||
|
import {ZodInteger} from "./integer";
|
||||||
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
|
export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
|
||||||
|
/**
|
||||||
|
* Foreign Key Id of the user
|
||||||
|
*/
|
||||||
|
userId: ZodLong,
|
||||||
|
/**
|
||||||
|
* Id of the media
|
||||||
|
*/
|
||||||
|
mediaId: ZodLong,
|
||||||
|
/**
|
||||||
|
* Percent of advancement in the media
|
||||||
|
*/
|
||||||
|
percent: ZodFloat,
|
||||||
|
/**
|
||||||
|
* Number of second of advancement in the media
|
||||||
|
*/
|
||||||
|
time: ZodInteger,
|
||||||
|
/**
|
||||||
|
* Number of time this media has been read
|
||||||
|
*/
|
||||||
|
count: ZodInteger,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UserMediaAdvancement = zod.infer<typeof ZodUserMediaAdvancement>;
|
||||||
|
|
||||||
|
export function isUserMediaAdvancement(data: any): data is UserMediaAdvancement {
|
||||||
|
try {
|
||||||
|
ZodUserMediaAdvancement.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserMediaAdvancement' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ZodUserMediaAdvancementWrite = ZodUserMediaAdvancement.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
export type UserMediaAdvancementWrite = zod.infer<typeof ZodUserMediaAdvancementWrite>;
|
||||||
|
|
||||||
|
export function isUserMediaAdvancementWrite(data: any): data is UserMediaAdvancementWrite {
|
||||||
|
try {
|
||||||
|
ZodUserMediaAdvancementWrite.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodUserMediaAdvancementWrite' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
38
front/src/app/back-api/model/user-out.ts
Normal file
38
front/src/app/back-api/model/user-out.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* 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 = ZodUserOut.partial();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
53
front/src/app/back-api/model/user.ts
Normal file
53
front/src/app/back-api/model/user.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
import {ZodTimestamp} from "./timestamp";
|
||||||
|
import {ZodUUID} from "./uuid";
|
||||||
|
import {ZodGenericDataSoftDelete} 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 = ZodUser.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
|
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,374 +4,442 @@
|
|||||||
* @license MPL-2
|
* @license MPL-2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RestErrorResponse } from "./model"
|
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||||
|
|
||||||
export enum HTTPRequestModel {
|
export enum HTTPRequestModel {
|
||||||
DELETE = 'DELETE',
|
DELETE = "DELETE",
|
||||||
GET = 'GET',
|
GET = "GET",
|
||||||
PATCH = 'PATCH',
|
PATCH = "PATCH",
|
||||||
POST = 'POST',
|
POST = "POST",
|
||||||
PUT = 'PUT',
|
PUT = "PUT",
|
||||||
}
|
}
|
||||||
export enum HTTPMimeType {
|
export enum HTTPMimeType {
|
||||||
ALL = '*/*',
|
ALL = "*/*",
|
||||||
CSV = 'text/csv',
|
CSV = "text/csv",
|
||||||
IMAGE = 'image/*',
|
IMAGE = "image/*",
|
||||||
IMAGE_JPEG = 'image/jpeg',
|
IMAGE_JPEG = "image/jpeg",
|
||||||
IMAGE_PNG = 'image/png',
|
IMAGE_PNG = "image/png",
|
||||||
JSON = 'application/json',
|
JSON = "application/json",
|
||||||
MULTIPART = 'multipart/form-data',
|
MULTIPART = "multipart/form-data",
|
||||||
OCTET_STREAM = 'application/octet-stream',
|
OCTET_STREAM = "application/octet-stream",
|
||||||
TEXT_PLAIN = 'text/plain',
|
TEXT_PLAIN = "text/plain",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTConfig {
|
export interface RESTConfig {
|
||||||
// base of the server: http(s)://my.server.org/plop/api/
|
// base of the server: http(s)://my.server.org/plop/api/
|
||||||
server: string;
|
server: string;
|
||||||
// Token to access of the data.
|
// Token to access of the data.
|
||||||
token?: string;
|
token?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RESTModel {
|
export interface RESTModel {
|
||||||
// base of the local API request: "sheep/{id}".
|
// base of the local API request: "sheep/{id}".
|
||||||
endPoint: string;
|
endPoint: string;
|
||||||
// Type of the request.
|
// Type of the request.
|
||||||
requestType?: HTTPRequestModel;
|
requestType?: HTTPRequestModel;
|
||||||
// Input type requested.
|
// Input type requested.
|
||||||
accept?: HTTPMimeType;
|
accept?: HTTPMimeType;
|
||||||
// Content of the local data.
|
// Content of the local data.
|
||||||
contentType?: HTTPMimeType;
|
contentType?: HTTPMimeType;
|
||||||
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||||
tokenInUrl?: boolean;
|
tokenInUrl?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModelResponseHttp {
|
export interface ModelResponseHttp {
|
||||||
status: number;
|
status: number;
|
||||||
data: any;
|
data: any;
|
||||||
}
|
|
||||||
|
|
||||||
export function isArrayOf<TYPE>(
|
|
||||||
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 {
|
function isNullOrUndefined(data: any): data is undefined | null {
|
||||||
return data === undefined || data === null;
|
return data === undefined || data === null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generic progression callback
|
// generic progression callback
|
||||||
export type ProgressCallback = (count: number, total: number) => void;
|
export type ProgressCallback = (count: number, total: number) => void;
|
||||||
|
|
||||||
export interface RESTAbort {
|
export interface RESTAbort {
|
||||||
abort?: () => boolean
|
abort?: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Rest generic callback have a basic model to upload and download advancement.
|
// Rest generic callback have a basic model to upload and download advancement.
|
||||||
export interface RESTCallbacks {
|
export interface RESTCallbacks {
|
||||||
progressUpload?: ProgressCallback,
|
progressUpload?: ProgressCallback;
|
||||||
progressDownload?: ProgressCallback,
|
progressDownload?: ProgressCallback;
|
||||||
abortHandle?: RESTAbort,
|
abortHandle?: RESTAbort;
|
||||||
};
|
}
|
||||||
|
|
||||||
export interface RESTRequestType {
|
export interface RESTRequestType {
|
||||||
restModel: RESTModel,
|
restModel: RESTModel;
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig;
|
||||||
data?: any,
|
data?: any;
|
||||||
params?: object,
|
params?: object;
|
||||||
queries?: object,
|
queries?: object;
|
||||||
callback?: RESTCallbacks,
|
callback?: RESTCallbacks;
|
||||||
};
|
}
|
||||||
|
|
||||||
function replaceAll(input, searchValue, replaceValue) {
|
function replaceAll(input, searchValue, replaceValue) {
|
||||||
return input.split(searchValue).join(replaceValue);
|
return input.split(searchValue).join(replaceValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeTrailingSlashes(input: string): string {
|
function removeTrailingSlashes(input: string): string {
|
||||||
if (isNullOrUndefined(input)) {
|
if (isNullOrUndefined(input)) {
|
||||||
return "undefined";
|
return "undefined";
|
||||||
}
|
}
|
||||||
return input.replace(/\/+$/, '');
|
return input.replace(/\/+$/, "");
|
||||||
}
|
}
|
||||||
function removeLeadingSlashes(input: string): string {
|
function removeLeadingSlashes(input: string): string {
|
||||||
if (isNullOrUndefined(input)) {
|
if (isNullOrUndefined(input)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return input.replace(/^\/+/, '');
|
return input.replace(/^\/+/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestType): string {
|
export function RESTUrl({
|
||||||
// Create the URL PATH:
|
restModel,
|
||||||
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
restConfig,
|
||||||
if (params !== undefined) {
|
params,
|
||||||
for (let key of Object.keys(params)) {
|
queries,
|
||||||
generateUrl = replaceAll(generateUrl, `{${key}}`, `${params[key]}`);
|
}: RESTRequestType): string {
|
||||||
|
// Create the URL PATH:
|
||||||
|
let generateUrl = `${removeTrailingSlashes(
|
||||||
|
restConfig.server
|
||||||
|
)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||||
|
if (params !== undefined) {
|
||||||
|
for (let key of Object.keys(params)) {
|
||||||
|
generateUrl = replaceAll(generateUrl, `{${key}}`, `${params[key]}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
queries === undefined &&
|
||||||
|
(restConfig.token === undefined || restModel.tokenInUrl !== true)
|
||||||
|
) {
|
||||||
|
return generateUrl;
|
||||||
|
}
|
||||||
|
const searchParams = new URLSearchParams();
|
||||||
|
if (queries !== undefined) {
|
||||||
|
for (let key of Object.keys(queries)) {
|
||||||
|
const value = queries[key];
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
for (const element of value) {
|
||||||
|
searchParams.append(`${key}`, `${element}`);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
searchParams.append(`${key}`, `${value}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
}
|
||||||
return generateUrl;
|
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||||
}
|
searchParams.append("Authorization", `Bearer ${restConfig.token}`);
|
||||||
const searchParams = new URLSearchParams();
|
}
|
||||||
if (queries !== undefined) {
|
return generateUrl + "?" + searchParams.toString();
|
||||||
for (let key of Object.keys(queries)) {
|
|
||||||
const value = queries[key];
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
for (let iii = 0; iii < value.length; iii++) {
|
|
||||||
searchParams.append(`${key}`, `${value[iii]}`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
searchParams.append(`${key}`, `${value}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
|
||||||
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
|
|
||||||
}
|
|
||||||
return generateUrl + "?" + searchParams.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchProgress(
|
||||||
export function fetchProgress(generateUrl: string, { method, headers, body }: {
|
generateUrl: string,
|
||||||
method: HTTPRequestModel,
|
{
|
||||||
headers: any,
|
method,
|
||||||
body: any,
|
headers,
|
||||||
}, { progressUpload, progressDownload, abortHandle }: RESTCallbacks): Promise<Response> {
|
body,
|
||||||
const xhr = {
|
}: {
|
||||||
io: new XMLHttpRequest()
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return new Promise((resolve, reject) => {
|
// Stream the download progress
|
||||||
// Stream the upload progress
|
if (progressDownload) {
|
||||||
if (progressUpload) {
|
xhr.io?.addEventListener("progress", (dataEvent) => {
|
||||||
xhr.io.upload.addEventListener("progress", (dataEvent) => {
|
if (dataEvent.lengthComputable) {
|
||||||
if (dataEvent.lengthComputable) {
|
progressDownload(dataEvent.loaded, dataEvent.total);
|
||||||
//console.log(` ==> has a progress event: ${dataEvent.loaded} / ${dataEvent.total}`);
|
|
||||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// Stream the download progress
|
});
|
||||||
if (progressDownload) {
|
}
|
||||||
xhr.io.addEventListener("progress", (dataEvent) => {
|
if (abortHandle) {
|
||||||
if (dataEvent.lengthComputable) {
|
abortHandle.abort = () => {
|
||||||
//console.log(` ==> download progress:: ${dataEvent.loaded} / ${dataEvent.total}`);
|
if (xhr.io) {
|
||||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||||
}
|
xhr.io.abort();
|
||||||
});
|
return true;
|
||||||
}
|
}
|
||||||
if (abortHandle) {
|
console.log(
|
||||||
abortHandle.abort = () => {
|
`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`
|
||||||
if (xhr.io) {
|
);
|
||||||
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
return false;
|
||||||
xhr.io.abort();
|
};
|
||||||
return true;
|
}
|
||||||
}
|
// Check if we have an internal Fail:
|
||||||
console.log(`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`);
|
xhr.io?.addEventListener("error", () => {
|
||||||
return false;
|
xhr.io = undefined;
|
||||||
}
|
reject(new TypeError("Failed to fetch"));
|
||||||
}
|
|
||||||
// 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) {
|
|
||||||
//console.log(` ==> READY state`);
|
|
||||||
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) {
|
|
||||||
var key = header.substring(0, firstColonIndex).trim();
|
|
||||||
var 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);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 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, callback }: RESTRequestType): Promise<ModelResponseHttp> {
|
export function RESTRequest({
|
||||||
// Create the URL PATH:
|
restModel,
|
||||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
restConfig,
|
||||||
let headers: any = {};
|
data,
|
||||||
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
params,
|
||||||
headers['Authorization'] = `Bearer ${restConfig.token}`;
|
queries,
|
||||||
|
callback,
|
||||||
|
}: 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;
|
||||||
}
|
}
|
||||||
if (restModel.accept !== undefined) {
|
}
|
||||||
headers['Accept'] = restModel.accept;
|
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]);
|
||||||
}
|
}
|
||||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
body = formData;
|
||||||
// if Get we have not a content type, the body is empty
|
}
|
||||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
return new Promise((resolve, reject) => {
|
||||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
let action: undefined | Promise<Response> = undefined;
|
||||||
headers['Content-Type'] = restModel.contentType;
|
if (
|
||||||
}
|
isNullOrUndefined(callback) ||
|
||||||
|
(isNullOrUndefined(callback.progressDownload) &&
|
||||||
|
isNullOrUndefined(callback.progressUpload) &&
|
||||||
|
isNullOrUndefined(callback.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,
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let body = data;
|
action
|
||||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
.then((response: Response) => {
|
||||||
body = JSON.stringify(data);
|
if (response.status >= 200 && response.status <= 299) {
|
||||||
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
const contentType = response.headers.get("Content-Type");
|
||||||
const formData = new FormData();
|
if (
|
||||||
for (const name in data) {
|
!isNullOrUndefined(restModel.accept) &&
|
||||||
formData.append(name, data[name]);
|
restModel.accept !== contentType
|
||||||
}
|
) {
|
||||||
body = formData
|
reject({
|
||||||
}
|
name: "Model accept type incompatible",
|
||||||
return new Promise((resolve, reject) => {
|
time: Date().toString(),
|
||||||
let action: undefined | Promise<Response> = undefined;
|
status: 901,
|
||||||
if (isNullOrUndefined(callback)
|
message: `REST Content type are not compatible: ${restModel.accept} != ${contentType}`,
|
||||||
|| (isNullOrUndefined(callback.progressDownload)
|
statusMessage: "Fetch error",
|
||||||
&& isNullOrUndefined(callback.progressUpload)
|
error: "rest-tools.ts Wrong type in the message return type",
|
||||||
&& isNullOrUndefined(callback.abortHandle))) {
|
} as RestErrorResponse);
|
||||||
// No information needed: call the generic fetch interface
|
} else if (contentType === HTTPMimeType.JSON) {
|
||||||
action = fetch(generateUrl, {
|
response
|
||||||
method: restModel.requestType,
|
.json()
|
||||||
headers,
|
.then((value: any) => {
|
||||||
body,
|
resolve({ status: response.status, data: value });
|
||||||
});
|
})
|
||||||
} else {
|
.catch((reason: Error) => {
|
||||||
// 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,
|
|
||||||
}, callback);
|
|
||||||
}
|
|
||||||
action.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 {
|
|
||||||
reject({
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 902,
|
||||||
|
message: `REST parse json fail: ${reason}`,
|
||||||
|
statusMessage: "Fetch parse error",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolve({ status: response.status, data: response.body });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// the answer is not correct not a 2XX
|
||||||
|
// clone the response to keep the raw data if case of error:
|
||||||
|
response
|
||||||
|
.clone()
|
||||||
|
.json()
|
||||||
|
.then((value: any) => {
|
||||||
|
if (isRestErrorResponse(value)) {
|
||||||
|
reject(value);
|
||||||
|
} else {
|
||||||
|
response
|
||||||
|
.text()
|
||||||
|
.then((dataError: string) => {
|
||||||
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: 903,
|
||||||
|
message: `REST parse error json with wrong type fail. ${dataError}`,
|
||||||
|
statusMessage: "Fetch parse error",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
})
|
||||||
|
.catch((reason: any) => {
|
||||||
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
|
time: Date().toString(),
|
||||||
|
status: response.status,
|
||||||
|
message: `unmanaged error model: ??? with error: ${reason}`,
|
||||||
|
statusMessage: "Fetch ERROR parse error",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((reason: Error) => {
|
||||||
|
response
|
||||||
|
.text()
|
||||||
|
.then((dataError: string) => {
|
||||||
|
reject({
|
||||||
|
name: "API serialization error",
|
||||||
time: Date().toString(),
|
time: Date().toString(),
|
||||||
status: response.status,
|
status: response.status,
|
||||||
error: `${response.body}`,
|
message: `unmanaged error model: ${dataError} with error: ${reason}`,
|
||||||
statusMessage: "Fetch code error",
|
statusMessage: "Fetch ERROR TEXT parse error",
|
||||||
message: "rest-tools.ts Wrong return code"
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
} as RestErrorResponse);
|
} as RestErrorResponse);
|
||||||
}
|
})
|
||||||
}).catch((error: any) => {
|
.catch((reason: any) => {
|
||||||
reject({
|
reject({
|
||||||
time: Date(),
|
name: "API serialization error",
|
||||||
status: 999,
|
time: Date().toString(),
|
||||||
error: error,
|
status: response.status,
|
||||||
statusMessage: "Fetch catch error",
|
message: `unmanaged error model: ??? with error: ${reason}`,
|
||||||
message: "rest-tools.ts detect an error in the fetch request"
|
statusMessage: "Fetch ERROR TEXT FAIL",
|
||||||
|
error: "rest-tools.ts Wrong message model to parse",
|
||||||
|
} as RestErrorResponse);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
})
|
||||||
|
.catch((error: Error) => {
|
||||||
|
if (isRestErrorResponse(error)) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
reject({
|
||||||
|
name: "Request fail",
|
||||||
|
time: Date(),
|
||||||
|
status: 999,
|
||||||
|
message: error,
|
||||||
|
statusMessage: "Fetch catch error",
|
||||||
|
error: "rest-tools.ts detect an error in the fetch request",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function RESTRequestJson<TYPE>(
|
||||||
|
request: RESTRequestType,
|
||||||
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
checker?: (data: any) => data is TYPE
|
||||||
return new Promise((resolve, reject) => {
|
): Promise<TYPE> {
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (checker(value.data)) {
|
RESTRequest(request)
|
||||||
resolve(value.data);
|
.then((value: ModelResponseHttp) => {
|
||||||
} else {
|
if (isNullOrUndefined(checker)) {
|
||||||
reject({
|
console.log(`Have no check of MODEL in API: ${RESTUrl(request)}`);
|
||||||
time: Date().toString(),
|
resolve(value.data);
|
||||||
status: 950,
|
} else if (checker === undefined || checker(value.data)) {
|
||||||
error: "REST Fail to verify the data",
|
resolve(value.data);
|
||||||
statusMessage: "API cast ERROR",
|
} else {
|
||||||
message: "api.ts Check type as fail"
|
reject({
|
||||||
} as RestErrorResponse);
|
name: "Model check fail",
|
||||||
}
|
time: Date().toString(),
|
||||||
}).catch((reason: RestErrorResponse) => {
|
status: 950,
|
||||||
reject(reason);
|
error: "REST Fail to verify the data",
|
||||||
});
|
statusMessage: "API cast ERROR",
|
||||||
});
|
message: "api.ts Check type as fail",
|
||||||
}
|
} as RestErrorResponse);
|
||||||
export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
}
|
||||||
return new Promise((resolve, reject) => {
|
})
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
.catch((reason: RestErrorResponse) => {
|
||||||
if (isArrayOf(value.data, checker)) {
|
reject(reason);
|
||||||
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 RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
RESTRequest(request)
|
||||||
resolve();
|
.then((value: ModelResponseHttp) => {
|
||||||
}).catch((reason: RestErrorResponse) => {
|
resolve();
|
||||||
reject(reason);
|
})
|
||||||
});
|
.catch((reason: RestErrorResponse) => {
|
||||||
});
|
reject(reason);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
import { Environment } from "@kangaroo-and-rabbit/kar-cw";
|
||||||
|
|
||||||
const serverSSOAddress = 'http://atria-soft.org'
|
const serverBaseAddress = 'http://atria-soft.org'
|
||||||
|
const serverSSOAddress = `${serverBaseAddress}/karso`
|
||||||
|
//const serverSSOAddress = 'http://localhost:4200'
|
||||||
|
|
||||||
const environment_back_prod: Environment = {
|
const environment_back_prod: Environment = {
|
||||||
production: false,
|
production: false,
|
||||||
@ -13,13 +15,13 @@ const environment_back_prod: Environment = {
|
|||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
defaultServer: "karideo",
|
defaultServer: "karideo",
|
||||||
server: {
|
server: {
|
||||||
karideo: `${serverSSOAddress}/karideo/api`,
|
karideo: `${serverBaseAddress}/karideo/api`,
|
||||||
karso: `${serverSSOAddress}/karso/api`,
|
karso: `${serverSSOAddress}/api`,
|
||||||
},
|
},
|
||||||
ssoSite: `${serverSSOAddress}/karso/`,
|
ssoSite: `${serverSSOAddress}/`,
|
||||||
ssoSignIn: `${serverSSOAddress}/karso/signin/karideo-dev/`,
|
ssoSignIn: `${serverSSOAddress}/signin/karideo-dev/`,
|
||||||
ssoSignUp: `${serverSSOAddress}/karso/signup/karideo-dev/`,
|
ssoSignUp: `${serverSSOAddress}/signup/karideo-dev/`,
|
||||||
ssoSignOut: `${serverSSOAddress}/karso/signout/karideo-dev/`,
|
ssoSignOut: `${serverSSOAddress}/signout/karideo-dev/`,
|
||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -30,12 +32,12 @@ const environment_local: Environment = {
|
|||||||
defaultServer: "karideo",
|
defaultServer: "karideo",
|
||||||
server: {
|
server: {
|
||||||
karideo: 'http://localhost:18080/karideo/api',
|
karideo: 'http://localhost:18080/karideo/api',
|
||||||
karso: `${serverSSOAddress}/karso/api`,
|
karso: `${serverSSOAddress}/api`,
|
||||||
},
|
},
|
||||||
ssoSite: `${serverSSOAddress}/karso/`,
|
ssoSite: `${serverSSOAddress}/`,
|
||||||
ssoSignIn: `${serverSSOAddress}/karso/signin/karideo-dev/`,
|
ssoSignIn: `${serverSSOAddress}/signin/karideo-dev/`,
|
||||||
ssoSignUp: `${serverSSOAddress}/karso/signup/karideo-dev/`,
|
ssoSignUp: `${serverSSOAddress}/signup/karideo-dev/`,
|
||||||
ssoSignOut: `${serverSSOAddress}/karso/signout/karideo-dev/`,
|
ssoSignOut: `${serverSSOAddress}/signout/karideo-dev/`,
|
||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
replaceDataToRealServer: true,
|
replaceDataToRealServer: true,
|
||||||
};
|
};
|
||||||
@ -46,13 +48,13 @@ const environment_hybrid: Environment = {
|
|||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
defaultServer: "karideo",
|
defaultServer: "karideo",
|
||||||
server: {
|
server: {
|
||||||
karideo: `${serverSSOAddress}/karideo/api`,
|
karideo: `${serverBaseAddress}/karideo/api`,
|
||||||
karso: `${serverSSOAddress}/karso/api`,
|
karso: `${serverSSOAddress}/api`,
|
||||||
},
|
},
|
||||||
ssoSite: `${serverSSOAddress}/karso/`,
|
ssoSite: `${serverSSOAddress}/`,
|
||||||
ssoSignIn: `${serverSSOAddress}/karso/signin/karideo-dev/`,
|
ssoSignIn: `${serverSSOAddress}/signin/karideo-dev/`,
|
||||||
ssoSignUp: `${serverSSOAddress}/karso/signup/karideo-dev/`,
|
ssoSignUp: `${serverSSOAddress}/signup/karideo-dev/`,
|
||||||
ssoSignOut: `${serverSSOAddress}/karso/signout/karideo-dev/`,
|
ssoSignOut: `${serverSSOAddress}/signout/karideo-dev/`,
|
||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user