Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
d44396ccee |
4
.gitignore
vendored
4
.gitignore
vendored
@ -53,8 +53,6 @@ testem.log
|
||||
# System Files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
/env_dev/data
|
||||
/env_dev/dataMongo
|
||||
|
||||
backPY/env
|
||||
|
||||
@ -64,5 +62,3 @@ __pycache__
|
||||
|
||||
.design/
|
||||
.vscode/
|
||||
front/storybook-static
|
||||
back/bin
|
||||
|
78
Dockerfile
78
Dockerfile
@ -3,31 +3,23 @@
|
||||
## buyilding-end install applications:
|
||||
##
|
||||
######################################################################################
|
||||
FROM archlinux:base-devel AS common
|
||||
FROM archlinux:base-devel AS builder
|
||||
# update system
|
||||
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||
&& pacman -S --noconfirm jdk-openjdk wget\
|
||||
&& pacman -Scc --noconfirm
|
||||
|
||||
WORKDIR /tmp
|
||||
|
||||
FROM common AS builder
|
||||
# update system
|
||||
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||
&& pacman -S --noconfirm maven npm pnpm \
|
||||
&& pacman -S --noconfirm jdk-openjdk maven npm pnpm \
|
||||
&& pacman -Scc --noconfirm
|
||||
|
||||
ENV PATH /tmp/node_modules/.bin:$PATH
|
||||
WORKDIR /tmp
|
||||
|
||||
######################################################################################
|
||||
##
|
||||
## Build back:
|
||||
##
|
||||
######################################################################################
|
||||
FROM builder AS build_back
|
||||
COPY back/pom.xml ./
|
||||
COPY back/Formatter.xml ./
|
||||
COPY back/src ./src/
|
||||
FROM builder AS buildBack
|
||||
COPY back/pom.xml /tmp
|
||||
COPY back/src /tmp/src/
|
||||
RUN mvn clean compile assembly:single
|
||||
|
||||
######################################################################################
|
||||
@ -35,44 +27,27 @@ RUN mvn clean compile assembly:single
|
||||
## Build front:
|
||||
##
|
||||
######################################################################################
|
||||
FROM builder AS dependency_front
|
||||
FROM builder AS buildFront
|
||||
|
||||
RUN echo "@kangaroo-and-rabbit:registry=https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/npm/" > /root/.npmrc
|
||||
|
||||
ADD front/package.json \
|
||||
front/pnpm-lock.yaml \
|
||||
./
|
||||
ADD front/src/theme ./src/theme
|
||||
front/karma.conf.js \
|
||||
front/protractor.conf.js \
|
||||
/tmp/
|
||||
|
||||
# install and cache app dependencies
|
||||
RUN pnpm install --prod=false
|
||||
RUN pnpm install
|
||||
|
||||
###############################################################
|
||||
## Install sources
|
||||
###############################################################
|
||||
FROM dependency_front AS load_sources_front
|
||||
|
||||
# JUST to get the vertion of the application and his sha...
|
||||
COPY \
|
||||
ADD front/e2e \
|
||||
front/tsconfig.json \
|
||||
front/tsconfig.node.json \
|
||||
front/vite.config.mts \
|
||||
front/index.html \
|
||||
./
|
||||
front/tslint.json \
|
||||
front/angular.json \
|
||||
/tmp/
|
||||
ADD front/src /tmp/src
|
||||
|
||||
COPY front/public ./public
|
||||
COPY front/src ./src
|
||||
|
||||
#We are not in prod mode ==> we need to overwrite the production env.
|
||||
ARG env=front/.env.production
|
||||
COPY ${env} .env
|
||||
|
||||
###############################################################
|
||||
## Build the sources
|
||||
###############################################################
|
||||
FROM load_sources_front AS build_front
|
||||
# build in bundle mode all the application
|
||||
RUN pnpm static:build
|
||||
# generate build
|
||||
RUN ng build --output-path=dist --configuration=production --base-href=/karideo/ --deploy-url=/karideo/
|
||||
|
||||
######################################################################################
|
||||
##
|
||||
@ -80,22 +55,17 @@ RUN pnpm static:build
|
||||
##
|
||||
######################################################################################
|
||||
|
||||
#FROM bellsoft/liberica-openjdk-alpine:latest
|
||||
## add wget to manage the health check...
|
||||
#RUN apk add --no-cache wget
|
||||
FROM common
|
||||
FROM bellsoft/liberica-openjdk-alpine:latest
|
||||
# add wget to manage the health check...
|
||||
RUN apk add --no-cache wget
|
||||
|
||||
ENV LANG C.UTF-8
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
COPY --from=build_back /tmp/out/maven/*.jar /application/application.jar
|
||||
COPY --from=build_front /tmp/dist /application/front/
|
||||
COPY --from=buildBack /tmp/out/maven/*.jar /application/application.jar
|
||||
COPY --from=buildFront /tmp/dist /application/front/
|
||||
|
||||
WORKDIR /application/
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
||||
HEALTHCHECK --start-period=10s --start-interval=2s --interval=30s --timeout=5s --retries=10 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80/api/health_check || exit 1
|
||||
|
||||
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karideo.WebLauncher"]
|
||||
|
125
README.md
125
README.md
@ -1,125 +0,0 @@
|
||||
Karideo
|
||||
=======
|
||||
|
||||
**K**angaroo **A**nd **R**abbit (v)ideo is a simple framework to propose video streaming for personal network
|
||||
|
||||
Run in local:
|
||||
=============
|
||||
|
||||
Start tools
|
||||
-----------
|
||||
|
||||
Start the server basic interfaces: (DB(mySQL), Adminer)
|
||||
|
||||
```{.bash}
|
||||
# start the Bdd interface (no big data > 50Mo)
|
||||
docker compose -f env_dev/docker-compose.yaml up -d
|
||||
```
|
||||
|
||||
Start the Back-end:
|
||||
-------------------
|
||||
|
||||
backend is developed in JAVA
|
||||
|
||||
The first step is configuring your JAVA version (or select the JVM with the OS)
|
||||
```bash
|
||||
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
|
||||
```
|
||||
|
||||
Install the dependency:
|
||||
```bash
|
||||
mvn install
|
||||
```
|
||||
|
||||
Run the test
|
||||
```bash
|
||||
mvn test
|
||||
```
|
||||
|
||||
Install it for external use
|
||||
```bash
|
||||
mvn install
|
||||
```
|
||||
|
||||
Execute the local server:
|
||||
```bash
|
||||
mvn exec:java@dev-mode
|
||||
```
|
||||
|
||||
Start the Front-end:
|
||||
--------------------
|
||||
|
||||
backend is developed in JAVA
|
||||
```bash
|
||||
cd front
|
||||
pnpm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Display the result:
|
||||
-------------------
|
||||
|
||||
[show the webpage: http://localhost:4203](http://localhost:4203)
|
||||
|
||||
Some other dev tools:
|
||||
=====================
|
||||
|
||||
Format code:
|
||||
------------
|
||||
|
||||
```bash
|
||||
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
|
||||
mvn formatter:format
|
||||
mvn test
|
||||
```
|
||||
|
||||
Tools in production mode
|
||||
========================
|
||||
|
||||
Changing the Log Level
|
||||
----------------------
|
||||
|
||||
In a production environment, you can adjust the log level to help diagnose bugs more effectively.
|
||||
|
||||
The available log levels are:
|
||||
| **Log Level Tag** | **org.kar.karideo** | **org.kar.archidata** | **other** |
|
||||
| ----------------- | ------------------- | --------------------- | --------- |
|
||||
| `prod` | INFO | INFO | INFO |
|
||||
| `prod-debug` | DEBUG | INFO | INFO |
|
||||
| `prod-trace` | TRACE | DEBUG | INFO |
|
||||
| `prod-trace-full` | TRACE | TRACE | INFO |
|
||||
| `dev` | TRACE | DEBUG | INFO |
|
||||
|
||||
|
||||
Manual set in production:
|
||||
=========================
|
||||
|
||||
Connect on the registry
|
||||
------------------------
|
||||
|
||||
To log-in and log-out from the registry:
|
||||
```bash
|
||||
export REGISTRY_ADDRESS=gitea.atria-soft.org
|
||||
docker login -u <<YOUR_USER_NAME>> ${REGISTRY_ADDRESS}
|
||||
docker logout ${REGISTRY_ADDRESS}
|
||||
```
|
||||
|
||||
pull the root image of dockers
|
||||
------------------------------
|
||||
|
||||
```bash
|
||||
docker pull archlinux:base-devel
|
||||
docker pull bellsoft/liberica-openjdk-alpine:latest
|
||||
```
|
||||
|
||||
Create the version
|
||||
------------------
|
||||
|
||||
Execute in the local folder: (use ```dev``` for development and ```latest``` for production release)
|
||||
|
||||
```bash
|
||||
export TAG_DOCKER=latest
|
||||
export REGISTRY_ADDRESS=gitea.atria-soft.org
|
||||
docker build -t ${REGISTRY_ADDRESS}/kangaroo-and-rabbit/karideo:${TAG_DOCKER} .
|
||||
docker push ${REGISTRY_ADDRESS}/kangaroo-and-rabbit/karideo:${TAG_DOCKER}
|
||||
```
|
@ -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 src /tmp/src/
|
||||
COPY Formatter.xml /tmp/
|
||||
WORKDIR /tmp/
|
||||
RUN mvn clean compile assembly:single
|
||||
|
||||
|
151
back/pom.xml
151
back/pom.xml
@ -5,9 +5,9 @@
|
||||
<artifactId>karideo</artifactId>
|
||||
<version>0.3.0</version>
|
||||
<properties>
|
||||
<maven.compiler.version>3.13.0</maven.compiler.version>
|
||||
<maven.compiler.source>23</maven.compiler.source>
|
||||
<maven.compiler.target>23</maven.compiler.target>
|
||||
<maven.compiler.version>3.1</maven.compiler.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.dependency.version>3.1.1</maven.dependency.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
@ -20,34 +20,17 @@
|
||||
<dependency>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.24.0</version>
|
||||
<version>0.12.0</version>
|
||||
</dependency>
|
||||
<!-- Loopback of logger JDK logging API to SLF4J -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>2.0.9</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>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.1.0-alpha1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<version>2.17.1</version>
|
||||
</dependency>
|
||||
<!--
|
||||
************************************************************
|
||||
@ -57,24 +40,24 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.11.0</version>
|
||||
<version>5.11.0-M2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.11.0</version>
|
||||
<version>5.11.0-M2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.24.1</version>
|
||||
<version>2.24.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
@ -104,45 +87,16 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>prod-mode</id>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
<version>1.4.0</version>
|
||||
<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>
|
||||
<mainClass/>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Create the source bundle -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>4.0.0-beta-1</version>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
@ -156,12 +110,10 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.2.5</version>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.7.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
@ -173,21 +125,80 @@
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</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 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<show>private</show>
|
||||
<nohelp>true</nohelp>
|
||||
</configuration>
|
||||
</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>
|
||||
<groupId>net.revelc.code.formatter</groupId>
|
||||
<artifactId>formatter-maven-plugin</artifactId>
|
||||
<version>2.24.1</version>
|
||||
<version>2.23.0</version>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<lineEnding>LF</lineEnding>
|
||||
@ -218,6 +229,14 @@
|
||||
<configuration>
|
||||
<includeFilterFile>spotbugs-security-include.xml</includeFilterFile>
|
||||
<excludeFilterFile>spotbugs-security-exclude.xml</excludeFilterFile>
|
||||
<!--<plugins>
|
||||
<plugin>
|
||||
<groupId>com.h3xstream.findsecbugs</groupId>
|
||||
<artifactId>findsecbugs-plugin</artifactId>
|
||||
<version>1.12.0</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
-->
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@ -228,7 +247,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.2.0</version>
|
||||
<configuration>
|
||||
<show>public</show>
|
||||
</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;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import org.glassfish.grizzly.http.server.HttpServer;
|
||||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
|
||||
import org.glassfish.jersey.jackson.JacksonFeature;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.UpdateJwtPublicKey;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.catcher.GenericCatcher;
|
||||
import org.kar.archidata.db.DbConfig;
|
||||
import org.kar.archidata.db.DBConfig;
|
||||
import org.kar.archidata.filter.CORSFilter;
|
||||
import org.kar.archidata.filter.OptionFilter;
|
||||
import org.kar.archidata.migration.MigrationEngine;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.archidata.tools.ContextGenericTools;
|
||||
import org.kar.karideo.api.Front;
|
||||
import org.kar.karideo.api.HealthCheck;
|
||||
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.Migration20231126;
|
||||
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.LoggerFactory;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
|
||||
import jakarta.ws.rs.core.UriBuilder;
|
||||
|
||||
public class WebLauncher {
|
||||
final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
|
||||
public static DBConfig dbConfig;
|
||||
protected UpdateJwtPublicKey keyUpdater = null;
|
||||
protected HttpServer server = null;
|
||||
|
||||
@ -62,18 +59,12 @@ public class WebLauncher {
|
||||
migrationEngine.add(new Migration20231015());
|
||||
migrationEngine.add(new Migration20231126());
|
||||
migrationEngine.add(new Migration20240226());
|
||||
migrationEngine.add(new Migration20240611());
|
||||
migrationEngine.add(new Migration20250214());
|
||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||
migrationEngine.migrateWaitAdmin(new DbConfig());
|
||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||
}
|
||||
|
||||
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");
|
||||
final WebLauncher launcher = new WebLauncher();
|
||||
launcher.migrateDB();
|
||||
@ -113,7 +104,7 @@ public class WebLauncher {
|
||||
|
||||
rc.register(HealthCheck.class);
|
||||
rc.register(Front.class);
|
||||
ContextGenericTools.addJsr310(rc);
|
||||
|
||||
// add jackson to be discover when we are ins stand-alone server
|
||||
rc.register(JacksonFeature.class);
|
||||
// enable this to show low level request
|
||||
|
@ -1,25 +1,40 @@
|
||||
|
||||
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.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.LoggerFactory;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
|
||||
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() {}
|
||||
|
||||
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 {
|
||||
// Loop-back of logger JDK logging API to SLF4J
|
||||
LogManager.getLogManager().reset();
|
||||
SLF4JBridgeHandler.install();
|
||||
// Generate the APIs in type-script
|
||||
Initialization.generateObjects();
|
||||
generateObjects();
|
||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||
launcher.process();
|
||||
LOGGER.info("end-configure the server & wait finish process:");
|
||||
@ -33,7 +48,6 @@ public class WebLauncherLocal extends WebLauncher {
|
||||
// for local test:
|
||||
ConfigBaseVariable.apiAdress = "http://0.0.0.0:18080/karideo/api/";
|
||||
ConfigBaseVariable.dbPort = "3906";
|
||||
ConfigBaseVariable.testMode = "true";
|
||||
}
|
||||
try {
|
||||
super.migrateDB();
|
||||
|
@ -11,9 +11,8 @@ import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.dataAccess.DBAccess;
|
||||
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.InputException;
|
||||
import org.kar.archidata.model.Data;
|
||||
@ -78,9 +77,6 @@ public class MediaResource {
|
||||
if (data.contentEquals("null")) {
|
||||
return null;
|
||||
}
|
||||
if (data.contentEquals("undefined")) {
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -89,43 +85,34 @@ public class MediaResource {
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Operation(description = "Create a new Media", tags = "GLOBAL")
|
||||
@TypeScriptProgress
|
||||
public Media uploadMedia( //
|
||||
// @AsyncType(Long.class) @FormDataParam("universeId") String universeId, //
|
||||
// @AsyncType(Long.class) @FormDataParam("typeId") String typeId, //
|
||||
// @AsyncType(Long.class) @FormDataParam("seriesId") String seriesId, //
|
||||
// @AsyncType(Long.class) @FormDataParam("season") String season, // value of the season ==> local add if needed
|
||||
// @AsyncType(Long.class) @FormDataParam("episode") String episode, // value of the season ==> local add if needed
|
||||
@FormDataParam("universeId") String universeId, //
|
||||
@FormDataParam("typeId") String typeId, //
|
||||
@FormDataParam("seriesId") String seriesId, //
|
||||
@FormDataParam("season") String season, // value of the season ==> local add if needed
|
||||
@FormDataParam("episode") String episode, // value of the season ==> local add if needed
|
||||
public Media uploadFile( //
|
||||
@FormDataParam("fileName") String fileName, //
|
||||
@FormDataParam("universe") String universe, //
|
||||
@FormDataParam("series") String series, //
|
||||
// @FormDataParam("seriesId") String seriesId, // Not used ...
|
||||
@FormDataParam("season") String season, //
|
||||
@FormDataParam("episode") String episode, //
|
||||
@FormDataParam("title") String title, //
|
||||
@FormDataParam("typeId") String typeId, //
|
||||
@FormDataParam("file") final InputStream fileInputStream, //
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData //
|
||||
) throws FailException {
|
||||
try (DBAccess db = DBAccess.createInterface()) {
|
||||
try {
|
||||
// correct input string stream :
|
||||
final String fileName = multipartCorrection(fileMetaData.getFileName());
|
||||
universeId = multipartCorrection(universeId);
|
||||
final Long universeIdLong = universeId != null ? Long.parseLong(universeId) : null;
|
||||
typeId = multipartCorrection(typeId);
|
||||
final Long typeIdLong = typeId != null ? Long.parseLong(typeId) : null;
|
||||
seriesId = multipartCorrection(seriesId);
|
||||
final Long seriesIdLong = seriesId != null ? Long.parseLong(seriesId) : null;
|
||||
fileName = multipartCorrection(fileName);
|
||||
universe = multipartCorrection(universe);
|
||||
series = multipartCorrection(series);
|
||||
season = multipartCorrection(season);
|
||||
final Long seasonLong = season != null ? Long.parseLong(season) : null;
|
||||
episode = multipartCorrection(episode);
|
||||
title = multipartCorrection(title);
|
||||
|
||||
// todo: check if all remotes Id exist ...
|
||||
typeId = multipartCorrection(typeId);
|
||||
|
||||
// public NodeSmall uploadFile(final FormDataMultiPart form) {
|
||||
LOGGER.info("Upload media file: {}", fileMetaData);
|
||||
LOGGER.info(" - fileName: {}", fileName);
|
||||
LOGGER.info(" - universe: {}", universeIdLong);
|
||||
LOGGER.info(" - series: {}", seriesIdLong);
|
||||
LOGGER.info(" - season: {}", seasonLong);
|
||||
LOGGER.info(" - universe: {}", universe);
|
||||
LOGGER.info(" - series: {}", series);
|
||||
LOGGER.info(" - season: {}", season);
|
||||
LOGGER.info(" - episode: {}", episode);
|
||||
LOGGER.info(" - title: {}", title);
|
||||
LOGGER.info(" - type: {}", typeId);
|
||||
@ -138,12 +125,12 @@ public class MediaResource {
|
||||
|
||||
final long tmpUID = DataResource.getTmpDataId();
|
||||
final String sha512 = DataResource.saveTemporaryFile(fileInputStream, tmpUID);
|
||||
Data data = DataTools.getWithSha512(db, sha512);
|
||||
Data data = DataResource.getWithSha512(sha512);
|
||||
if (data == null) {
|
||||
LOGGER.info("Need to add the data in the BDD ... ");
|
||||
System.out.flush();
|
||||
try {
|
||||
data = DataTools.createNewData(db, tmpUID, fileName, sha512);
|
||||
data = DataResource.createNewData(tmpUID, fileName, sha512);
|
||||
} catch (final IOException ex) {
|
||||
DataResource.removeTemporaryFile(tmpUID);
|
||||
ex.printStackTrace();
|
||||
@ -152,7 +139,7 @@ public class MediaResource {
|
||||
} else if (data != null && data.deleted != null && data.deleted) {
|
||||
LOGGER.info("Data already exist but deleted");
|
||||
System.out.flush();
|
||||
DataTools.undelete(db, data.oid);
|
||||
DataTools.undelete(data.uuid);
|
||||
data.deleted = false;
|
||||
} else {
|
||||
LOGGER.info("Data already exist ... all good");
|
||||
@ -161,32 +148,26 @@ public class MediaResource {
|
||||
// Fist step: retieve all the Id of each parents:...
|
||||
LOGGER.info("Find typeNode");
|
||||
// check if id of type exist:
|
||||
final Type typeNode = TypeResource.getId(typeIdLong);
|
||||
final Type typeNode = TypeResource.getId(Long.parseLong(typeId));
|
||||
if (typeNode == null) {
|
||||
DataResource.removeTemporaryFile(tmpUID);
|
||||
throw new InputException("typeId", "TypeId does not exist ...");
|
||||
}
|
||||
// check if id of type exist:
|
||||
LOGGER.info(" ==> {}", typeNode);
|
||||
LOGGER.info("Find seriesNode");
|
||||
// get uid of group:
|
||||
Series seriesNode = null;
|
||||
if (seriesIdLong != null) {
|
||||
seriesNode = SeriesResource.getId(seriesIdLong);
|
||||
if (seriesNode == null) {
|
||||
DataResource.removeTemporaryFile(tmpUID);
|
||||
throw new InputException("seriesId", "seriesId does not exist ...");
|
||||
}
|
||||
if (seriesNode.parentId != typeNode.id) {
|
||||
DataResource.removeTemporaryFile(tmpUID);
|
||||
throw new InputException("seriesId", "seriesId object have not the correct parent...");
|
||||
}
|
||||
if (series != null) {
|
||||
seriesNode = SeriesResource.getOrCreate(series, typeNode.id);
|
||||
}
|
||||
|
||||
LOGGER.info(" ==> {}", seriesNode);
|
||||
LOGGER.info("Find seasonNode");
|
||||
// get uid of season:
|
||||
Season seasonNode = null;
|
||||
if (seriesNode == null && seasonLong != null) {
|
||||
if (seriesNode == null && season != null) {
|
||||
DataResource.removeTemporaryFile(tmpUID);
|
||||
throw new InputException("season", "Season is set but no series is set !!");
|
||||
throw new InputException("season", "Season is set but no seraies is set !!");
|
||||
}
|
||||
if (season != null) {
|
||||
seasonNode = SeasonResource.getOrCreate(season, seriesNode.id);
|
||||
@ -198,7 +179,7 @@ public class MediaResource {
|
||||
try {
|
||||
final Media media = new Media();
|
||||
media.name = title;
|
||||
media.dataId = data.oid;
|
||||
media.dataId = data.uuid;
|
||||
media.typeId = typeNode.id;
|
||||
media.seriesId = null;
|
||||
if (seriesNode != null) {
|
||||
@ -212,7 +193,7 @@ public class MediaResource {
|
||||
if (episode != null && !episode.contentEquals("")) {
|
||||
media.episode = Integer.parseInt(episode);
|
||||
}
|
||||
final Media out = db.insert(media);
|
||||
final Media out = DataAccess.insert(media);
|
||||
LOGGER.info("Generate new media {}", out);
|
||||
return out;
|
||||
} catch (final SQLException ex) {
|
||||
@ -238,13 +219,12 @@ public class MediaResource {
|
||||
@TypeScriptProgress
|
||||
public Media uploadCover( //
|
||||
@PathParam("id") final Long id, //
|
||||
@FormDataParam("fileName") final String fileName, //
|
||||
@FormDataParam("file") final InputStream fileInputStream, //
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData//
|
||||
) throws Exception {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
DataTools.uploadCover(dbIo, Media.class, id, fileInputStream, fileMetaData);
|
||||
return dbIo.get(Media.class, id);
|
||||
}
|
||||
DataTools.uploadCover(Media.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Media.class, id);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@ -255,10 +235,8 @@ public class MediaResource {
|
||||
@PathParam("id") final Long id, //
|
||||
@PathParam("coverId") final UUID coverId //
|
||||
) throws Exception {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
AddOnDataJson.removeLink(dbIo, Media.class, "id", id, "covers", coverId);
|
||||
return dbIo.get(Media.class, id);
|
||||
}
|
||||
AddOnDataJson.removeLink(Media.class, id, "covers", coverId);
|
||||
return DataAccess.get(Media.class, id);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
|
@ -8,11 +8,10 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||
import org.glassfish.jersey.media.multipart.FormDataParam;
|
||||
import org.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||
import org.kar.archidata.dataAccess.DBAccess;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
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.tools.DataTools;
|
||||
import org.kar.karideo.model.Season;
|
||||
@ -86,12 +85,10 @@ public class SeasonResource {
|
||||
@Consumes(MediaType.MULTIPART_FORM_DATA)
|
||||
@Operation(description = "Upload a new season cover season", tags = "GLOBAL")
|
||||
@TypeScriptProgress
|
||||
public Season uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
|
||||
throws Exception {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
DataTools.uploadCover(dbIo, Season.class, id, fileInputStream, fileMetaData);
|
||||
return dbIo.get(Season.class, id);
|
||||
}
|
||||
public Season uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Season.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Season.class, id);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@ -99,10 +96,8 @@ public class SeasonResource {
|
||||
@RolesAllowed("ADMIN")
|
||||
@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 {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
AddOnDataJson.removeLink(dbIo, Season.class, "id", id, "covers", coverId);
|
||||
return dbIo.get(Season.class, id);
|
||||
}
|
||||
AddOnDataJson.removeLink(Season.class, id, "covers", coverId);
|
||||
return DataAccess.get(Season.class, id);
|
||||
}
|
||||
|
||||
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.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||
import org.kar.archidata.dataAccess.DBAccess;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.QueryAnd;
|
||||
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.tools.DataTools;
|
||||
import org.kar.karideo.model.Series;
|
||||
@ -52,9 +51,6 @@ public class SeriesResource {
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
|
||||
public static Series getId(final Long id) throws Exception {
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
/* ============================================================================= ADMIN SECTION: ============================================================================= */
|
||||
|
||||
@POST
|
||||
@ -89,12 +85,10 @@ public class SeriesResource {
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Operation(description = "Upload a new season cover Series", tags = "GLOBAL")
|
||||
@TypeScriptProgress
|
||||
public Series uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
|
||||
throws Exception {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
DataTools.uploadCover(dbIo, Series.class, id, fileInputStream, fileMetaData);
|
||||
return dbIo.get(Series.class, id);
|
||||
}
|
||||
public Series uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Series.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@ -102,10 +96,8 @@ public class SeriesResource {
|
||||
@RolesAllowed("ADMIN")
|
||||
@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 {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
AddOnDataJson.removeLink(dbIo, Series.class, "id", id, "covers", coverId);
|
||||
return dbIo.get(Series.class, id);
|
||||
}
|
||||
AddOnDataJson.removeLink(Series.class, id, "covers", coverId);
|
||||
return DataAccess.get(Series.class, id);
|
||||
}
|
||||
|
||||
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.kar.archidata.annotation.AsyncType;
|
||||
import org.kar.archidata.annotation.TypeScriptProgress;
|
||||
import org.kar.archidata.dataAccess.DBAccess;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
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.tools.DataTools;
|
||||
import org.kar.karideo.model.Type;
|
||||
@ -89,12 +88,10 @@ public class TypeResource {
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@Operation(description = "Upload a new season cover Type", tags = "GLOBAL")
|
||||
@TypeScriptProgress
|
||||
public Type uploadCover(@PathParam("id") final Long id, @FormDataParam("file") final InputStream fileInputStream, @FormDataParam("file") final FormDataContentDisposition fileMetaData)
|
||||
throws Exception {
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
DataTools.uploadCover(dbIo, Type.class, id, fileInputStream, fileMetaData);
|
||||
return dbIo.get(Type.class, id);
|
||||
}
|
||||
public Type uploadCover(@PathParam("id") final Long id, @FormDataParam("fileName") final String fileName, @FormDataParam("file") final InputStream fileInputStream,
|
||||
@FormDataParam("file") final FormDataContentDisposition fileMetaData) throws Exception {
|
||||
DataTools.uploadCover(Type.class, id, fileName, fileInputStream, fileMetaData);
|
||||
return DataAccess.get(Type.class, id);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@ -102,11 +99,8 @@ public class TypeResource {
|
||||
@RolesAllowed("ADMIN")
|
||||
@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 {
|
||||
|
||||
try (DBAccess dbIo = DBAccess.createInterface()) {
|
||||
AddOnDataJson.removeLink(dbIo, Type.class, "id", id, "covers", coverId);
|
||||
return dbIo.get(Type.class, id);
|
||||
}
|
||||
AddOnDataJson.removeLink(Type.class, id, "covers", coverId);
|
||||
return DataAccess.get(Type.class, id);
|
||||
}
|
||||
|
||||
public static Type getOrCreate(final String name) {
|
||||
|
@ -90,7 +90,7 @@ public class UserMediaAdvancementResource {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -2,22 +2,10 @@ package org.kar.karideo.migration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.dataAccess.DBAccess;
|
||||
import org.kar.archidata.externalRestApi.AnalyzeApi;
|
||||
import org.kar.archidata.externalRestApi.TsGenerateApi;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.migration.MigrationSqlStep;
|
||||
import org.kar.archidata.model.Data;
|
||||
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.Season;
|
||||
import org.kar.karideo.model.Series;
|
||||
@ -38,15 +26,8 @@ public class Initialization extends MigrationSqlStep {
|
||||
return "Initialization";
|
||||
}
|
||||
|
||||
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);
|
||||
api.addModel(JwtToken.class);
|
||||
TsGenerateApi.generateApi(api, "../front/src/back-api/");
|
||||
LOGGER.info("Generate APIs (DONE)");
|
||||
public Initialization() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,21 +36,19 @@ public class Initialization extends MigrationSqlStep {
|
||||
addClass(clazz);
|
||||
}
|
||||
|
||||
addAction((final DBAccess da) -> {
|
||||
final List<Type> data = List.of(//
|
||||
new Type("Documentary", "Documentary (animals, space, earth...)"), //
|
||||
new Type("Movie", "Movie with real humans (film)"), //
|
||||
new Type("Animation", "Animation movies (film)"), //
|
||||
new Type("Short movie", "Small movies (less 2 minutes)"), //
|
||||
new Type("TV show", "TV show for old peoples"), //
|
||||
new Type("Animation TV show", "TV show for young peoples"), //
|
||||
new Type("Theater", "Theater play"), //
|
||||
new Type("One man show", "Recorded stand up"), //
|
||||
new Type("Concert", "Recorded concert"), //
|
||||
new Type("Opera", "Recorded opera") //
|
||||
);
|
||||
da.insertMultiple(data);
|
||||
});
|
||||
addAction("""
|
||||
INSERT INTO `type` (`id`, `name`, `description`) VALUES
|
||||
(UUID_TO_BIN('15237fd7-d4ee-11ee-a8dd-02420a030203'), 'Documentary', 'Documentary (animals, space, earth...)'),
|
||||
(UUID_TO_BIN('553146c1-d4ee-11ee-a8dd-02420a030203'), 'Movie', 'Movie with real humans (film)'),
|
||||
(UUID_TO_BIN('59c430a3-d4ee-11ee-a8dd-02420a030203'), 'Animation', 'Animation movies (film)'),
|
||||
(UUID_TO_BIN('5cd619e3-d4ee-11ee-a8dd-02420a030203'), 'Short movie', 'Small movies (less 2 minutes)'),
|
||||
(UUID_TO_BIN('5fbbf085-d4ee-11ee-a8dd-02420a030203'), 'TV show', 'TV show for old peoples'),
|
||||
(UUID_TO_BIN('66dcb6ba-d4ee-11ee-a8dd-02420a030203'), 'Animation TV show', 'TV show for young peoples'),
|
||||
(UUID_TO_BIN('69ee5c15-d4ee-11ee-a8dd-02420a030203'), 'Theater', 'Theater play'),
|
||||
(UUID_TO_BIN('6ce72530-d4ee-11ee-a8dd-02420a030203'), 'One man show', 'Recorded stand up'),
|
||||
(UUID_TO_BIN('6ff1691a-d4ee-11ee-a8dd-02420a030203'), 'Concert', 'Recorded concert'),
|
||||
(UUID_TO_BIN('730815ef-d4ee-11ee-a8dd-02420a030203'), 'Opera', 'Recorded opera');
|
||||
""");
|
||||
// set start increment element to permit to add after default elements
|
||||
addAction("""
|
||||
ALTER TABLE `media` AUTO_INCREMENT = 1000;
|
||||
@ -88,10 +67,10 @@ public class Initialization extends MigrationSqlStep {
|
||||
""", "mysql");
|
||||
}
|
||||
|
||||
public static void dropAll(final DBAccess da) {
|
||||
public static void dropAll() {
|
||||
for (final Class<?> element : CLASSES_BASE) {
|
||||
try {
|
||||
da.drop(element);
|
||||
DataAccess.drop(element);
|
||||
} catch (final Exception ex) {
|
||||
LOGGER.error("Fail to drop table !!!!!!");
|
||||
ex.printStackTrace();
|
||||
@ -99,10 +78,10 @@ public class Initialization extends MigrationSqlStep {
|
||||
}
|
||||
}
|
||||
|
||||
public static void cleanAll(final DBAccess da) {
|
||||
public static void cleanAll() {
|
||||
for (final Class<?> element : CLASSES_BASE) {
|
||||
try {
|
||||
da.cleanAll(element);
|
||||
DataAccess.cleanAll(element);
|
||||
} catch (final Exception ex) {
|
||||
LOGGER.error("Fail to clean table !!!!!!");
|
||||
ex.printStackTrace();
|
||||
|
@ -1,6 +1,23 @@
|
||||
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.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.LoggerFactory;
|
||||
|
||||
@ -19,6 +36,102 @@ public class Migration20240226 extends MigrationSqlStep {
|
||||
}
|
||||
|
||||
@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,139 +0,0 @@
|
||||
package org.kar.karideo.migration;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
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.archidata.tools.ConfigBaseVariable;
|
||||
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 `dataId` `dataIdOld` binary(16);
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE `media` CHANGE `dataOid` `dataId` binary(12) NOT NULL;
|
||||
""");
|
||||
// Move the files...
|
||||
addAction((final DBAccess da) -> {
|
||||
final String filePath = ConfigBaseVariable.getMediaDataFolder() + "/Migration20250214.txt";
|
||||
try (FileWriter writer = new FileWriter(filePath, true)) {
|
||||
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());
|
||||
}
|
||||
writer.write(origin + " | " + destination + "\n");
|
||||
writer.flush();
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
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.UUID;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.kar.archidata.annotation.DataJson;
|
||||
|
||||
import jakarta.persistence.Id;
|
||||
@ -13,6 +12,4 @@ public class CoverConversion {
|
||||
public Long id = null;
|
||||
@DataJson
|
||||
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 org.bson.types.ObjectId;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
public class MediaConversion {
|
||||
@Id
|
||||
public Long id = null;
|
||||
public UUID dataId = null;
|
||||
public ObjectId dataOid = null;
|
||||
public Long dataId = null;
|
||||
public UUID dataUUID = null;
|
||||
}
|
||||
|
@ -2,12 +2,10 @@ package org.kar.karideo.migration.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
public class OIDConversion {
|
||||
public class UUIDConversion {
|
||||
@Id
|
||||
public Long id = null;
|
||||
public UUID uuid = null;
|
||||
public ObjectId _id = null;
|
||||
}
|
@ -3,7 +3,6 @@ package org.kar.karideo.model;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.kar.archidata.annotation.DataJson;
|
||||
import org.kar.archidata.model.Data;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
@ -11,7 +10,6 @@ import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@ -31,11 +29,7 @@ public class Media extends GenericDataSoftDelete {
|
||||
@Schema(description = "Foreign Key Id of the data")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||
@Column(nullable = false)
|
||||
public ObjectId dataId;
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Data.class)
|
||||
@Column(nullable = false)
|
||||
@Nullable
|
||||
public UUID dataIdOld;
|
||||
public UUID dataId;
|
||||
@Schema(description = "Type of the media")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Type.class)
|
||||
public Long typeId;
|
||||
@ -55,8 +49,7 @@ public class Media extends GenericDataSoftDelete {
|
||||
public Integer ageLimit;
|
||||
@Schema(description = "List of Id of the specific covers")
|
||||
@DataJson(targetEntity = Data.class)
|
||||
@Nullable
|
||||
public List<ObjectId> covers = null;
|
||||
public List<UUID> covers = null;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.kar.karideo.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.annotation.DataJson;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
@ -10,7 +10,6 @@ import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@ -32,6 +31,5 @@ public class Season extends GenericDataSoftDelete {
|
||||
public Long parentId;
|
||||
@Schema(description = "List of Id of the specific covers")
|
||||
@DataJson()
|
||||
@Nullable
|
||||
public List<ObjectId> covers = null;
|
||||
public List<UUID> covers = null;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package org.kar.karideo.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.annotation.DataJson;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
@ -10,7 +10,6 @@ import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@ -32,6 +31,5 @@ public class Series extends GenericDataSoftDelete {
|
||||
public Long parentId;
|
||||
@Schema(description = "List of Id of the specific covers")
|
||||
@DataJson()
|
||||
@Nullable
|
||||
public List<ObjectId> covers = null;
|
||||
public List<UUID> covers = null;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package org.kar.karideo.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.annotation.DataJson;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
@ -10,7 +10,6 @@ import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
@ -26,14 +25,5 @@ public class Type extends GenericDataSoftDelete {
|
||||
public String description;
|
||||
@Schema(description = "List of Id of the specific covers")
|
||||
@DataJson()
|
||||
@Nullable
|
||||
public List<ObjectId> covers = null;
|
||||
|
||||
public Type() {}
|
||||
|
||||
public Type(final String name, final String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public List<UUID> covers = null;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@ -21,7 +20,6 @@ public class UserMediaAdvancement extends GenericDataSoftDelete {
|
||||
@Column(nullable = false)
|
||||
@Schema(description = "Foreign Key Id of the user")
|
||||
@ManyToOne(fetch = FetchType.LAZY, targetEntity = UserKarideo.class)
|
||||
@Nullable
|
||||
public Long userId;
|
||||
@Column(nullable = false)
|
||||
@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.TestMethodOrder;
|
||||
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.RESTApi;
|
||||
import org.kar.karideo.api.HealthCheck.HealthResult;
|
||||
@ -48,7 +49,7 @@ public class TestHealthCheck {
|
||||
webInterface.stop();
|
||||
webInterface = null;
|
||||
LOGGER.info("Remove the test db");
|
||||
// DBEntry.closeAllForceMode();
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
}
|
||||
|
||||
@ -63,7 +64,7 @@ public class TestHealthCheck {
|
||||
@Order(2)
|
||||
@Test
|
||||
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;
|
||||
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.karideo.WebLauncher;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -8,5 +9,26 @@ import org.slf4j.LoggerFactory;
|
||||
public class WebLauncherTest extends WebLauncher {
|
||||
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=karideo/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,92 +1,50 @@
|
||||
{
|
||||
"name": "karideo",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"description": "KAR web music application",
|
||||
"author": {
|
||||
"name": "Edouard DUPIN",
|
||||
"email": "yui.heero@gmail.farm"
|
||||
},
|
||||
"license": "PROPRIETARY",
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"version": "0.0.0",
|
||||
"license": "MPL-2",
|
||||
"scripts": {
|
||||
"update_packages": "ncu --target minor",
|
||||
"upgrade_packages": "ncu --upgrade ",
|
||||
"install_dependency": "pnpm install",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest watch",
|
||||
"build": "tsc && vite build",
|
||||
"static:build": "pnpm build",
|
||||
"dev": "vite",
|
||||
"pretty": "prettier -w .",
|
||||
"lint": "pnpm tsc --noEmit",
|
||||
"storybook": "storybook dev -p 3001",
|
||||
"storybook:build": "storybook build && mv ./storybook-static ./public/storybook"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx,js,jsx,json}": "prettier --write"
|
||||
"all": "npm run build && npm run test",
|
||||
"ng": "ng",
|
||||
"dev": "ng serve --configuration=develop --watch --port 4202",
|
||||
"dev-hot-update": "ng serve --configuration=develop --watch --hmr --port 4202",
|
||||
"build": "ng build --prod",
|
||||
"test": "ng test",
|
||||
"lint": "ng lint",
|
||||
"style": "prettier --write .",
|
||||
"e2e": "ng e2e",
|
||||
"update_packages": "ncu --upgrade",
|
||||
"install_dependency": "pnpm install --force",
|
||||
"link_kar_cw": "pnpm link ../../kar-cw/dist/kar-cw/",
|
||||
"unlink_kar_cw": "pnpm unlink ../../kar-cw/dist/kar-cw/"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@locator/babel-jsx": "0.4.4",
|
||||
"@trivago/prettier-plugin-sort-imports": "5.2.2",
|
||||
"@chakra-ui/cli": "3.8.1",
|
||||
"@chakra-ui/react": "3.8.1",
|
||||
"@emotion/react": "11.14.0",
|
||||
"allotment": "1.20.3",
|
||||
"css-mediaquery": "0.1.2",
|
||||
"dayjs": "1.11.13",
|
||||
"history": "5.3.0",
|
||||
"next-themes": "^0.4.4",
|
||||
"react": "19.0.0",
|
||||
"react-dom": "19.0.0",
|
||||
"react-error-boundary": "5.0.0",
|
||||
"react-icons": "5.5.0",
|
||||
"react-router-dom": "7.2.0",
|
||||
"react-select": "5.10.0",
|
||||
"react-use": "17.6.0",
|
||||
"zod": "3.24.2",
|
||||
"zustand": "5.0.3"
|
||||
"@angular/animations": "^18.0.2",
|
||||
"@angular/cdk": "^18.0.2",
|
||||
"@angular/common": "^18.0.2",
|
||||
"@angular/compiler": "^18.0.2",
|
||||
"@angular/core": "^18.0.2",
|
||||
"@angular/forms": "^18.0.2",
|
||||
"@angular/material": "^18.0.2",
|
||||
"@angular/platform-browser": "^18.0.2",
|
||||
"@angular/platform-browser-dynamic": "^18.0.2",
|
||||
"@angular/router": "^18.0.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"zone.js": "^0.14.6",
|
||||
"zod": "3.23.8",
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chakra-ui/styled-system": "^2.12.0",
|
||||
"@playwright/test": "1.50.1",
|
||||
"@storybook/addon-actions": "8.5.8",
|
||||
"@storybook/addon-essentials": "8.5.8",
|
||||
"@storybook/addon-links": "8.5.8",
|
||||
"@storybook/addon-mdx-gfm": "8.5.8",
|
||||
"@storybook/react": "8.5.8",
|
||||
"@storybook/react-vite": "8.5.8",
|
||||
"@storybook/theming": "8.5.8",
|
||||
"@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.5",
|
||||
"@types/react": "19.0.10",
|
||||
"@types/react-dom": "19.0.4",
|
||||
"@typescript-eslint/eslint-plugin": "8.24.1",
|
||||
"@typescript-eslint/parser": "8.24.1",
|
||||
"@vitejs/plugin-react": "4.3.4",
|
||||
"eslint": "9.21.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-react": "7.37.4",
|
||||
"eslint-plugin-react-hooks": "5.1.0",
|
||||
"eslint-plugin-storybook": "0.11.3",
|
||||
"jest": "29.7.0",
|
||||
"jest-environment-jsdom": "29.7.0",
|
||||
"knip": "5.44.5",
|
||||
"lint-staged": "15.4.3",
|
||||
"npm-check-updates": "^17.1.15",
|
||||
"prettier": "3.5.2",
|
||||
"puppeteer": "24.2.1",
|
||||
"react-is": "19.0.0",
|
||||
"storybook": "8.5.8",
|
||||
"ts-node": "10.9.2",
|
||||
"typescript": "5.7.3",
|
||||
"vite": "6.1.1",
|
||||
"vitest": "3.0.6"
|
||||
"@angular-devkit/build-angular": "^18.0.3",
|
||||
"@angular-eslint/builder": "18.0.1",
|
||||
"@angular-eslint/eslint-plugin": "18.0.1",
|
||||
"@angular-eslint/eslint-plugin-template": "18.0.1",
|
||||
"@angular-eslint/schematics": "18.0.1",
|
||||
"@angular-eslint/template-parser": "18.0.1",
|
||||
"@angular/cli": "^18.0.3",
|
||||
"@angular/compiler-cli": "^18.0.2",
|
||||
"@angular/language-service": "^18.0.2",
|
||||
"npm-check-updates": "^16.14.20",
|
||||
"tslib": "^2.6.3"
|
||||
}
|
||||
}
|
18883
front/pnpm-lock.yaml
generated
18883
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 { VideoPlayer } 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>
|
||||
<VideoPlayer />
|
||||
</ServiceContextProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
@ -10,7 +10,7 @@ import {
|
||||
} from "../rest-tools";
|
||||
|
||||
import {
|
||||
ObjectId,
|
||||
UUID,
|
||||
} from "../model";
|
||||
|
||||
export namespace DataResource {
|
||||
@ -30,13 +30,13 @@ export namespace DataResource {
|
||||
},
|
||||
params: {
|
||||
name: string,
|
||||
oid: ObjectId,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/{oid}/{name}",
|
||||
endPoint: "/data/{uuid}/{name}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
@ -59,13 +59,13 @@ export namespace DataResource {
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
oid: ObjectId,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/{oid}",
|
||||
endPoint: "/data/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
||||
@ -88,13 +88,13 @@ export namespace DataResource {
|
||||
Authorization?: string,
|
||||
},
|
||||
params: {
|
||||
oid: ObjectId,
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/thumbnail/{oid}",
|
||||
endPoint: "/data/thumbnail/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
},
|
||||
restConfig,
|
@ -154,16 +154,17 @@ export namespace MediaResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
callback?: RESTCallbacks,
|
||||
}): Promise<Media> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -175,7 +176,7 @@ export namespace MediaResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}, isMedia);
|
||||
};
|
||||
/**
|
||||
@ -184,7 +185,7 @@ export namespace MediaResource {
|
||||
export function uploadFile({
|
||||
restConfig,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: {
|
||||
@ -197,7 +198,7 @@ export namespace MediaResource {
|
||||
typeId: string,
|
||||
title: string,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
callback?: RESTCallbacks,
|
||||
}): Promise<Media> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -208,7 +209,7 @@ export namespace MediaResource {
|
||||
},
|
||||
restConfig,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}, isMedia);
|
||||
};
|
||||
}
|
@ -176,16 +176,17 @@ export namespace SeasonResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
callback?: RESTCallbacks,
|
||||
}): Promise<Season> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -197,7 +198,7 @@ export namespace SeasonResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}, isSeason);
|
||||
};
|
||||
}
|
@ -176,16 +176,17 @@ export namespace SeriesResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
callback?: RESTCallbacks,
|
||||
}): Promise<Series> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -197,7 +198,7 @@ export namespace SeriesResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}, isSeries);
|
||||
};
|
||||
}
|
@ -176,16 +176,17 @@ export namespace TypeResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: {
|
||||
fileName: string,
|
||||
file: File,
|
||||
},
|
||||
callbacks?: RESTCallbacks,
|
||||
callback?: RESTCallbacks,
|
||||
}): Promise<Type> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -197,7 +198,7 @@ export namespace TypeResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
callbacks,
|
||||
callback,
|
||||
}, isType);
|
||||
};
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodGenericData, ZodGenericDataWrite } from "./generic-data";
|
||||
import {ZodGenericData} from "./generic-data";
|
||||
|
||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||
/**
|
||||
@ -24,7 +24,14 @@ export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelet
|
||||
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>;
|
||||
|
@ -4,7 +4,7 @@
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodGenericTiming, ZodGenericTimingWrite } from "./generic-timing";
|
||||
import {ZodGenericTiming} from "./generic-timing";
|
||||
|
||||
export const ZodGenericData = ZodGenericTiming.extend({
|
||||
/**
|
||||
@ -25,7 +25,13 @@ export function isGenericData(data: any): data is GenericData {
|
||||
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>;
|
||||
|
@ -28,9 +28,12 @@ export function isGenericTiming(data: any): data is GenericTiming {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export const ZodGenericTimingWrite = zod.object({
|
||||
|
||||
});
|
||||
export const ZodGenericTimingWrite = ZodGenericTiming.omit({
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
||||
|
@ -19,9 +19,8 @@ export function isHealthResult(data: any): data is HealthResult {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export const ZodHealthResultWrite = zod.object({
|
||||
|
||||
});
|
||||
export const ZodHealthResultWrite = ZodHealthResult.partial();
|
||||
|
||||
export type HealthResultWrite = zod.infer<typeof ZodHealthResultWrite>;
|
||||
|
@ -1,20 +1,17 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
export * from "./data"
|
||||
export * from "./float"
|
||||
export * from "./generic-data"
|
||||
export * from "./generic-data-soft-delete"
|
||||
export * from "./generic-timing"
|
||||
export * from "./health-result"
|
||||
export * from "./int"
|
||||
export * from "./integer"
|
||||
export * from "./iso-date"
|
||||
export * from "./long"
|
||||
export * from "./media"
|
||||
export * from "./media-informations-delta"
|
||||
export * from "./object-id"
|
||||
export * from "./oid-generic-data"
|
||||
export * from "./oid-generic-data-soft-delete"
|
||||
export * from "./rest-error-response"
|
||||
export * from "./season"
|
||||
export * from "./series"
|
@ -19,9 +19,8 @@ export function isint(data: any): data is int {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export const ZodintWrite = zod.object({
|
||||
|
||||
});
|
||||
export const ZodintWrite = Zodint.partial();
|
||||
|
||||
export type intWrite = zod.infer<typeof ZodintWrite>;
|
||||
|
@ -19,9 +19,8 @@ export function isMediaInformationsDelta(data: any): data is MediaInformationsDe
|
||||
return false;
|
||||
}
|
||||
}
|
||||
export const ZodMediaInformationsDeltaWrite = zod.object({
|
||||
|
||||
});
|
||||
export const ZodMediaInformationsDeltaWrite = ZodMediaInformationsDelta.partial();
|
||||
|
||||
export type MediaInformationsDeltaWrite = zod.infer<typeof ZodMediaInformationsDeltaWrite>;
|
||||
|
@ -3,10 +3,10 @@
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodObjectId} from "./object-id";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodInteger} from "./integer";
|
||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
@ -20,7 +20,7 @@ export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* Foreign Key Id of the data
|
||||
*/
|
||||
dataId: ZodObjectId,
|
||||
dataId: ZodUUID,
|
||||
/**
|
||||
* Type of the media
|
||||
*/
|
||||
@ -49,7 +49,7 @@ export const ZodMedia = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
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>;
|
||||
|
@ -3,15 +3,15 @@
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodObjectId} from "./object-id";
|
||||
import {ZodInteger} from "./integer";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {Zodint} from "./int";
|
||||
|
||||
export const ZodRestErrorResponse = zod.object({
|
||||
oid: ZodObjectId.optional(),
|
||||
uuid: ZodUUID.optional(),
|
||||
name: zod.string(),
|
||||
message: zod.string(),
|
||||
time: zod.string(),
|
||||
status: ZodInteger,
|
||||
status: Zodint,
|
||||
statusMessage: zod.string(),
|
||||
|
||||
});
|
||||
@ -27,3 +27,17 @@ export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||
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 {ZodLong} from "./long";
|
||||
import {ZodObjectId} from "./object-id";
|
||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodSeason = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
@ -23,7 +23,7 @@ export const ZodSeason = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
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>;
|
||||
|
@ -4,8 +4,8 @@
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodObjectId} from "./object-id";
|
||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
@ -23,7 +23,7 @@ export const ZodSeries = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
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>;
|
||||
|
@ -3,8 +3,8 @@
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodObjectId} from "./object-id";
|
||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodType = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
@ -18,7 +18,7 @@ export const ZodType = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
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>;
|
||||
|
@ -3,9 +3,11 @@
|
||||
*/
|
||||
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>;
|
||||
|
||||
@ -18,7 +20,14 @@ export function isUserKarideo(data: any): data is UserKarideo {
|
||||
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>;
|
||||
|
@ -6,13 +6,13 @@ import { z as zod } from "zod";
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodFloat} from "./float";
|
||||
import {ZodInteger} from "./integer";
|
||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodUserMediaAdvancement = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* Foreign Key Id of the user
|
||||
*/
|
||||
userId: ZodLong.optional(),
|
||||
userId: ZodLong,
|
||||
/**
|
||||
* Id of the media
|
||||
*/
|
||||
@ -43,29 +43,14 @@ export function isUserMediaAdvancement(data: any): data is UserMediaAdvancement
|
||||
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>;
|
||||
|
@ -7,7 +7,7 @@ import {ZodLong} from "./long";
|
||||
|
||||
export const ZodUserOut = zod.object({
|
||||
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;
|
||||
}
|
||||
}
|
||||
export const ZodUserOutWrite = zod.object({
|
||||
id: ZodLong,
|
||||
login: zod.string().nullable().optional(),
|
||||
|
||||
});
|
||||
export const ZodUserOutWrite = ZodUserOut.partial();
|
||||
|
||||
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
||||
|
@ -5,13 +5,14 @@ import { z as zod } from "zod";
|
||||
|
||||
import {ZodTimestamp} from "./timestamp";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||
login: zod.string().min(3).max(128),
|
||||
login: zod.string().max(128).optional(),
|
||||
lastConnection: ZodTimestamp.optional(),
|
||||
blocked: zod.boolean().optional(),
|
||||
blockedReason: zod.string().max(512).optional(),
|
||||
admin: zod.boolean(),
|
||||
blocked: zod.boolean(),
|
||||
removed: zod.boolean(),
|
||||
/**
|
||||
* List of Id of the specific covers
|
||||
*/
|
||||
@ -30,17 +31,14 @@ export function isUser(data: any): data is User {
|
||||
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>;
|
||||
|
@ -7,15 +7,11 @@
|
||||
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||
|
||||
export enum HTTPRequestModel {
|
||||
ARCHIVE = "ARCHIVE",
|
||||
DELETE = "DELETE",
|
||||
HEAD = "HEAD",
|
||||
GET = "GET",
|
||||
OPTION = "OPTION",
|
||||
PATCH = "PATCH",
|
||||
POST = "POST",
|
||||
PUT = "PUT",
|
||||
RESTORE = "RESTORE",
|
||||
}
|
||||
export enum HTTPMimeType {
|
||||
ALL = "*/*",
|
||||
@ -78,7 +74,7 @@ export interface RESTRequestType {
|
||||
data?: any;
|
||||
params?: object;
|
||||
queries?: object;
|
||||
callbacks?: RESTCallbacks;
|
||||
callback?: RESTCallbacks;
|
||||
}
|
||||
|
||||
function replaceAll(input, searchValue, replaceValue) {
|
||||
@ -241,7 +237,7 @@ export function RESTRequest({
|
||||
data,
|
||||
params,
|
||||
queries,
|
||||
callbacks,
|
||||
callback,
|
||||
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||
@ -252,14 +248,9 @@ export function RESTRequest({
|
||||
if (restModel.accept !== undefined) {
|
||||
headers["Accept"] = restModel.accept;
|
||||
}
|
||||
if (restModel.requestType !== HTTPRequestModel.GET &&
|
||||
restModel.requestType !== HTTPRequestModel.ARCHIVE &&
|
||||
restModel.requestType !== HTTPRequestModel.RESTORE
|
||||
) {
|
||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||
// if Get we have not a content type, the body is empty
|
||||
if (restModel.contentType !== HTTPMimeType.MULTIPART &&
|
||||
restModel.contentType !== undefined
|
||||
) {
|
||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||
headers["Content-Type"] = restModel.contentType;
|
||||
}
|
||||
@ -277,10 +268,10 @@ export function RESTRequest({
|
||||
return new Promise((resolve, reject) => {
|
||||
let action: undefined | Promise<Response> = undefined;
|
||||
if (
|
||||
isNullOrUndefined(callbacks) ||
|
||||
(isNullOrUndefined(callbacks.progressDownload) &&
|
||||
isNullOrUndefined(callbacks.progressUpload) &&
|
||||
isNullOrUndefined(callbacks.abortHandle))
|
||||
isNullOrUndefined(callback) ||
|
||||
(isNullOrUndefined(callback.progressDownload) &&
|
||||
isNullOrUndefined(callback.progressUpload) &&
|
||||
isNullOrUndefined(callback.abortHandle))
|
||||
) {
|
||||
// No information needed: call the generic fetch interface
|
||||
action = fetch(generateUrl, {
|
||||
@ -297,7 +288,7 @@ export function RESTRequest({
|
||||
headers,
|
||||
body,
|
||||
},
|
||||
callbacks
|
||||
callback
|
||||
);
|
||||
}
|
||||
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