Compare commits
No commits in common. "86fec254aa607370381b8c2f2342eba45dfcc465" and "1fc1b5d35d569fb5ca090722e603180e7ae2a995" have entirely different histories.
86fec254aa
...
1fc1b5d35d
@ -1,8 +1,7 @@
|
|||||||
FROM maven:3-openjdk-23 AS build
|
FROM maven:3.6.3-openjdk-16 AS build
|
||||||
|
|
||||||
COPY pom.xml /tmp/
|
COPY pom.xml /tmp/
|
||||||
COPY src /tmp/src/
|
COPY src /tmp/src/
|
||||||
COPY Formatter.xml /tmp/
|
|
||||||
WORKDIR /tmp/
|
WORKDIR /tmp/
|
||||||
RUN mvn clean compile assembly:single
|
RUN mvn clean compile assembly:single
|
||||||
|
|
||||||
|
153
back/pom.xml
153
back/pom.xml
@ -5,9 +5,9 @@
|
|||||||
<artifactId>karideo</artifactId>
|
<artifactId>karideo</artifactId>
|
||||||
<version>0.3.0</version>
|
<version>0.3.0</version>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.version>3.13.0</maven.compiler.version>
|
<maven.compiler.version>3.1</maven.compiler.version>
|
||||||
<maven.compiler.source>23</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<maven.compiler.target>23</maven.compiler.target>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
<maven.dependency.version>3.1.1</maven.dependency.version>
|
||||||
</properties>
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
@ -20,34 +20,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>kangaroo-and-rabbit</groupId>
|
<groupId>kangaroo-and-rabbit</groupId>
|
||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.23.7-SNAPSHOT</version>
|
<version>0.12.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Loopback of logger JDK logging API to SLF4J -->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>jul-to-slf4j</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
<version>2.0.9</version>
|
<version>2.1.0-alpha1</version>
|
||||||
</dependency>
|
|
||||||
<!-- generic logger of SLF4J to console (in color) -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>1.4.11</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>xerces</groupId>
|
|
||||||
<artifactId>xercesImpl</artifactId>
|
|
||||||
<version>2.12.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.codehaus.janino</groupId>
|
|
||||||
<artifactId>janino</artifactId>
|
|
||||||
<version>3.1.9</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.18.1</version>
|
<version>2.17.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
************************************************************
|
************************************************************
|
||||||
@ -57,24 +40,24 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
<version>5.11.0</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.11.0</version>
|
<version>5.11.0-M2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.revelc.code.formatter</groupId>
|
<groupId>net.revelc.code.formatter</groupId>
|
||||||
<artifactId>formatter-maven-plugin</artifactId>
|
<artifactId>formatter-maven-plugin</artifactId>
|
||||||
<version>2.24.1</version>
|
<version>2.24.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
@ -104,45 +87,16 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>1.4.0</version>
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>prod-mode</id>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>org.kar.karideo.WebLauncher</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>dev-mode</id>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>org.kar.karideo.WebLauncherLocal</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<id>generate-api</id>
|
|
||||||
<goals>
|
|
||||||
<goal>java</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<mainClass>org.kar.karideo.GenerateApi</mainClass>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<mainClass/>
|
<mainClass>org.kar.karideo.WebLauncher</mainClass>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Create the source bundle -->
|
<!-- Create the source bundle -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>4.0.0-beta-1</version>
|
<version>3.2.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
@ -156,12 +110,10 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.2.5</version>
|
<version>3.0.0-M5</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
<version>3.7.1</version>
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
@ -173,21 +125,80 @@
|
|||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<!-- Create coverage -->
|
||||||
|
<!--
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.8.10</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>prepare-agent</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>report</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>jacoco-check</id>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<element>PACKAGE</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>LINE</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>0.50</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
-->
|
||||||
<!-- Java-doc generation for stand-alone site -->
|
<!-- Java-doc generation for stand-alone site -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>private</show>
|
<show>private</show>
|
||||||
<nohelp>true</nohelp>
|
<nohelp>true</nohelp>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Check the style of the code -->
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>exec-application</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>java</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>org.kar.karideo.WebLauncher</mainClass>
|
||||||
|
</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.24.1</version>
|
<version>2.23.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<encoding>UTF-8</encoding>
|
<encoding>UTF-8</encoding>
|
||||||
<lineEnding>LF</lineEnding>
|
<lineEnding>LF</lineEnding>
|
||||||
@ -218,6 +229,14 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
|
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
|
||||||
<excludeFilterFile>spotbugs-security-exclude.xml</excludeFilterFile>
|
<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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -228,7 +247,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.3.0</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<show>public</show>
|
<show>public</show>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
package org.kar.karideo;
|
|
||||||
|
|
||||||
import org.kar.karideo.migration.Initialization;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class GenerateApi {
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(GenerateApi.class);
|
|
||||||
|
|
||||||
private GenerateApi() {}
|
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
|
||||||
LOGGER.info("Generate API");
|
|
||||||
Initialization.generateObjects();
|
|
||||||
LOGGER.info("STOP the REST server.");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +1,21 @@
|
|||||||
package org.kar.karideo;
|
package org.kar.karideo;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.logging.LogManager;
|
|
||||||
|
|
||||||
import org.glassfish.grizzly.http.server.HttpServer;
|
import org.glassfish.grizzly.http.server.HttpServer;
|
||||||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
||||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
|
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.GenericCatcher;
|
import org.kar.archidata.catcher.GenericCatcher;
|
||||||
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;
|
||||||
import org.kar.archidata.migration.MigrationEngine;
|
import org.kar.archidata.migration.MigrationEngine;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.archidata.tools.ContextGenericTools;
|
|
||||||
import org.kar.karideo.api.Front;
|
import org.kar.karideo.api.Front;
|
||||||
import org.kar.karideo.api.HealthCheck;
|
import org.kar.karideo.api.HealthCheck;
|
||||||
import org.kar.karideo.api.MediaResource;
|
import org.kar.karideo.api.MediaResource;
|
||||||
@ -31,16 +30,14 @@ import org.kar.karideo.migration.Migration20230810;
|
|||||||
import org.kar.karideo.migration.Migration20231015;
|
import org.kar.karideo.migration.Migration20231015;
|
||||||
import org.kar.karideo.migration.Migration20231126;
|
import org.kar.karideo.migration.Migration20231126;
|
||||||
import org.kar.karideo.migration.Migration20240226;
|
import org.kar.karideo.migration.Migration20240226;
|
||||||
import org.kar.karideo.migration.Migration20240611;
|
|
||||||
import org.kar.karideo.migration.Migration20250214;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.core.UriBuilder;
|
import jakarta.ws.rs.core.UriBuilder;
|
||||||
|
|
||||||
public class WebLauncher {
|
public class WebLauncher {
|
||||||
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||||
|
public static DBConfig dbConfig;
|
||||||
protected UpdateJwtPublicKey keyUpdater = null;
|
protected UpdateJwtPublicKey keyUpdater = null;
|
||||||
protected HttpServer server = null;
|
protected HttpServer server = null;
|
||||||
|
|
||||||
@ -62,18 +59,12 @@ public class WebLauncher {
|
|||||||
migrationEngine.add(new Migration20231015());
|
migrationEngine.add(new Migration20231015());
|
||||||
migrationEngine.add(new Migration20231126());
|
migrationEngine.add(new Migration20231126());
|
||||||
migrationEngine.add(new Migration20240226());
|
migrationEngine.add(new Migration20240226());
|
||||||
migrationEngine.add(new Migration20240611());
|
|
||||||
migrationEngine.add(new Migration20250214());
|
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||||
migrationEngine.migrateWaitAdmin(new DbConfig());
|
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(final String[] args) throws Exception {
|
public static void main(final String[] args) throws Exception {
|
||||||
// Loop-back of logger JDK logging API to SLF4J
|
|
||||||
LogManager.getLogManager().reset();
|
|
||||||
SLF4JBridgeHandler.install();
|
|
||||||
|
|
||||||
WebLauncher.LOGGER.info("[START] application wake UP");
|
WebLauncher.LOGGER.info("[START] application wake UP");
|
||||||
final WebLauncher launcher = new WebLauncher();
|
final WebLauncher launcher = new WebLauncher();
|
||||||
launcher.migrateDB();
|
launcher.migrateDB();
|
||||||
@ -113,7 +104,7 @@ public class WebLauncher {
|
|||||||
|
|
||||||
rc.register(HealthCheck.class);
|
rc.register(HealthCheck.class);
|
||||||
rc.register(Front.class);
|
rc.register(Front.class);
|
||||||
ContextGenericTools.addJsr310(rc);
|
|
||||||
// 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
|
||||||
|
@ -1,25 +1,40 @@
|
|||||||
|
|
||||||
package org.kar.karideo;
|
package org.kar.karideo;
|
||||||
|
|
||||||
import java.util.logging.LogManager;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
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.migration.Initialization;
|
import org.kar.karideo.api.Front;
|
||||||
|
import org.kar.karideo.api.HealthCheck;
|
||||||
|
import org.kar.karideo.api.MediaResource;
|
||||||
|
import org.kar.karideo.api.SeasonResource;
|
||||||
|
import org.kar.karideo.api.SeriesResource;
|
||||||
|
import org.kar.karideo.api.TypeResource;
|
||||||
|
import org.kar.karideo.api.UserMediaAdvancementResource;
|
||||||
|
import org.kar.karideo.api.UserResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
|
||||||
|
|
||||||
public class WebLauncherLocal extends WebLauncher {
|
public class WebLauncherLocal extends WebLauncher {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
|
private final static Logger LOGGER = LoggerFactory.getLogger(WebLauncherLocal.class);
|
||||||
|
|
||||||
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 {
|
||||||
// Loop-back of logger JDK logging API to SLF4J
|
generateObjects();
|
||||||
LogManager.getLogManager().reset();
|
|
||||||
SLF4JBridgeHandler.install();
|
|
||||||
// Generate the APIs in type-script
|
|
||||||
Initialization.generateObjects();
|
|
||||||
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:");
|
||||||
@ -33,7 +48,6 @@ public class WebLauncherLocal extends WebLauncher {
|
|||||||
// for local test:
|
// for local test:
|
||||||
ConfigBaseVariable.apiAdress = "http://0.0.0.0:18080/karideo/api/";
|
ConfigBaseVariable.apiAdress = "http://0.0.0.0:18080/karideo/api/";
|
||||||
ConfigBaseVariable.dbPort = "3906";
|
ConfigBaseVariable.dbPort = "3906";
|
||||||
ConfigBaseVariable.testMode = "true";
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
super.migrateDB();
|
super.migrateDB();
|
||||||
|
@ -11,9 +11,8 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
|||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.api.DataResource;
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.addOnSQL.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.exception.FailException;
|
import org.kar.archidata.exception.FailException;
|
||||||
import org.kar.archidata.exception.InputException;
|
import org.kar.archidata.exception.InputException;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
@ -98,7 +97,7 @@ public class MediaResource {
|
|||||||
@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 (DBAccess db = DBAccess.createInterface()) {
|
try {
|
||||||
// correct input string stream :
|
// correct input string stream :
|
||||||
fileName = multipartCorrection(fileName);
|
fileName = multipartCorrection(fileName);
|
||||||
universe = multipartCorrection(universe);
|
universe = multipartCorrection(universe);
|
||||||
@ -126,12 +125,12 @@ public class MediaResource {
|
|||||||
|
|
||||||
final long tmpUID = DataResource.getTmpDataId();
|
final long tmpUID = DataResource.getTmpDataId();
|
||||||
final String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID);
|
final String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID);
|
||||||
Data data = DataTools.getWithSha512(db, sha512);
|
Data data = DataResource.getWithSha512(sha512);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
LOGGER.info("Need to add the data in the BDD ... ");
|
LOGGER.info("Need to add the data in the BDD ... ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
try {
|
try {
|
||||||
data = DataTools.createNewData(db, tmpUID, fileName, sha512);
|
data = DataResource.createNewData(tmpUID, fileName, sha512);
|
||||||
} catch (final IOException ex) {
|
} catch (final IOException ex) {
|
||||||
DataResource.removeTemporaryFile(tmpUID);
|
DataResource.removeTemporaryFile(tmpUID);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -140,7 +139,7 @@ public class MediaResource {
|
|||||||
} 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(db, data.oid);
|
DataTools.undelete(data.uuid);
|
||||||
data.deleted = false;
|
data.deleted = false;
|
||||||
} else {
|
} else {
|
||||||
LOGGER.info("Data already exist ... all good");
|
LOGGER.info("Data already exist ... all good");
|
||||||
@ -180,7 +179,7 @@ public class MediaResource {
|
|||||||
try {
|
try {
|
||||||
final Media media = new Media();
|
final Media media = new Media();
|
||||||
media.name = title;
|
media.name = title;
|
||||||
media.dataId = data.oid;
|
media.dataId = data.uuid;
|
||||||
media.typeId = typeNode.id;
|
media.typeId = typeNode.id;
|
||||||
media.seriesId = null;
|
media.seriesId = null;
|
||||||
if (seriesNode != null) {
|
if (seriesNode != null) {
|
||||||
@ -194,7 +193,7 @@ public class MediaResource {
|
|||||||
if (episode != null && !episode.contentEquals("")) {
|
if (episode != null && !episode.contentEquals("")) {
|
||||||
media.episode = Integer.parseInt(episode);
|
media.episode = Integer.parseInt(episode);
|
||||||
}
|
}
|
||||||
final Media out = db.insert(media);
|
final Media out = DataAccess.insert(media);
|
||||||
LOGGER.info("Generate new media {}", out);
|
LOGGER.info("Generate new media {}", out);
|
||||||
return out;
|
return out;
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
@ -220,13 +219,12 @@ public class MediaResource {
|
|||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Media uploadCover( //
|
public Media uploadCover( //
|
||||||
@PathParam("id") final Long id, //
|
@PathParam("id") final Long id, //
|
||||||
|
@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 {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
DataTools.uploadCover(dbIo, Media.class, id, fileInputStream, fileMetaData);
|
return DataAccess.get(Media.class, id);
|
||||||
return dbIo.get(Media.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@ -237,10 +235,8 @@ public class MediaResource {
|
|||||||
@PathParam("id") final Long id, //
|
@PathParam("id") final Long id, //
|
||||||
@PathParam("coverId") final UUID coverId //
|
@PathParam("coverId") final UUID coverId //
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
AddOnDataJson.removeLink(Media.class, id, "covers", coverId);
|
||||||
AddOnDataJson.removeLink(dbIo, Media.class, "id", id, "covers", coverId);
|
return DataAccess.get(Media.class, id);
|
||||||
return dbIo.get(Media.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
|
@ -8,11 +8,10 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
|||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOnSQL.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karideo.model.Season;
|
import org.kar.karideo.model.Season;
|
||||||
@ -86,12 +85,10 @@ public class SeasonResource {
|
|||||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||||
@Operation(description = "Upload a new season cover season", tags = "GLOBAL")
|
@Operation(description = "Upload a new season cover season", tags = "GLOBAL")
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Season uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
|
public Season uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
throws Exception {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
DataTools.uploadCover(dbIo, Season.class, id, fileInputStream, fileMetaData);
|
return DataAccess.get(Season.class, id);
|
||||||
return dbIo.get(Season.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@ -99,10 +96,8 @@ public class SeasonResource {
|
|||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a specific cover of a season", tags = "GLOBAL")
|
@Operation(description = "Remove a specific cover of a season", tags = "GLOBAL")
|
||||||
public Season removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Season removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
AddOnDataJson.removeLink(Season.class, id, "covers", coverId);
|
||||||
AddOnDataJson.removeLink(dbIo, Season.class, "id", id, "covers", coverId);
|
return DataAccess.get(Season.class, id);
|
||||||
return dbIo.get(Season.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Season getOrCreate(final String name, final Long seriesId) {
|
public static Season getOrCreate(final String name, final Long seriesId) {
|
||||||
|
@ -8,11 +8,10 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
|||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryAnd;
|
import org.kar.archidata.dataAccess.QueryAnd;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOnSQL.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karideo.model.Series;
|
import org.kar.karideo.model.Series;
|
||||||
@ -86,12 +85,10 @@ public class SeriesResource {
|
|||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@Operation(description = "Upload a new season cover Series", tags = "GLOBAL")
|
@Operation(description = "Upload a new season cover Series", tags = "GLOBAL")
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Series uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
|
public Series uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
throws Exception {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
DataTools.uploadCover(dbIo, Series.class, id, fileInputStream, fileMetaData);
|
return DataAccess.get(Series.class, id);
|
||||||
return dbIo.get(Series.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@ -99,10 +96,8 @@ public class SeriesResource {
|
|||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a specific Series of a season", tags = "GLOBAL")
|
@Operation(description = "Remove a specific Series of a season", tags = "GLOBAL")
|
||||||
public Series removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Series removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
AddOnDataJson.removeLink(Series.class, id, "covers", coverId);
|
||||||
AddOnDataJson.removeLink(dbIo, Series.class, "id", id, "covers", coverId);
|
return DataAccess.get(Series.class, id);
|
||||||
return dbIo.get(Series.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Series getOrCreate(final String name, final Long typeId) {
|
public static Series getOrCreate(final String name, final Long typeId) {
|
||||||
|
@ -8,10 +8,9 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
|||||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||||
import org.kar.archidata.annotation.AsyncType;
|
import org.kar.archidata.annotation.AsyncType;
|
||||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.dataAccess.DataAccess;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.QueryCondition;
|
import org.kar.archidata.dataAccess.QueryCondition;
|
||||||
import org.kar.archidata.dataAccess.addOnSQL.AddOnDataJson;
|
import org.kar.archidata.dataAccess.addOn.AddOnDataJson;
|
||||||
import org.kar.archidata.dataAccess.options.Condition;
|
import org.kar.archidata.dataAccess.options.Condition;
|
||||||
import org.kar.archidata.tools.DataTools;
|
import org.kar.archidata.tools.DataTools;
|
||||||
import org.kar.karideo.model.Type;
|
import org.kar.karideo.model.Type;
|
||||||
@ -89,12 +88,10 @@ public class TypeResource {
|
|||||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||||
@Operation(description = "Upload a new season cover Type", tags = "GLOBAL")
|
@Operation(description = "Upload a new season cover Type", tags = "GLOBAL")
|
||||||
@TypeScriptProgress
|
@TypeScriptProgress
|
||||||
public Type uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
|
public Type uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||||
throws Exception {
|
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||||
DataTools.uploadCover(dbIo, Type.class, id, fileInputStream, fileMetaData);
|
return DataAccess.get(Type.class, id);
|
||||||
return dbIo.get(Type.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DELETE
|
@DELETE
|
||||||
@ -102,11 +99,8 @@ public class TypeResource {
|
|||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
@Operation(description = "Remove a specific cover of a type", tags = "GLOBAL")
|
@Operation(description = "Remove a specific cover of a type", tags = "GLOBAL")
|
||||||
public Type removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
public Type removeCover(@PathParam("id") final Long id, @PathParam("coverId") final UUID coverId) throws Exception {
|
||||||
|
AddOnDataJson.removeLink(Type.class, id, "covers", coverId);
|
||||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
return DataAccess.get(Type.class, id);
|
||||||
AddOnDataJson.removeLink(dbIo, Type.class, "id", id, "covers", coverId);
|
|
||||||
return dbIo.get(Type.class, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Type getOrCreate(final String name) {
|
public static Type getOrCreate(final String name) {
|
||||||
|
@ -90,7 +90,7 @@ public class UserMediaAdvancementResource {
|
|||||||
elem.count++;
|
elem.count++;
|
||||||
}
|
}
|
||||||
LOGGER.info("{},{},{}", elem.time, elem.percent, elem.count);
|
LOGGER.info("{},{},{}", elem.time, elem.percent, elem.count);
|
||||||
final long nbAfected = DataAccess.update(elem, elem.id, List.of("time", "percent", "count"));
|
final int nbAfected = DataAccess.update(elem, elem.id, List.of("time", "percent", "count"));
|
||||||
return DataAccess.get(UserMediaAdvancement.class, elem.id);
|
return DataAccess.get(UserMediaAdvancement.class, elem.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,22 +2,10 @@ package org.kar.karideo.migration;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.kar.archidata.api.DataResource;
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.externalRestApi.AnalyzeApi;
|
|
||||||
import org.kar.archidata.externalRestApi.TsGenerateApi;
|
|
||||||
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;
|
||||||
import org.kar.archidata.model.token.JwtToken;
|
|
||||||
import org.kar.karideo.api.Front;
|
|
||||||
import org.kar.karideo.api.HealthCheck;
|
|
||||||
import org.kar.karideo.api.MediaResource;
|
|
||||||
import org.kar.karideo.api.SeasonResource;
|
|
||||||
import org.kar.karideo.api.SeriesResource;
|
|
||||||
import org.kar.karideo.api.TypeResource;
|
|
||||||
import org.kar.karideo.api.UserMediaAdvancementResource;
|
|
||||||
import org.kar.karideo.api.UserResource;
|
|
||||||
import org.kar.karideo.model.Media;
|
import org.kar.karideo.model.Media;
|
||||||
import org.kar.karideo.model.Season;
|
import org.kar.karideo.model.Season;
|
||||||
import org.kar.karideo.model.Series;
|
import org.kar.karideo.model.Series;
|
||||||
@ -28,50 +16,39 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
public class Initialization extends MigrationSqlStep {
|
public class Initialization extends MigrationSqlStep {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class);
|
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,
|
public static final List<Class<?>> CLASSES_BASE = List.of(Data.class, Media.class, Type.class, Series.class, Season.class, User.class, UserMediaAdvancement.class);
|
||||||
Season.class, User.class, UserMediaAdvancement.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Initialization";
|
return "Initialization";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generateObjects() throws Exception {
|
public Initialization() {
|
||||||
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);
|
|
||||||
api.addModel(JwtToken.class);
|
|
||||||
TsGenerateApi.generateApi(api, "../front/src/back-api/");
|
|
||||||
LOGGER.info("Generate APIs (DONE)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
addAction((final DBAccess da) -> {
|
addAction("""
|
||||||
final List<Type> data = List.of(//
|
INSERT INTO `type` (`id`, `name`, `description`) VALUES
|
||||||
new Type("Documentary", "Documentary (animals, space, earth...)"), //
|
(UUID_TO_BIN('15237fd7-d4ee-11ee-a8dd-02420a030203'), 'Documentary', 'Documentary (animals, space, earth...)'),
|
||||||
new Type("Movie", "Movie with real humans (film)"), //
|
(UUID_TO_BIN('553146c1-d4ee-11ee-a8dd-02420a030203'), 'Movie', 'Movie with real humans (film)'),
|
||||||
new Type("Animation", "Animation movies (film)"), //
|
(UUID_TO_BIN('59c430a3-d4ee-11ee-a8dd-02420a030203'), 'Animation', 'Animation movies (film)'),
|
||||||
new Type("Short movie", "Small movies (less 2 minutes)"), //
|
(UUID_TO_BIN('5cd619e3-d4ee-11ee-a8dd-02420a030203'), 'Short movie', 'Small movies (less 2 minutes)'),
|
||||||
new Type("TV show", "TV show for old peoples"), //
|
(UUID_TO_BIN('5fbbf085-d4ee-11ee-a8dd-02420a030203'), 'TV show', 'TV show for old peoples'),
|
||||||
new Type("Animation TV show", "TV show for young peoples"), //
|
(UUID_TO_BIN('66dcb6ba-d4ee-11ee-a8dd-02420a030203'), 'Animation TV show', 'TV show for young peoples'),
|
||||||
new Type("Theater", "Theater play"), //
|
(UUID_TO_BIN('69ee5c15-d4ee-11ee-a8dd-02420a030203'), 'Theater', 'Theater play'),
|
||||||
new Type("One man show", "Recorded stand up"), //
|
(UUID_TO_BIN('6ce72530-d4ee-11ee-a8dd-02420a030203'), 'One man show', 'Recorded stand up'),
|
||||||
new Type("Concert", "Recorded concert"), //
|
(UUID_TO_BIN('6ff1691a-d4ee-11ee-a8dd-02420a030203'), 'Concert', 'Recorded concert'),
|
||||||
new Type("Opera", "Recorded opera") //
|
(UUID_TO_BIN('730815ef-d4ee-11ee-a8dd-02420a030203'), 'Opera', 'Recorded opera');
|
||||||
);
|
""");
|
||||||
da.insertMultiple(data);
|
|
||||||
});
|
|
||||||
// set start increment element to permit to add after default elements
|
// set start increment element to permit to add after default elements
|
||||||
addAction("""
|
addAction("""
|
||||||
ALTER TABLE `media` AUTO_INCREMENT = 1000;
|
ALTER TABLE `media` AUTO_INCREMENT = 1000;
|
||||||
@ -89,22 +66,22 @@ public class Initialization extends MigrationSqlStep {
|
|||||||
ALTER TABLE `userMediaAdvancement` AUTO_INCREMENT = 1000;
|
ALTER TABLE `userMediaAdvancement` AUTO_INCREMENT = 1000;
|
||||||
""", "mysql");
|
""", "mysql");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dropAll(final DBAccess da) {
|
public static void dropAll() {
|
||||||
for (final Class<?> element : CLASSES_BASE) {
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
try {
|
try {
|
||||||
da.drop(element);
|
DataAccess.drop(element);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
LOGGER.error("Fail to drop table !!!!!!");
|
LOGGER.error("Fail to drop table !!!!!!");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cleanAll(final DBAccess da) {
|
public static void cleanAll() {
|
||||||
for (final Class<?> element : CLASSES_BASE) {
|
for (final Class<?> element : CLASSES_BASE) {
|
||||||
try {
|
try {
|
||||||
da.cleanAll(element);
|
DataAccess.cleanAll(element);
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
LOGGER.error("Fail to clean table !!!!!!");
|
LOGGER.error("Fail to clean table !!!!!!");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -1,6 +1,23 @@
|
|||||||
package org.kar.karideo.migration;
|
package org.kar.karideo.migration;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.NoSuchFileException;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.kar.archidata.api.DataResource;
|
||||||
|
import org.kar.archidata.dataAccess.DataAccess;
|
||||||
|
import org.kar.archidata.dataAccess.addOn.model.LinkTableLongLong;
|
||||||
|
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
||||||
|
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
import org.kar.archidata.migration.MigrationSqlStep;
|
||||||
|
import org.kar.archidata.tools.UuidUtils;
|
||||||
|
import org.kar.karideo.migration.model.CoverConversion;
|
||||||
|
import org.kar.karideo.migration.model.MediaConversion;
|
||||||
|
import org.kar.karideo.migration.model.UUIDConversion;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -19,6 +36,102 @@ public class Migration20240226 extends MigrationSqlStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateStep() throws Exception {}
|
public void generateStep() throws Exception {
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` ADD `uuid` binary(16) AFTER `id`;
|
||||||
|
""");
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
for (final UUIDConversion elem : datas) {
|
||||||
|
elem.uuid = UuidUtils.nextUUID();
|
||||||
|
}
|
||||||
|
for (final UUIDConversion elem : datas) {
|
||||||
|
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("data"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addAction("""
|
||||||
|
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");
|
||||||
|
for (final String tableName : tableToTransform) {
|
||||||
|
addAction("ALTER TABLE `" + tableName + "` ADD `covers` text NULL;");
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
final List<CoverConversion> medias = DataAccess.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
||||||
|
final List<LinkTableLongLong> links = DataAccess.gets(LinkTableLongLong.class, new OverrideTableName(tableName + "_link_cover"));
|
||||||
|
LOGGER.info("Get somes data: {} {} {}", datas.size(), medias.size(), links.size());
|
||||||
|
for (final CoverConversion media : medias) {
|
||||||
|
final List<UUID> values = new ArrayList<>();
|
||||||
|
for (final LinkTableLongLong link : links) {
|
||||||
|
if (link.object1Id.equals(media.id)) {
|
||||||
|
for (final UUIDConversion data : datas) {
|
||||||
|
if (data.id.equals(link.object2Id)) {
|
||||||
|
values.add(data.uuid);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (values.size() != 0) {
|
||||||
|
media.covers = values;
|
||||||
|
LOGGER.info(" update: {} => {}", media.id, media.covers);
|
||||||
|
DataAccess.update(media, media.id, List.of("covers"), new OverrideTableName(tableName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addAction("DROP TABLE `" + tableName + "_link_cover`;");
|
||||||
|
}
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `media` ADD `dataUUID` binary(16) AFTER dataId;
|
||||||
|
""");
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
final List<MediaConversion> medias = DataAccess.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("media"));
|
||||||
|
for (final MediaConversion media : medias) {
|
||||||
|
for (final UUIDConversion data : datas) {
|
||||||
|
if (data.id.equals(media.dataId)) {
|
||||||
|
media.dataUUID = data.uuid;
|
||||||
|
DataAccess.update(media, media.id, List.of("dataUUID"), new OverrideTableName("media"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `media` DROP `dataId`;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `media` CHANGE `dataUUID` `dataId` binary(16) NOT NULL;
|
||||||
|
""");
|
||||||
|
// Move the files...
|
||||||
|
addAction(() -> {
|
||||||
|
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
||||||
|
for (final UUIDConversion data : datas) {
|
||||||
|
final String origin = DataResource.getFileDataOld(data.id);
|
||||||
|
final String destination = DataResource.getFileData(data.uuid);
|
||||||
|
LOGGER.info("move file = {}", origin);
|
||||||
|
LOGGER.info(" ==> {}", destination);
|
||||||
|
try {
|
||||||
|
Files.move(Paths.get(origin), Paths.get(destination), StandardCopyOption.ATOMIC_MOVE);
|
||||||
|
} catch (final NoSuchFileException ex) {
|
||||||
|
LOGGER.error("MOVE_ERROR : {} -> {}", origin, destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/* I am not sure then I prefer keep the primary key for the moment addAction(""" ALTER TABLE `data` DROP `id`; """); */
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` CHANGE `id` `idOld` bigint NOT NULL DEFAULT 0;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` DROP PRIMARY KEY;
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` CHANGE `uuid` `id` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
||||||
|
""");
|
||||||
|
addAction("""
|
||||||
|
ALTER TABLE `data` ADD PRIMARY KEY `id` (`id`);
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
package org.kar.karideo.migration;
|
|
||||||
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Migration20240611 extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2024-06-11: corect data uuid";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Migration20240611() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() throws Exception {
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` CHANGE `id` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
package org.kar.karideo.migration;
|
|
||||||
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.NoSuchFileException;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.kar.archidata.api.DataResource;
|
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.dataAccess.options.AccessDeletedItems;
|
|
||||||
import org.kar.archidata.dataAccess.options.OverrideTableName;
|
|
||||||
import org.kar.archidata.migration.MigrationSqlStep;
|
|
||||||
import org.kar.karideo.migration.model.CoverConversion;
|
|
||||||
import org.kar.karideo.migration.model.MediaConversion;
|
|
||||||
import org.kar.karideo.migration.model.OIDConversion;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class Migration20250214 extends MigrationSqlStep {
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Migration20240226.class);
|
|
||||||
|
|
||||||
public static final int KARSO_INITIALISATION_ID = 1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "migration-2025-01-04: convert base from UUID to OID";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateStep() throws Exception {
|
|
||||||
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` ADD `_id` binary(12) AFTER `uuid`;
|
|
||||||
""");
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
for (final OIDConversion elem : datas) {
|
|
||||||
elem._id = new ObjectId();
|
|
||||||
}
|
|
||||||
for (final OIDConversion elem : datas) {
|
|
||||||
da.update(elem, elem.uuid, List.of("_id"), new OverrideTableName("data"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
final List<String> tableToTransform = List.of("media", "season", "series", "type", "user");
|
|
||||||
for (final String tableName : tableToTransform) {
|
|
||||||
addAction("ALTER TABLE `" + tableName + "` ADD `covers_oid` text NULL;");
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
final List<CoverConversion> tableCoverTransforms = da.gets(CoverConversion.class, new AccessDeletedItems(), new OverrideTableName(tableName));
|
|
||||||
LOGGER.info("Get somes data: {} {}", datas.size(), tableCoverTransforms.size());
|
|
||||||
for (final CoverConversion tableTransform : tableCoverTransforms) {
|
|
||||||
final List<ObjectId> values = new ArrayList<>();
|
|
||||||
if (tableTransform.covers == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (final UUID link : tableTransform.covers) {
|
|
||||||
for (final OIDConversion data : datas) {
|
|
||||||
if (data.uuid.equals(link)) {
|
|
||||||
values.add(data._id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (values.size() != 0) {
|
|
||||||
tableTransform.covers_oid = values;
|
|
||||||
LOGGER.info(" update: {}: {} => {}", tableTransform.id, tableTransform.covers, tableTransform.covers_oid);
|
|
||||||
da.update(tableTransform, tableTransform.id, List.of("covers_oid"), new OverrideTableName(tableName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("ALTER TABLE `" + tableName + "` DROP `covers`;");
|
|
||||||
addAction("ALTER TABLE `" + tableName + "` CHANGE `covers_oid` `covers` text NULL;");
|
|
||||||
}
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `media` ADD `dataOid` binary(12) AFTER dataId;
|
|
||||||
""");
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
final List<MediaConversion> medias = da.gets(MediaConversion.class, new AccessDeletedItems(), new OverrideTableName("media"));
|
|
||||||
for (final MediaConversion media : medias) {
|
|
||||||
for (final OIDConversion data : datas) {
|
|
||||||
if (data.uuid.equals(media.dataId)) {
|
|
||||||
media.dataOid = data._id;
|
|
||||||
da.update(media, media.id, List.of("dataOid"), new OverrideTableName("media"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `media` DROP `dataId`;
|
|
||||||
""");
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `media` CHANGE `dataOid` `dataId` binary(12) NOT NULL;
|
|
||||||
""");
|
|
||||||
// Move the files...
|
|
||||||
addAction((final DBAccess da) -> {
|
|
||||||
final List<OIDConversion> datas = da.gets(OIDConversion.class, new AccessDeletedItems(), new OverrideTableName("data"));
|
|
||||||
for (final OIDConversion data : datas) {
|
|
||||||
final String origin = DataResource.getFileDataOld(data.uuid);
|
|
||||||
final String destination = DataResource.getFileData(data._id);
|
|
||||||
LOGGER.info("move file = {}", origin);
|
|
||||||
LOGGER.info(" ==> {}", destination);
|
|
||||||
try {
|
|
||||||
Files.move(Paths.get(origin), Paths.get(destination), StandardCopyOption.ATOMIC_MOVE);
|
|
||||||
} catch (final NoSuchFileException ex) {
|
|
||||||
LOGGER.warn("Fail to move file : {}", ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` DROP INDEX `PRIMARY`;
|
|
||||||
""");
|
|
||||||
// addAction("""
|
|
||||||
// ALTER TABLE `data` DROP `uuid`;
|
|
||||||
// """);
|
|
||||||
addAction("""
|
|
||||||
ALTER TABLE `data` ADD PRIMARY KEY `_id` (`_id`);
|
|
||||||
""");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -3,7 +3,6 @@ package org.kar.karideo.migration.model;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.kar.archidata.annotation.DataJson;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
|
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
@ -13,6 +12,4 @@ public class CoverConversion {
|
|||||||
public Long id = null;
|
public Long id = null;
|
||||||
@DataJson
|
@DataJson
|
||||||
public List<UUID> covers = null;
|
public List<UUID> covers = null;
|
||||||
@DataJson
|
|
||||||
public List<ObjectId> covers_oid = null;
|
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,11 @@ package org.kar.karideo.migration.model;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
public class MediaConversion {
|
public class MediaConversion {
|
||||||
@Id
|
@Id
|
||||||
public Long id = null;
|
public Long id = null;
|
||||||
public UUID dataId = null;
|
public Long dataId = null;
|
||||||
public ObjectId dataOid = null;
|
public UUID dataUUID = null;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,10 @@ package org.kar.karideo.migration.model;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
|
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
|
||||||
public class OIDConversion {
|
public class UUIDConversion {
|
||||||
@Id
|
@Id
|
||||||
|
public Long id = null;
|
||||||
public UUID uuid = null;
|
public UUID uuid = null;
|
||||||
public ObjectId _id = null;
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package org.kar.karideo.model;
|
package org.kar.karideo.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.kar.archidata.annotation.DataJson;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.model.Data;
|
import org.kar.archidata.model.Data;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
@ -10,7 +10,6 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.annotation.Nullable;
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
@ -30,7 +29,7 @@ public class Media extends GenericDataSoftDelete {
|
|||||||
@Schema(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 ObjectId dataId;
|
public UUID dataId;
|
||||||
@Schema(description = "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;
|
||||||
@ -50,8 +49,7 @@ public class Media extends GenericDataSoftDelete {
|
|||||||
public Integer ageLimit;
|
public Integer ageLimit;
|
||||||
@Schema(description = "List of Id of the specific covers")
|
@Schema(description = "List of Id of the specific covers")
|
||||||
@DataJson(targetEntity = Data.class)
|
@DataJson(targetEntity = Data.class)
|
||||||
@Nullable
|
public List<UUID> covers = null;
|
||||||
public List<ObjectId> covers = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package org.kar.karideo.model;
|
package org.kar.karideo.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.annotation.DataJson;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
@ -10,7 +10,6 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.annotation.Nullable;
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
@ -32,6 +31,5 @@ public class Season extends GenericDataSoftDelete {
|
|||||||
public Long parentId;
|
public Long parentId;
|
||||||
@Schema(description = "List of Id of the specific covers")
|
@Schema(description = "List of Id of the specific covers")
|
||||||
@DataJson()
|
@DataJson()
|
||||||
@Nullable
|
public List<UUID> covers = null;
|
||||||
public List<ObjectId> covers = null;
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package org.kar.karideo.model;
|
package org.kar.karideo.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.annotation.DataJson;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
@ -10,7 +10,6 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.annotation.Nullable;
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
@ -32,6 +31,5 @@ public class Series extends GenericDataSoftDelete {
|
|||||||
public Long parentId;
|
public Long parentId;
|
||||||
@Schema(description = "List of Id of the specific covers")
|
@Schema(description = "List of Id of the specific covers")
|
||||||
@DataJson()
|
@DataJson()
|
||||||
@Nullable
|
public List<UUID> covers = null;
|
||||||
public List<ObjectId> covers = null;
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package org.kar.karideo.model;
|
package org.kar.karideo.model;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bson.types.ObjectId;
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
import org.kar.archidata.annotation.DataJson;
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
@ -10,7 +10,6 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.annotation.Nullable;
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
|
|
||||||
@ -26,14 +25,5 @@ public class Type extends GenericDataSoftDelete {
|
|||||||
public String description;
|
public String description;
|
||||||
@Schema(description = "List of Id of the specific covers")
|
@Schema(description = "List of Id of the specific covers")
|
||||||
@DataJson()
|
@DataJson()
|
||||||
@Nullable
|
public List<UUID> covers = null;
|
||||||
public List<ObjectId> covers = null;
|
|
||||||
|
|
||||||
public Type() {}
|
|
||||||
|
|
||||||
public Type(final String name, final String description) {
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.annotation.Nullable;
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
@ -21,7 +20,6 @@ public class UserMediaAdvancement extends GenericDataSoftDelete {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@Schema(description = "Foreign Key Id of the user")
|
@Schema(description = "Foreign Key Id of the user")
|
||||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserKarideo.class)
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserKarideo.class)
|
||||||
@Nullable
|
|
||||||
public Long userId;
|
public Long userId;
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
@Schema(description = "Id of the media")
|
@Schema(description = "Id of the media")
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
package test.kar.karideo;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DBAccess;
|
|
||||||
import org.kar.archidata.db.DbConfig;
|
|
||||||
import org.kar.archidata.db.DbIoFactory;
|
|
||||||
import org.kar.archidata.exception.DataAccessException;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.karideo.model.Media;
|
|
||||||
import org.kar.karideo.model.Season;
|
|
||||||
import org.kar.karideo.model.Series;
|
|
||||||
import org.kar.karideo.model.Type;
|
|
||||||
import org.kar.karideo.model.UserKarideo;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import jakarta.ws.rs.InternalServerErrorException;
|
|
||||||
|
|
||||||
public class ConfigureDb {
|
|
||||||
final static private Logger LOGGER = LoggerFactory.getLogger(ConfigureDb.class);
|
|
||||||
final static private String modeTestForced = null;// "MONGO";
|
|
||||||
public static DBAccess da = null;
|
|
||||||
|
|
||||||
public static void configure() throws IOException, InternalServerErrorException, DataAccessException {
|
|
||||||
String modeTest = System.getenv("TEST_E2E_MODE");
|
|
||||||
if (modeTest == null || modeTest.isEmpty() || "false".equalsIgnoreCase(modeTest)) {
|
|
||||||
modeTest = "SQLITE-MEMORY";
|
|
||||||
} else if ("true".equalsIgnoreCase(modeTest)) {
|
|
||||||
modeTest = "MY-SQL";
|
|
||||||
}
|
|
||||||
// override the local test:
|
|
||||||
if (modeTestForced != null) {
|
|
||||||
modeTest = modeTestForced;
|
|
||||||
}
|
|
||||||
// for local test:
|
|
||||||
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";
|
|
||||||
final List<Class<?>> listObject = List.of( //
|
|
||||||
Media.class, //
|
|
||||||
Season.class, //
|
|
||||||
Series.class, //
|
|
||||||
Type.class, //
|
|
||||||
UserKarideo.class //
|
|
||||||
);
|
|
||||||
if ("SQLITE-MEMORY".equalsIgnoreCase(modeTest)) {
|
|
||||||
ConfigBaseVariable.dbType = "sqlite";
|
|
||||||
ConfigBaseVariable.bdDatabase = null;
|
|
||||||
ConfigBaseVariable.dbHost = "memory";
|
|
||||||
// for test we need to connect all time the DB
|
|
||||||
ConfigBaseVariable.dbKeepConnected = "true";
|
|
||||||
} else if ("SQLITE".equalsIgnoreCase(modeTest)) {
|
|
||||||
ConfigBaseVariable.dbType = "sqlite";
|
|
||||||
ConfigBaseVariable.bdDatabase = null;
|
|
||||||
ConfigBaseVariable.dbKeepConnected = "true";
|
|
||||||
} else if ("MY-SQL".equalsIgnoreCase(modeTest)) {
|
|
||||||
ConfigBaseVariable.dbType = "mysql";
|
|
||||||
ConfigBaseVariable.bdDatabase = "test_Karideo_db";
|
|
||||||
ConfigBaseVariable.dbPort = "3906";
|
|
||||||
ConfigBaseVariable.dbUser = "root";
|
|
||||||
} else if ("MONGO".equalsIgnoreCase(modeTest)) {
|
|
||||||
ConfigBaseVariable.dbType = "mongo";
|
|
||||||
ConfigBaseVariable.bdDatabase = "test_Karideo_db";
|
|
||||||
} else {
|
|
||||||
// User local modification ...
|
|
||||||
ConfigBaseVariable.bdDatabase = "test_Karideo_db";
|
|
||||||
ConfigBaseVariable.dbPort = "3906";
|
|
||||||
ConfigBaseVariable.dbUser = "root";
|
|
||||||
}
|
|
||||||
removeDB();
|
|
||||||
// Connect the dataBase...
|
|
||||||
da = DBAccess.createInterface();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void removeDB() {
|
|
||||||
String modeTest = System.getenv("TEST_E2E_MODE");
|
|
||||||
if (modeTest == null || modeTest.isEmpty() || "false".equalsIgnoreCase(modeTest)) {
|
|
||||||
modeTest = "SQLITE-MEMORY";
|
|
||||||
} else if ("true".equalsIgnoreCase(modeTest)) {
|
|
||||||
modeTest = "MY-SQL";
|
|
||||||
}
|
|
||||||
// override the local test:
|
|
||||||
if (modeTestForced != null) {
|
|
||||||
modeTest = modeTestForced;
|
|
||||||
}
|
|
||||||
DbConfig config = null;
|
|
||||||
try {
|
|
||||||
config = new DbConfig();
|
|
||||||
} catch (final DataAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOGGER.error("Fail to clean the DB");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
config.setDbName(null);
|
|
||||||
LOGGER.info("Remove the DB and create a new one '{}'", config.getDbName());
|
|
||||||
try (final DBAccess daRoot = DBAccess.createInterface(config)) {
|
|
||||||
if ("SQLITE-MEMORY".equalsIgnoreCase(modeTest)) {
|
|
||||||
// nothing to do ...
|
|
||||||
} else if ("SQLITE".equalsIgnoreCase(modeTest)) {
|
|
||||||
daRoot.deleteDB(ConfigBaseVariable.bdDatabase);
|
|
||||||
} else if ("MY-SQL".equalsIgnoreCase(modeTest)) {
|
|
||||||
daRoot.deleteDB(ConfigBaseVariable.bdDatabase);
|
|
||||||
} else if ("MONGO".equalsIgnoreCase(modeTest)) {
|
|
||||||
daRoot.deleteDB(ConfigBaseVariable.bdDatabase);
|
|
||||||
}
|
|
||||||
daRoot.createDB(ConfigBaseVariable.bdDatabase);
|
|
||||||
} catch (final InternalServerErrorException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOGGER.error("Fail to clean the DB");
|
|
||||||
return;
|
|
||||||
} catch (final IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
LOGGER.error("Fail to clean the DB");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clear() throws IOException {
|
|
||||||
LOGGER.info("Remove the test db");
|
|
||||||
removeDB();
|
|
||||||
// The connection is by default open ==> close it at the end of test:
|
|
||||||
da.close();
|
|
||||||
DbIoFactory.closeAllForceMode();
|
|
||||||
ConfigBaseVariable.clearAllValue();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package test.kar.karideo;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterAll;
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
|
||||||
import org.kar.archidata.tools.RESTApi;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
@ExtendWith(StepwiseExtension.class)
|
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
|
||||||
public class TestBase {
|
|
||||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestBase.class);
|
|
||||||
public final static String ENDPOINT_NAME = "species/";
|
|
||||||
|
|
||||||
static WebLauncherTest webInterface = null;
|
|
||||||
static RESTApi api = null;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void configureWebServer() throws Exception {
|
|
||||||
ConfigureDb.configure();
|
|
||||||
LOGGER.info("configure server ...");
|
|
||||||
webInterface = new WebLauncherTest();
|
|
||||||
LOGGER.info("Start REST (BEGIN)");
|
|
||||||
webInterface.process();
|
|
||||||
LOGGER.info("Start REST (DONE)");
|
|
||||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
|
||||||
api.setToken(Common.ADMIN_TOKEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterAll
|
|
||||||
public static void stopWebServer() throws Exception {
|
|
||||||
LOGGER.info("Kill the web server");
|
|
||||||
webInterface.stop();
|
|
||||||
webInterface = null;
|
|
||||||
ConfigureDb.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public static void TestEmpty() throws Exception {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -10,7 +10,8 @@ import org.junit.jupiter.api.Order;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestMethodOrder;
|
import org.junit.jupiter.api.TestMethodOrder;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.kar.archidata.exception.RESTErrorResponseException;
|
import org.kar.archidata.db.DBEntry;
|
||||||
|
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.archidata.tools.RESTApi;
|
import org.kar.archidata.tools.RESTApi;
|
||||||
import org.kar.karideo.api.HealthCheck.HealthResult;
|
import org.kar.karideo.api.HealthCheck.HealthResult;
|
||||||
@ -48,7 +49,7 @@ public class TestHealthCheck {
|
|||||||
webInterface.stop();
|
webInterface.stop();
|
||||||
webInterface = null;
|
webInterface = null;
|
||||||
LOGGER.info("Remove the test db");
|
LOGGER.info("Remove the test db");
|
||||||
// DBEntry.closeAllForceMode();
|
DBEntry.closeAllForceMode();
|
||||||
ConfigBaseVariable.clearAllValue();
|
ConfigBaseVariable.clearAllValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public class TestHealthCheck {
|
|||||||
@Order(2)
|
@Order(2)
|
||||||
@Test
|
@Test
|
||||||
public void checkHealthCheckWrongAPI() throws Exception {
|
public void checkHealthCheckWrongAPI() throws Exception {
|
||||||
Assertions.assertThrows(RESTErrorResponseException.class, () -> api.get(HealthResult.class, "health_checks"));
|
Assertions.assertThrows(RESTErrorResponseExeption.class, () -> api.get(HealthResult.class, "health_checks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
package test.kar.karideo;
|
package test.kar.karideo;
|
||||||
|
|
||||||
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.karideo.WebLauncher;
|
import org.kar.karideo.WebLauncher;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -8,5 +9,26 @@ 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");
|
||||||
|
// for local test:
|
||||||
|
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";
|
||||||
|
// for the test we a in memory sqlite..
|
||||||
|
if (true) {
|
||||||
|
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||||
|
ConfigBaseVariable.dbType = "sqlite";
|
||||||
|
ConfigBaseVariable.dbHost = "memory";
|
||||||
|
// for test we need to connect all time the DB
|
||||||
|
ConfigBaseVariable.dbKeepConnected = "true";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Enable this if you want to access to a local MySQL base to test with an adminer
|
||||||
|
ConfigBaseVariable.bdDatabase = "test_db";
|
||||||
|
ConfigBaseVariable.dbPort = "3309";
|
||||||
|
ConfigBaseVariable.dbUser = "root";
|
||||||
|
ConfigBaseVariable.dbPassword = "password";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +0,0 @@
|
|||||||
NODE_ENV=development
|
|
@ -1,2 +0,0 @@
|
|||||||
# URL for database connection
|
|
||||||
VITE_API_BASE_URL=karusic/api/
|
|
@ -1,27 +0,0 @@
|
|||||||
import type { StorybookConfig } from '@storybook/react-vite';
|
|
||||||
|
|
||||||
const config: StorybookConfig = {
|
|
||||||
framework: {
|
|
||||||
name: '@storybook/react-vite',
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
|
|
||||||
core: {
|
|
||||||
disableTelemetry: true,
|
|
||||||
builder: '@storybook/builder-vite',
|
|
||||||
},
|
|
||||||
|
|
||||||
stories: ['../src/**/*.@(mdx|stories.@(js|jsx|ts|tsx))'],
|
|
||||||
|
|
||||||
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
|
|
||||||
|
|
||||||
staticDirs: ['../public'],
|
|
||||||
|
|
||||||
typescript: {
|
|
||||||
reactDocgen: false,
|
|
||||||
},
|
|
||||||
|
|
||||||
docs: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
@ -1,16 +0,0 @@
|
|||||||
<style>
|
|
||||||
html {
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.docs-story > :first-child {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
.docs-story > * {
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
#root #start-ui-storybook-wrapper {
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,34 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
|
|
||||||
import { Box } from '@chakra-ui/react';
|
|
||||||
import { ChakraProvider } from '@chakra-ui/react';
|
|
||||||
import { MemoryRouter } from 'react-router-dom';
|
|
||||||
|
|
||||||
import { ColorModeProvider } from '../src/components/ui/color-mode';
|
|
||||||
import { Toaster } from '../src/components/ui/toaster';
|
|
||||||
import { systemTheme } from '../src/theme/theme';
|
|
||||||
|
|
||||||
// .
|
|
||||||
const DocumentationWrapper = ({ children }) => {
|
|
||||||
return (
|
|
||||||
<Box id="start-ui-storybook-wrapper" p="4" pb="8" flex="1">
|
|
||||||
{children}
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const decorators = [
|
|
||||||
(Story, context) => (
|
|
||||||
<ColorModeProvider>
|
|
||||||
<ChakraProvider value={systemTheme}>
|
|
||||||
{/* Using MemoryRouter to avoid route clashing with Storybook */}
|
|
||||||
<MemoryRouter>
|
|
||||||
<DocumentationWrapper>
|
|
||||||
<Story {...context} />
|
|
||||||
</DocumentationWrapper>
|
|
||||||
</MemoryRouter>
|
|
||||||
<Toaster />
|
|
||||||
</ChakraProvider>
|
|
||||||
</ColorModeProvider>
|
|
||||||
),
|
|
||||||
];
|
|
@ -1,2 +0,0 @@
|
|||||||
Proprietary
|
|
||||||
@copyright Edouard Dupin 2024
|
|
10637
front/config sample.yaml
10637
front/config sample.yaml
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Karideo</title>
|
|
||||||
<link rel="icon" href="/favicon.ico" />
|
|
||||||
</head>
|
|
||||||
<body style="width:100vw;height:100vh;min-width:100%;min-height:100%;">
|
|
||||||
<div id="root" style="width:100%;height:100%;min-width:100%;min-height:100%;"></div>
|
|
||||||
<script type="module" src="/src/main.tsx"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,9 +0,0 @@
|
|||||||
import type { KnipConfig } from 'knip';
|
|
||||||
|
|
||||||
const config: KnipConfig = {
|
|
||||||
// Ignoring mostly shell binaries
|
|
||||||
ignoreBinaries: ['export', 'sleep'],
|
|
||||||
ignore: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
@ -1,91 +1,50 @@
|
|||||||
{
|
{
|
||||||
"name": "karideo",
|
"name": "karideo",
|
||||||
"private": true,
|
"version": "0.0.0",
|
||||||
"version": "0.0.1",
|
"license": "MPL-2",
|
||||||
"description": "KAR web music application",
|
"scripts": {
|
||||||
"author": {
|
"all": "npm run build && npm run test",
|
||||||
"name": "Edouard DUPIN",
|
"ng": "ng",
|
||||||
"email": "yui.heero@gmail.farm"
|
"dev": "ng serve --configuration=develop --watch --port 4202",
|
||||||
},
|
"dev-hot-update": "ng serve --configuration=develop --watch --hmr --port 4202",
|
||||||
"license": "PROPRIETARY",
|
"build": "ng build --prod",
|
||||||
"engines": {
|
"test": "ng test",
|
||||||
"node": ">=20"
|
"lint": "ng lint",
|
||||||
},
|
"style": "prettier --write .",
|
||||||
"scripts": {
|
"e2e": "ng e2e",
|
||||||
"update_packages": "ncu --target minor",
|
"update_packages": "ncu --upgrade",
|
||||||
"upgrade_packages": "ncu --upgrade ",
|
"install_dependency": "pnpm install --force",
|
||||||
"install_dependency": "pnpm install",
|
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
||||||
"test": "vitest run",
|
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
||||||
"test:watch": "vitest watch",
|
},
|
||||||
"build": "tsc && vite build",
|
"private": true,
|
||||||
"static:build": "pnpm build",
|
"dependencies": {
|
||||||
"dev": "vite",
|
"@angular/animations": "^18.0.2",
|
||||||
"pretty": "prettier -w .",
|
"@angular/cdk": "^18.0.2",
|
||||||
"lint": "pnpm tsc --noEmit",
|
"@angular/common": "^18.0.2",
|
||||||
"storybook": "storybook dev -p 3001",
|
"@angular/compiler": "^18.0.2",
|
||||||
"storybook:build": "storybook build && mv ./storybook-static ./public/storybook"
|
"@angular/core": "^18.0.2",
|
||||||
},
|
"@angular/forms": "^18.0.2",
|
||||||
"lint-staged": {
|
"@angular/material": "^18.0.2",
|
||||||
"*.{ts,tsx,js,jsx,json}": "prettier --write"
|
"@angular/platform-browser": "^18.0.2",
|
||||||
},
|
"@angular/platform-browser-dynamic": "^18.0.2",
|
||||||
"dependencies": {
|
"@angular/router": "^18.0.2",
|
||||||
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
"rxjs": "^7.8.1",
|
||||||
"@chakra-ui/cli": "3.7.0",
|
"zone.js": "^0.14.6",
|
||||||
"@chakra-ui/react": "3.7.0",
|
"zod": "3.23.8",
|
||||||
"@emotion/react": "11.14.0",
|
"@kangaroo-and-rabbit/kar-cw": "^0.4.1"
|
||||||
"allotment": "1.20.2",
|
},
|
||||||
"css-mediaquery": "0.1.2",
|
"devDependencies": {
|
||||||
"dayjs": "1.11.13",
|
"@angular-devkit/build-angular": "^18.0.3",
|
||||||
"history": "5.3.0",
|
"@angular-eslint/builder": "18.0.1",
|
||||||
"next-themes": "^0.4.4",
|
"@angular-eslint/eslint-plugin": "18.0.1",
|
||||||
"react": "19.0.0-rc.1",
|
"@angular-eslint/eslint-plugin-template": "18.0.1",
|
||||||
"react-dom": "19.0.0-rc.1",
|
"@angular-eslint/schematics": "18.0.1",
|
||||||
"react-error-boundary": "5.0.0",
|
"@angular-eslint/template-parser": "18.0.1",
|
||||||
"react-icons": "5.4.0",
|
"@angular/cli": "^18.0.3",
|
||||||
"react-router-dom": "7.1.5",
|
"@angular/compiler-cli": "^18.0.2",
|
||||||
"react-select": "5.10.0",
|
"@angular/language-service": "^18.0.2",
|
||||||
"react-use": "17.6.0",
|
"npm-check-updates": "^16.14.20",
|
||||||
"zod": "3.24.1",
|
"tslib": "^2.6.3"
|
||||||
"zustand": "5.0.3"
|
}
|
||||||
},
|
}
|
||||||
"devDependencies": {
|
|
||||||
"@chakra-ui/styled-system": "^2.12.0",
|
|
||||||
"@playwright/test": "1.50.1",
|
|
||||||
"@storybook/addon-actions": "8.5.4",
|
|
||||||
"@storybook/addon-essentials": "8.5.4",
|
|
||||||
"@storybook/addon-links": "8.5.4",
|
|
||||||
"@storybook/addon-mdx-gfm": "8.5.4",
|
|
||||||
"@storybook/react": "8.5.4",
|
|
||||||
"@storybook/react-vite": "8.5.4",
|
|
||||||
"@storybook/theming": "8.5.4",
|
|
||||||
"@testing-library/jest-dom": "6.6.3",
|
|
||||||
"@testing-library/react": "16.2.0",
|
|
||||||
"@testing-library/user-event": "14.6.1",
|
|
||||||
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
|
||||||
"@types/jest": "29.5.14",
|
|
||||||
"@types/node": "22.13.1",
|
|
||||||
"@types/react": "19.0.8",
|
|
||||||
"@types/react-dom": "19.0.3",
|
|
||||||
"@typescript-eslint/eslint-plugin": "8.24.0",
|
|
||||||
"@typescript-eslint/parser": "8.24.0",
|
|
||||||
"@vitejs/plugin-react": "4.3.4",
|
|
||||||
"eslint": "9.20.1",
|
|
||||||
"eslint-plugin-import": "2.31.0",
|
|
||||||
"eslint-plugin-react": "7.37.4",
|
|
||||||
"eslint-plugin-react-hooks": "5.1.0",
|
|
||||||
"eslint-plugin-storybook": "0.11.2",
|
|
||||||
"jest": "29.7.0",
|
|
||||||
"jest-environment-jsdom": "29.7.0",
|
|
||||||
"knip": "5.44.0",
|
|
||||||
"lint-staged": "15.4.3",
|
|
||||||
"npm-check-updates": "^17.1.14",
|
|
||||||
"prettier": "3.5.0",
|
|
||||||
"puppeteer": "24.2.0",
|
|
||||||
"react-is": "19.0.0",
|
|
||||||
"storybook": "8.5.4",
|
|
||||||
"ts-node": "10.9.2",
|
|
||||||
"typescript": "5.7.3",
|
|
||||||
"vite": "6.1.0",
|
|
||||||
"vitest": "3.0.5"
|
|
||||||
}
|
|
||||||
}
|
|
17670
front/pnpm-lock.yaml
generated
17670
front/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -1,16 +0,0 @@
|
|||||||
// Using a JS file, allowing us to add comments
|
|
||||||
module.exports = {
|
|
||||||
// This plugins line is mandatory for the plugin to work with pnpm.
|
|
||||||
// https://github.com/trivago/prettier-plugin-sort-imports/blob/61d069711008c530f5a41ca4e254781abc5de358/README.md?plain=1#L89-L96
|
|
||||||
plugins: ['@trivago/prettier-plugin-sort-imports'],
|
|
||||||
endOfLine: 'lf',
|
|
||||||
semi: true,
|
|
||||||
singleQuote: true,
|
|
||||||
tabWidth: 2,
|
|
||||||
trailingComma: 'es5',
|
|
||||||
arrowParens: 'always',
|
|
||||||
importOrder: ['^react$', '^(?!^react$|^@/|^[./]).*', '^@/(.*)$', '^[./]'],
|
|
||||||
importOrderSeparation: true,
|
|
||||||
importOrderSortSpecifiers: true,
|
|
||||||
importOrderParserPlugins: ['jsx', 'typescript'],
|
|
||||||
};
|
|
@ -1,20 +0,0 @@
|
|||||||
import { ErrorBoundary } from '@/errors/ErrorBoundary';
|
|
||||||
|
|
||||||
import { AudioPlayer } from './components';
|
|
||||||
import { EnvDevelopment } from './components/EnvDevelopment/EnvDevelopment';
|
|
||||||
import { AppRoutes } from './scene/AppRoutes';
|
|
||||||
import { ServiceContextProvider } from './service/ServiceContext';
|
|
||||||
|
|
||||||
export const App = () => {
|
|
||||||
return (
|
|
||||||
<ServiceContextProvider>
|
|
||||||
<EnvDevelopment />
|
|
||||||
<ErrorBoundary>
|
|
||||||
<AppRoutes />
|
|
||||||
</ErrorBoundary>
|
|
||||||
<AudioPlayer />
|
|
||||||
</ServiceContextProvider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default App;
|
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from "../rest-tools";
|
} from "../rest-tools";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ObjectId,
|
UUID,
|
||||||
} from "../model";
|
} from "../model";
|
||||||
|
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
@ -30,13 +30,13 @@ export namespace DataResource {
|
|||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
name: string,
|
name: string,
|
||||||
oid: ObjectId,
|
uuid: UUID,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{oid}/{name}",
|
endPoint: "/data/{uuid}/{name}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -59,13 +59,13 @@ export namespace DataResource {
|
|||||||
Authorization?: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
oid: ObjectId,
|
uuid: UUID,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{oid}",
|
endPoint: "/data/{uuid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -88,13 +88,13 @@ export namespace DataResource {
|
|||||||
Authorization?: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
oid: ObjectId,
|
uuid: UUID,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/thumbnail/{oid}",
|
endPoint: "/data/thumbnail/{uuid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
@ -154,16 +154,17 @@ export namespace MediaResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
fileName: string,
|
||||||
file: File,
|
file: File,
|
||||||
},
|
},
|
||||||
callbacks?: RESTCallbacks,
|
callback?: RESTCallbacks,
|
||||||
}): Promise<Media> {
|
}): Promise<Media> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -175,7 +176,7 @@ export namespace MediaResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}, isMedia);
|
}, isMedia);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -184,7 +185,7 @@ export namespace MediaResource {
|
|||||||
export function uploadFile({
|
export function uploadFile({
|
||||||
restConfig,
|
restConfig,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
data: {
|
data: {
|
||||||
@ -197,7 +198,7 @@ export namespace MediaResource {
|
|||||||
typeId: string,
|
typeId: string,
|
||||||
title: string,
|
title: string,
|
||||||
},
|
},
|
||||||
callbacks?: RESTCallbacks,
|
callback?: RESTCallbacks,
|
||||||
}): Promise<Media> {
|
}): Promise<Media> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -208,7 +209,7 @@ export namespace MediaResource {
|
|||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}, isMedia);
|
}, isMedia);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -176,16 +176,17 @@ export namespace SeasonResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
fileName: string,
|
||||||
file: File,
|
file: File,
|
||||||
},
|
},
|
||||||
callbacks?: RESTCallbacks,
|
callback?: RESTCallbacks,
|
||||||
}): Promise<Season> {
|
}): Promise<Season> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -197,7 +198,7 @@ export namespace SeasonResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}, isSeason);
|
}, isSeason);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -176,16 +176,17 @@ export namespace SeriesResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
fileName: string,
|
||||||
file: File,
|
file: File,
|
||||||
},
|
},
|
||||||
callbacks?: RESTCallbacks,
|
callback?: RESTCallbacks,
|
||||||
}): Promise<Series> {
|
}): Promise<Series> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -197,7 +198,7 @@ export namespace SeriesResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}, isSeries);
|
}, isSeries);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -176,16 +176,17 @@ export namespace TypeResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
params: {
|
params: {
|
||||||
id: Long,
|
id: Long,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
fileName: string,
|
||||||
file: File,
|
file: File,
|
||||||
},
|
},
|
||||||
callbacks?: RESTCallbacks,
|
callback?: RESTCallbacks,
|
||||||
}): Promise<Type> {
|
}): Promise<Type> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
@ -197,7 +198,7 @@ export namespace TypeResource {
|
|||||||
restConfig,
|
restConfig,
|
||||||
params,
|
params,
|
||||||
data,
|
data,
|
||||||
callbacks,
|
callback,
|
||||||
}, isType);
|
}, isType);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodGenericData, ZodGenericDataWrite } from "./generic-data";
|
import {ZodGenericData} from "./generic-data";
|
||||||
|
|
||||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||||
/**
|
/**
|
||||||
@ -24,7 +24,14 @@ export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelet
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataWrite;
|
|
||||||
|
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataSoftDelete.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericTiming, ZodGenericTimingWrite } from "./generic-timing";
|
import {ZodGenericTiming} from "./generic-timing";
|
||||||
|
|
||||||
export const ZodGenericData = ZodGenericTiming.extend({
|
export const ZodGenericData = ZodGenericTiming.extend({
|
||||||
/**
|
/**
|
||||||
@ -25,7 +25,13 @@ export function isGenericData(data: any): data is GenericData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodGenericDataWrite = ZodGenericTimingWrite;
|
|
||||||
|
export const ZodGenericDataWrite = ZodGenericData.omit({
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
||||||
|
|
@ -28,9 +28,12 @@ export function isGenericTiming(data: any): data is GenericTiming {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodGenericTimingWrite = zod.object({
|
|
||||||
|
|
||||||
});
|
export const ZodGenericTimingWrite = ZodGenericTiming.omit({
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
||||||
|
|
@ -19,9 +19,8 @@ export function isHealthResult(data: any): data is HealthResult {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodHealthResultWrite = zod.object({
|
|
||||||
|
|
||||||
});
|
export const ZodHealthResultWrite = ZodHealthResult.partial();
|
||||||
|
|
||||||
export type HealthResultWrite = zod.infer<typeof ZodHealthResultWrite>;
|
export type HealthResultWrite = zod.infer<typeof ZodHealthResultWrite>;
|
||||||
|
|
@ -1,20 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* Interface of the server (auto-generated code)
|
* Interface of the server (auto-generated code)
|
||||||
*/
|
*/
|
||||||
export * from "./data"
|
|
||||||
export * from "./float"
|
export * from "./float"
|
||||||
export * from "./generic-data"
|
export * from "./generic-data"
|
||||||
export * from "./generic-data-soft-delete"
|
export * from "./generic-data-soft-delete"
|
||||||
export * from "./generic-timing"
|
export * from "./generic-timing"
|
||||||
export * from "./health-result"
|
export * from "./health-result"
|
||||||
|
export * from "./int"
|
||||||
export * from "./integer"
|
export * from "./integer"
|
||||||
export * from "./iso-date"
|
export * from "./iso-date"
|
||||||
export * from "./long"
|
export * from "./long"
|
||||||
export * from "./media"
|
export * from "./media"
|
||||||
export * from "./media-informations-delta"
|
export * from "./media-informations-delta"
|
||||||
export * from "./object-id"
|
|
||||||
export * from "./oid-generic-data"
|
|
||||||
export * from "./oid-generic-data-soft-delete"
|
|
||||||
export * from "./rest-error-response"
|
export * from "./rest-error-response"
|
||||||
export * from "./season"
|
export * from "./season"
|
||||||
export * from "./series"
|
export * from "./series"
|
@ -19,9 +19,8 @@ export function isint(data: any): data is int {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodintWrite = zod.object({
|
|
||||||
|
|
||||||
});
|
export const ZodintWrite = Zodint.partial();
|
||||||
|
|
||||||
export type intWrite = zod.infer<typeof ZodintWrite>;
|
export type intWrite = zod.infer<typeof ZodintWrite>;
|
||||||
|
|
@ -19,9 +19,8 @@ export function isMediaInformationsDelta(data: any): data is MediaInformationsDe
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodMediaInformationsDeltaWrite = zod.object({
|
|
||||||
|
|
||||||
});
|
export const ZodMediaInformationsDeltaWrite = ZodMediaInformationsDelta.partial();
|
||||||
|
|
||||||
export type MediaInformationsDeltaWrite = zod.infer<typeof ZodMediaInformationsDeltaWrite>;
|
export type MediaInformationsDeltaWrite = zod.infer<typeof ZodMediaInformationsDeltaWrite>;
|
||||||
|
|
@ -3,10 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodObjectId} from "./object-id";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodInteger} from "./integer";
|
import {ZodInteger} from "./integer";
|
||||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,7 @@ export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* Foreign Key Id of the data
|
* Foreign Key Id of the data
|
||||||
*/
|
*/
|
||||||
dataId: ZodObjectId,
|
dataId: ZodUUID,
|
||||||
/**
|
/**
|
||||||
* Type of the media
|
* Type of the media
|
||||||
*/
|
*/
|
||||||
@ -49,7 +49,7 @@ export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* List of Id of the specific covers
|
* List of Id of the specific covers
|
||||||
*/
|
*/
|
||||||
covers: zod.array(ZodObjectId).optional(),
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -64,50 +64,14 @@ export function isMedia(data: any): data is Media {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodMediaWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|
||||||
/**
|
|
||||||
* Name of the media (this represent the title)
|
|
||||||
*/
|
|
||||||
name: zod.string().optional(),
|
|
||||||
/**
|
|
||||||
* Description of the media
|
|
||||||
*/
|
|
||||||
description: zod.string().nullable().optional(),
|
|
||||||
/**
|
|
||||||
* Foreign Key Id of the data
|
|
||||||
*/
|
|
||||||
dataId: ZodObjectId.optional(),
|
|
||||||
/**
|
|
||||||
* Type of the media
|
|
||||||
*/
|
|
||||||
typeId: ZodLong.nullable().optional(),
|
|
||||||
/**
|
|
||||||
* Series reference of the media
|
|
||||||
*/
|
|
||||||
seriesId: ZodLong.nullable().optional(),
|
|
||||||
/**
|
|
||||||
* Season reference of the media
|
|
||||||
*/
|
|
||||||
seasonId: ZodLong.nullable().optional(),
|
|
||||||
/**
|
|
||||||
* Episode Id
|
|
||||||
*/
|
|
||||||
episode: ZodInteger.nullable().optional(),
|
|
||||||
date: ZodInteger.nullable().optional(),
|
|
||||||
/**
|
|
||||||
* Creation years of the media
|
|
||||||
*/
|
|
||||||
time: ZodInteger.nullable().optional(),
|
|
||||||
/**
|
|
||||||
* Limitation Age of the media
|
|
||||||
*/
|
|
||||||
ageLimit: ZodInteger.nullable().optional(),
|
|
||||||
/**
|
|
||||||
* List of Id of the specific covers
|
|
||||||
*/
|
|
||||||
covers: zod.array(ZodObjectId).nullable().optional(),
|
|
||||||
|
|
||||||
});
|
export const ZodMediaWrite = ZodMedia.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type MediaWrite = zod.infer<typeof ZodMediaWrite>;
|
export type MediaWrite = zod.infer<typeof ZodMediaWrite>;
|
||||||
|
|
@ -3,15 +3,15 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodObjectId} from "./object-id";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodInteger} from "./integer";
|
import {Zodint} from "./int";
|
||||||
|
|
||||||
export const ZodRestErrorResponse = zod.object({
|
export const ZodRestErrorResponse = zod.object({
|
||||||
oid: ZodObjectId.optional(),
|
uuid: ZodUUID.optional(),
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
message: zod.string(),
|
message: zod.string(),
|
||||||
time: zod.string(),
|
time: zod.string(),
|
||||||
status: ZodInteger,
|
status: Zodint,
|
||||||
statusMessage: zod.string(),
|
statusMessage: zod.string(),
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -27,3 +27,17 @@ export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
|||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -4,8 +4,8 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodObjectId} from "./object-id";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodSeason = ZodGenericDataSoftDelete.extend({
|
export const ZodSeason = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -23,7 +23,7 @@ export const ZodSeason = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* List of Id of the specific covers
|
* List of Id of the specific covers
|
||||||
*/
|
*/
|
||||||
covers: zod.array(ZodObjectId).optional(),
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -38,25 +38,14 @@ export function isSeason(data: any): data is Season {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodSeasonWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|
||||||
/**
|
|
||||||
* Name of the media (this represent the title)
|
|
||||||
*/
|
|
||||||
name: zod.string().optional(),
|
|
||||||
/**
|
|
||||||
* Description of the media
|
|
||||||
*/
|
|
||||||
description: zod.string().nullable().optional(),
|
|
||||||
/**
|
|
||||||
* series parent ID
|
|
||||||
*/
|
|
||||||
parentId: ZodLong.optional(),
|
|
||||||
/**
|
|
||||||
* List of Id of the specific covers
|
|
||||||
*/
|
|
||||||
covers: zod.array(ZodObjectId).nullable().optional(),
|
|
||||||
|
|
||||||
});
|
export const ZodSeasonWrite = ZodSeason.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type SeasonWrite = zod.infer<typeof ZodSeasonWrite>;
|
export type SeasonWrite = zod.infer<typeof ZodSeasonWrite>;
|
||||||
|
|
@ -4,8 +4,8 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodObjectId} from "./object-id";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -23,7 +23,7 @@ export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* List of Id of the specific covers
|
* List of Id of the specific covers
|
||||||
*/
|
*/
|
||||||
covers: zod.array(ZodObjectId).optional(),
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -38,25 +38,14 @@ export function isSeries(data: any): data is Series {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodSeriesWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|
||||||
/**
|
|
||||||
* Name of the media (this represent the title)
|
|
||||||
*/
|
|
||||||
name: zod.string().optional(),
|
|
||||||
/**
|
|
||||||
* Description of the media
|
|
||||||
*/
|
|
||||||
description: zod.string().nullable().optional(),
|
|
||||||
/**
|
|
||||||
* series parent ID
|
|
||||||
*/
|
|
||||||
parentId: ZodLong.optional(),
|
|
||||||
/**
|
|
||||||
* List of Id of the specific covers
|
|
||||||
*/
|
|
||||||
covers: zod.array(ZodObjectId).nullable().optional(),
|
|
||||||
|
|
||||||
});
|
export const ZodSeriesWrite = ZodSeries.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type SeriesWrite = zod.infer<typeof ZodSeriesWrite>;
|
export type SeriesWrite = zod.infer<typeof ZodSeriesWrite>;
|
||||||
|
|
@ -3,8 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodObjectId} from "./object-id";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodType = ZodGenericDataSoftDelete.extend({
|
export const ZodType = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -18,7 +18,7 @@ export const ZodType = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* List of Id of the specific covers
|
* List of Id of the specific covers
|
||||||
*/
|
*/
|
||||||
covers: zod.array(ZodObjectId).optional(),
|
covers: zod.array(ZodUUID),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -33,21 +33,14 @@ export function isType(data: any): data is Type {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodTypeWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|
||||||
/**
|
|
||||||
* Name of the media (this represent the title)
|
|
||||||
*/
|
|
||||||
name: zod.string().optional(),
|
|
||||||
/**
|
|
||||||
* Description of the media
|
|
||||||
*/
|
|
||||||
description: zod.string().nullable().optional(),
|
|
||||||
/**
|
|
||||||
* List of Id of the specific covers
|
|
||||||
*/
|
|
||||||
covers: zod.array(ZodObjectId).nullable().optional(),
|
|
||||||
|
|
||||||
});
|
export const ZodTypeWrite = ZodType.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type TypeWrite = zod.infer<typeof ZodTypeWrite>;
|
export type TypeWrite = zod.infer<typeof ZodTypeWrite>;
|
||||||
|
|
@ -3,9 +3,11 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodUser, ZodUserWrite } from "./user";
|
import {ZodUser} from "./user";
|
||||||
|
|
||||||
export const ZodUserKarideo = ZodUser;
|
export const ZodUserKarideo = ZodUser.extend({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
export type UserKarideo = zod.infer<typeof ZodUserKarideo>;
|
export type UserKarideo = zod.infer<typeof ZodUserKarideo>;
|
||||||
|
|
||||||
@ -18,7 +20,14 @@ export function isUserKarideo(data: any): data is UserKarideo {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodUserKarideoWrite = ZodUserWrite;
|
|
||||||
|
export const ZodUserKarideoWrite = ZodUserKarideo.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type UserKarideoWrite = zod.infer<typeof ZodUserKarideoWrite>;
|
export type UserKarideoWrite = zod.infer<typeof ZodUserKarideoWrite>;
|
||||||
|
|
@ -6,13 +6,13 @@ import { z as zod } from "zod";
|
|||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodFloat} from "./float";
|
import {ZodFloat} from "./float";
|
||||||
import {ZodInteger} from "./integer";
|
import {ZodInteger} from "./integer";
|
||||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
|
export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
* Foreign Key Id of the user
|
* Foreign Key Id of the user
|
||||||
*/
|
*/
|
||||||
userId: ZodLong.optional(),
|
userId: ZodLong,
|
||||||
/**
|
/**
|
||||||
* Id of the media
|
* Id of the media
|
||||||
*/
|
*/
|
||||||
@ -43,29 +43,14 @@ export function isUserMediaAdvancement(data: any): data is UserMediaAdvancement
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodUserMediaAdvancementWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|
||||||
/**
|
|
||||||
* Foreign Key Id of the user
|
|
||||||
*/
|
|
||||||
userId: ZodLong.nullable().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 const ZodUserMediaAdvancementWrite = ZodUserMediaAdvancement.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type UserMediaAdvancementWrite = zod.infer<typeof ZodUserMediaAdvancementWrite>;
|
export type UserMediaAdvancementWrite = zod.infer<typeof ZodUserMediaAdvancementWrite>;
|
||||||
|
|
@ -7,7 +7,7 @@ import {ZodLong} from "./long";
|
|||||||
|
|
||||||
export const ZodUserOut = zod.object({
|
export const ZodUserOut = zod.object({
|
||||||
id: ZodLong,
|
id: ZodLong,
|
||||||
login: zod.string().optional(),
|
login: zod.string().max(255).optional(),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,11 +22,8 @@ export function isUserOut(data: any): data is UserOut {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodUserOutWrite = zod.object({
|
|
||||||
id: ZodLong,
|
|
||||||
login: zod.string().nullable().optional(),
|
|
||||||
|
|
||||||
});
|
export const ZodUserOutWrite = ZodUserOut.partial();
|
||||||
|
|
||||||
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
||||||
|
|
@ -5,13 +5,14 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
import {ZodTimestamp} from "./timestamp";
|
import {ZodTimestamp} from "./timestamp";
|
||||||
import {ZodUUID} from "./uuid";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||||
login: zod.string().min(3).max(128),
|
login: zod.string().max(128).optional(),
|
||||||
lastConnection: ZodTimestamp.optional(),
|
lastConnection: ZodTimestamp.optional(),
|
||||||
blocked: zod.boolean().optional(),
|
admin: zod.boolean(),
|
||||||
blockedReason: zod.string().max(512).optional(),
|
blocked: zod.boolean(),
|
||||||
|
removed: zod.boolean(),
|
||||||
/**
|
/**
|
||||||
* List of Id of the specific covers
|
* List of Id of the specific covers
|
||||||
*/
|
*/
|
||||||
@ -30,17 +31,14 @@ export function isUser(data: any): data is User {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const ZodUserWrite = ZodGenericDataSoftDeleteWrite.extend({
|
|
||||||
login: zod.string().min(3).max(128).optional(),
|
|
||||||
lastConnection: ZodTimestamp.nullable().optional(),
|
|
||||||
blocked: zod.boolean().nullable().optional(),
|
|
||||||
blockedReason: zod.string().max(512).nullable().optional(),
|
|
||||||
/**
|
|
||||||
* List of Id of the specific covers
|
|
||||||
*/
|
|
||||||
covers: zod.array(ZodUUID).nullable().optional(),
|
|
||||||
|
|
||||||
});
|
export const ZodUserWrite = ZodUser.omit({
|
||||||
|
deleted: true,
|
||||||
|
id: true,
|
||||||
|
createdAt: true,
|
||||||
|
updatedAt: true,
|
||||||
|
|
||||||
|
}).partial();
|
||||||
|
|
||||||
export type UserWrite = zod.infer<typeof ZodUserWrite>;
|
export type UserWrite = zod.infer<typeof ZodUserWrite>;
|
||||||
|
|
@ -7,15 +7,11 @@
|
|||||||
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||||
|
|
||||||
export enum HTTPRequestModel {
|
export enum HTTPRequestModel {
|
||||||
ARCHIVE = "ARCHIVE",
|
|
||||||
DELETE = "DELETE",
|
DELETE = "DELETE",
|
||||||
HEAD = "HEAD",
|
|
||||||
GET = "GET",
|
GET = "GET",
|
||||||
OPTION = "OPTION",
|
|
||||||
PATCH = "PATCH",
|
PATCH = "PATCH",
|
||||||
POST = "POST",
|
POST = "POST",
|
||||||
PUT = "PUT",
|
PUT = "PUT",
|
||||||
RESTORE = "RESTORE",
|
|
||||||
}
|
}
|
||||||
export enum HTTPMimeType {
|
export enum HTTPMimeType {
|
||||||
ALL = "*/*",
|
ALL = "*/*",
|
||||||
@ -78,7 +74,7 @@ export interface RESTRequestType {
|
|||||||
data?: any;
|
data?: any;
|
||||||
params?: object;
|
params?: object;
|
||||||
queries?: object;
|
queries?: object;
|
||||||
callbacks?: RESTCallbacks;
|
callback?: RESTCallbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAll(input, searchValue, replaceValue) {
|
function replaceAll(input, searchValue, replaceValue) {
|
||||||
@ -241,7 +237,7 @@ export function RESTRequest({
|
|||||||
data,
|
data,
|
||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
callbacks,
|
callback,
|
||||||
}: RESTRequestType): Promise<ModelResponseHttp> {
|
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||||
// Create the URL PATH:
|
// Create the URL PATH:
|
||||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||||
@ -252,14 +248,9 @@ export function RESTRequest({
|
|||||||
if (restModel.accept !== undefined) {
|
if (restModel.accept !== undefined) {
|
||||||
headers["Accept"] = restModel.accept;
|
headers["Accept"] = restModel.accept;
|
||||||
}
|
}
|
||||||
if (restModel.requestType !== HTTPRequestModel.GET &&
|
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||||
restModel.requestType !== HTTPRequestModel.ARCHIVE &&
|
|
||||||
restModel.requestType !== HTTPRequestModel.RESTORE
|
|
||||||
) {
|
|
||||||
// if Get we have not a content type, the body is empty
|
// if Get we have not a content type, the body is empty
|
||||||
if (restModel.contentType !== HTTPMimeType.MULTIPART &&
|
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||||
restModel.contentType !== undefined
|
|
||||||
) {
|
|
||||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||||
headers["Content-Type"] = restModel.contentType;
|
headers["Content-Type"] = restModel.contentType;
|
||||||
}
|
}
|
||||||
@ -277,10 +268,10 @@ export function RESTRequest({
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let action: undefined | Promise<Response> = undefined;
|
let action: undefined | Promise<Response> = undefined;
|
||||||
if (
|
if (
|
||||||
isNullOrUndefined(callbacks) ||
|
isNullOrUndefined(callback) ||
|
||||||
(isNullOrUndefined(callbacks.progressDownload) &&
|
(isNullOrUndefined(callback.progressDownload) &&
|
||||||
isNullOrUndefined(callbacks.progressUpload) &&
|
isNullOrUndefined(callback.progressUpload) &&
|
||||||
isNullOrUndefined(callbacks.abortHandle))
|
isNullOrUndefined(callback.abortHandle))
|
||||||
) {
|
) {
|
||||||
// No information needed: call the generic fetch interface
|
// No information needed: call the generic fetch interface
|
||||||
action = fetch(generateUrl, {
|
action = fetch(generateUrl, {
|
||||||
@ -297,7 +288,7 @@ export function RESTRequest({
|
|||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
},
|
},
|
||||||
callbacks
|
callback
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
action
|
action
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user