Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
c3980225d2 | |||
d3e05889a9 | |||
ad26736b80 | |||
4d1ae6f795 | |||
10bdf926cf | |||
ab949c1084 | |||
ac38ba284b | |||
73bed05b5f |
31
Dockerfile
31
Dockerfile
@ -6,11 +6,11 @@
|
||||
FROM archlinux:base-devel AS builder
|
||||
# update system
|
||||
RUN pacman -Syu --noconfirm && pacman-db-upgrade \
|
||||
&& pacman -S --noconfirm jdk-openjdk maven npm \
|
||||
&& pacman -S --noconfirm jdk-openjdk maven pnpm \
|
||||
&& pacman -Scc --noconfirm
|
||||
|
||||
ENV PATH /tmp/node_modules/.bin:$PATH
|
||||
WORKDIR /tmp
|
||||
ENV PATH /workspace/node_modules/.bin:$PATH
|
||||
WORKDIR /workspace
|
||||
|
||||
######################################################################################
|
||||
##
|
||||
@ -18,8 +18,8 @@ WORKDIR /tmp
|
||||
##
|
||||
######################################################################################
|
||||
FROM builder AS buildBack
|
||||
COPY back/pom.xml /tmp
|
||||
COPY back/src /tmp/src/
|
||||
COPY back/pom.xml back/Formatter.xml ./
|
||||
COPY back/src ./src/
|
||||
RUN mvn clean compile assembly:single
|
||||
|
||||
######################################################################################
|
||||
@ -29,21 +29,22 @@ RUN mvn clean compile assembly:single
|
||||
######################################################################################
|
||||
FROM builder AS buildFront
|
||||
|
||||
ADD front/package-lock.json \
|
||||
front/package.json \
|
||||
RUN echo "@kangaroo-and-rabbit:registry=https://gitea.atria-soft.org/api/packages/kangaroo-and-rabbit/npm/" > /root/.npmrc
|
||||
|
||||
ADD front/package.json \
|
||||
front/karma.conf.js \
|
||||
front/protractor.conf.js \
|
||||
/tmp/
|
||||
./
|
||||
|
||||
# install and cache app dependencies
|
||||
RUN npm install
|
||||
RUN pnpm install
|
||||
|
||||
ADD front/e2e \
|
||||
front/tsconfig.json \
|
||||
front/tslint.json \
|
||||
front/angular.json \
|
||||
/tmp/
|
||||
ADD front/src /tmp/src
|
||||
./
|
||||
ADD front/src ./src
|
||||
|
||||
# generate build
|
||||
RUN ng build --output-path=dist --configuration=production --base-href=/karso/ --deploy-url=/karso/ karso
|
||||
@ -60,11 +61,15 @@ RUN apk add --no-cache wget
|
||||
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
COPY --from=buildBack /tmp/out/maven/*.jar /application/application.jar
|
||||
COPY --from=buildFront /tmp/dist /application/front/
|
||||
COPY --from=buildBack /workspace/out/maven/*.jar /application/application.jar
|
||||
COPY --from=buildFront /workspace/dist /application/front/
|
||||
|
||||
WORKDIR /application/
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
# To verify health-check: docker inspect --format "{{json .State.Health }}" YOUR_SERVICE_NAME | jq
|
||||
HEALTHCHECK --start-period=30s --start-interval=5s --interval=30s --timeout=5s --retries=10 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:80/karso/api/health_check || exit 1
|
||||
|
||||
CMD ["java", "-Xms64M", "-Xmx1G", "-cp", "/application/application.jar", "org.kar.karso.WebLauncher"]
|
||||
|
@ -93,3 +93,11 @@ Action a faire d'urgence:
|
||||
- mise en place d'envoie d'email pour faire une autentification plus sérieuse.
|
||||
- mettre un place un back-end LDAP
|
||||
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
export PATH=$(ls -d --color=never /usr/lib/jvm/java-2*-openjdk)/bin:$PATH
|
||||
mvn formatter:format
|
||||
mvn test
|
||||
```
|
@ -25,7 +25,7 @@
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -15,10 +15,16 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>edu.umd.cs.findbugs.plugin.eclipse.findbugsNature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
|
@ -1,10 +1,10 @@
|
||||
services:
|
||||
kar_db_service:
|
||||
db_service:
|
||||
image: mysql:latest
|
||||
restart: always
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=base_db_password
|
||||
volumes: # !!!! the folder is not the default set it on ssh not on long-storage data
|
||||
volumes:
|
||||
- ./data:/var/lib/mysql
|
||||
#- /workspace/data/global/db:/var/lib/mysql
|
||||
mem_limit: 300m
|
||||
@ -16,13 +16,13 @@ services:
|
||||
retries: 5
|
||||
start_period: 20s
|
||||
|
||||
kar_adminer_service:
|
||||
adminer_service:
|
||||
image: adminer:latest
|
||||
restart: always
|
||||
ports:
|
||||
- 18079:8080
|
||||
- 5079:8080
|
||||
links:
|
||||
- kar_db_service:db
|
||||
- db_service:db
|
||||
#read_only: true
|
||||
mem_limit: 100m
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.kar</groupId>
|
||||
<artifactId>karso</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<version>0.8.0</version>
|
||||
<properties>
|
||||
<maven.compiler.version>3.1</maven.compiler.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>kangaroo-and-rabbit</groupId>
|
||||
<artifactId>archidata</artifactId>
|
||||
<version>0.8.7</version>
|
||||
<version>0.11.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -40,13 +40,13 @@
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.11.0-M1</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-M1</version>
|
||||
<version>5.11.0-M2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -12,11 +12,7 @@ import org.kar.archidata.UpdateJwtPublicKey;
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.backup.BackupEngine;
|
||||
import org.kar.archidata.backup.BackupEngine.StoreMode;
|
||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
||||
import org.kar.archidata.catcher.FailException404API;
|
||||
import org.kar.archidata.catcher.FailExceptionCatcher;
|
||||
import org.kar.archidata.catcher.InputExceptionCatcher;
|
||||
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
||||
import org.kar.archidata.catcher.GenericCatcher;
|
||||
import org.kar.archidata.db.DBConfig;
|
||||
import org.kar.archidata.filter.CORSFilter;
|
||||
import org.kar.archidata.filter.OptionFilter;
|
||||
@ -36,6 +32,7 @@ import org.kar.karso.filter.KarsoAuthenticationFilter;
|
||||
import org.kar.karso.migration.Initialization;
|
||||
import org.kar.karso.migration.Migration20231015;
|
||||
import org.kar.karso.migration.Migration20231126;
|
||||
import org.kar.karso.migration.Migration20240515;
|
||||
import org.kar.karso.model.Application;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
import org.kar.karso.model.Right;
|
||||
@ -79,6 +76,7 @@ public class WebLauncher {
|
||||
WebLauncher.LOGGER.info("Add migration since last version");
|
||||
migrationEngine.add(new Migration20231015());
|
||||
migrationEngine.add(new Migration20231126());
|
||||
migrationEngine.add(new Migration20240515());
|
||||
WebLauncher.LOGGER.info("Migrate the DB [START]");
|
||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||
@ -119,11 +117,7 @@ public class WebLauncher {
|
||||
// global authentication system
|
||||
rc.register(KarsoAuthenticationFilter.class);
|
||||
// register exception catcher
|
||||
rc.register(InputExceptionCatcher.class);
|
||||
rc.register(SystemExceptionCatcher.class);
|
||||
rc.register(FailExceptionCatcher.class);
|
||||
rc.register(FailException404API.class);
|
||||
rc.register(ExceptionCatcher.class);
|
||||
GenericCatcher.addAll(rc);
|
||||
// add default resource:
|
||||
rc.register(DataResource.class);
|
||||
rc.register(ApplicationResource.class);
|
||||
|
@ -4,7 +4,8 @@ package org.kar.karso;
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.api.DataResource;
|
||||
import org.kar.archidata.dataAccess.DataFactoryTsApi;
|
||||
import org.kar.archidata.externalRestApi.AnalyzeApi;
|
||||
import org.kar.archidata.externalRestApi.TsGenerateApi;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.karso.api.ApplicationResource;
|
||||
import org.kar.karso.api.ApplicationTokenResource;
|
||||
@ -13,7 +14,6 @@ import org.kar.karso.api.PublicKeyResource;
|
||||
import org.kar.karso.api.RightResource;
|
||||
import org.kar.karso.api.SystemConfigResource;
|
||||
import org.kar.karso.api.UserResource;
|
||||
import org.kar.karso.migration.Initialization;
|
||||
import org.kar.karso.util.ConfigVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -23,11 +23,19 @@ public class WebLauncherLocal extends WebLauncher {
|
||||
|
||||
private WebLauncherLocal() {}
|
||||
|
||||
public static void generateObjects() throws Exception {
|
||||
LOGGER.info("Generate APIs");
|
||||
final List<Class<?>> listOfResources = List.of(Front.class, DataResource.class, ApplicationResource.class,
|
||||
ApplicationTokenResource.class, PublicKeyResource.class, RightResource.class, UserResource.class,
|
||||
SystemConfigResource.class);
|
||||
final AnalyzeApi api = new AnalyzeApi();
|
||||
api.addAllApi(listOfResources);
|
||||
TsGenerateApi.generateApi(api, "../front/src/back-api/");
|
||||
LOGGER.info("Generate APIs (DONE)");
|
||||
}
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
DataFactoryTsApi.generatePackage(
|
||||
List.of(Front.class, DataResource.class, ApplicationResource.class, ApplicationTokenResource.class,
|
||||
PublicKeyResource.class, RightResource.class, UserResource.class, SystemConfigResource.class),
|
||||
Initialization.CLASSES_BASE, "../front/src/back-api/");
|
||||
generateObjects();
|
||||
final WebLauncherLocal launcher = new WebLauncherLocal();
|
||||
launcher.process();
|
||||
LOGGER.info("end-configure the server & wait finish process:");
|
||||
|
@ -126,7 +126,8 @@ public class ApplicationResource {
|
||||
application.createdAt = null;
|
||||
application.deleted = null;
|
||||
application.updatedAt = null;
|
||||
return DataAccess.insert(application);
|
||||
final Application tmp = DataAccess.insert(application);
|
||||
return get(tmp.id);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -91,7 +91,7 @@ public class SystemConfigResource {
|
||||
public void setKey(
|
||||
@Context final SecurityContext sc,
|
||||
@PathParam("key") final String key,
|
||||
@AsyncType(Map.class) final String jsonRequest) throws Exception {
|
||||
@AsyncType(Object.class) final String jsonRequest) throws Exception {
|
||||
Settings res = null;
|
||||
try {
|
||||
res = DataAccess.getWhere(Settings.class, new Condition(new QueryCondition("key", "=", key)));
|
||||
|
@ -52,7 +52,7 @@ public class UserResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserResource.class);
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class UserOut {
|
||||
public static class UserOut {
|
||||
public long id;
|
||||
public String login;
|
||||
|
||||
@ -276,8 +276,9 @@ public class UserResource {
|
||||
"FAIL Authentiocate-wrong email/login '" + login + "')");
|
||||
}
|
||||
// Check the password:
|
||||
final String passwodCheck = getSHA512("login='" + login + "';pass='" + user.password + "';date='" + time + "'");
|
||||
if (!passwodCheck.contentEquals(password)) {
|
||||
final String passwordCheck = getSHA512(
|
||||
"login='" + login + "';pass='" + user.password + "';date='" + time + "'");
|
||||
if (!passwordCheck.contentEquals(password)) {
|
||||
throw new FailException(Response.Status.PRECONDITION_FAILED, "Password error ...");
|
||||
}
|
||||
LOGGER.debug(" ==> pass nearly all test : admin={} blocked={} removed={}", user.admin, user.blocked,
|
||||
|
@ -2,20 +2,25 @@ package org.kar.karso.migration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.migration.MigrationSqlStep;
|
||||
import org.kar.archidata.tools.UuidUtils;
|
||||
import org.kar.karso.model.Application;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
import org.kar.karso.model.Right;
|
||||
import org.kar.karso.model.RightDescription;
|
||||
import org.kar.karso.model.Settings;
|
||||
import org.kar.karso.model.UserAuth;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Initialization extends MigrationSqlStep {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Initialization.class);
|
||||
|
||||
public static final int KARSO_INITIALISATION_ID = 1;
|
||||
|
||||
public static final List<Class<?>> CLASSES_BASE = List.of(Settings.class, UserAuth.class, Application.class,
|
||||
ApplicationToken.class, RightDescription.class, Right.class);
|
||||
public static final List<Class<?>> LIST_OF_COMMON_CLASSES = List.of(Settings.class, UserAuth.class,
|
||||
Application.class, ApplicationToken.class, RightDescription.class, Right.class);
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@ -28,7 +33,7 @@ public class Initialization extends MigrationSqlStep {
|
||||
|
||||
@Override
|
||||
public void generateStep() throws Exception {
|
||||
for (final Class<?> clazz : CLASSES_BASE) {
|
||||
for (final Class<?> clazz : LIST_OF_COMMON_CLASSES) {
|
||||
addClass(clazz);
|
||||
}
|
||||
|
||||
@ -44,10 +49,15 @@ public class Initialization extends MigrationSqlStep {
|
||||
(1, 'karadmin', '0ddcac5ede3f1300a1ce5948ab15112f2810130531d578ab8bc4dc131652d7cf7a3ff6e827eb957bff43bc2c65a6a1d46722e5b3a2343ac3176a33ea7250080b',
|
||||
'admin@admin.ZZZ', 1);
|
||||
""");
|
||||
final String data = UuidUtils.nextUUID().toString();
|
||||
addAction("""
|
||||
INSERT INTO `user_link_application` (`object1Id`, `object2Id`)
|
||||
VALUES ('1', '1');
|
||||
""");
|
||||
INSERT INTO `user_link_application` (`uuid`, `object1Id`, `object2Id`)
|
||||
VALUES (UUID_TO_BIN('%s'), '1', '1');
|
||||
""".formatted(data), "mysql");
|
||||
addAction("""
|
||||
INSERT INTO `user_link_application` (`uuid`, `object1Id`, `object2Id`)
|
||||
VALUES ('%s', '1', '1');
|
||||
""".formatted(data), "sqlite");
|
||||
addAction("""
|
||||
INSERT INTO `settings` (`key`, `right`, `type`, `value`) VALUES
|
||||
('SIGN_UP_ENABLE', 'rwr-r-', 'BOOLEAN', 'false'),
|
||||
@ -83,4 +93,25 @@ public class Initialization extends MigrationSqlStep {
|
||||
display();
|
||||
}
|
||||
|
||||
public static void dropAll() {
|
||||
for (final Class<?> element : LIST_OF_COMMON_CLASSES) {
|
||||
try {
|
||||
DataAccess.drop(element);
|
||||
} catch (final Exception ex) {
|
||||
LOGGER.error("Fail to drop table !!!!!!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void cleanAll() {
|
||||
for (final Class<?> element : LIST_OF_COMMON_CLASSES) {
|
||||
try {
|
||||
DataAccess.cleanAll(element);
|
||||
} catch (final Exception ex) {
|
||||
LOGGER.error("Fail to clean table !!!!!!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class Migration20231015 extends MigrationSqlStep {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateStep() throws Exception {
|
||||
public void generateStep() {
|
||||
|
||||
for (final String elem : List.of("application", "applicationToken", "right", "rightDescription", "settings",
|
||||
"user", "user_link_application")) { //, "user_link_cover")) {
|
||||
@ -30,7 +30,6 @@ public class Migration20231015 extends MigrationSqlStep {
|
||||
RENAME COLUMN `modify_date` TO `updatedAt`;
|
||||
""");
|
||||
}
|
||||
display();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateStep() throws Exception {
|
||||
public void generateStep() {
|
||||
// update migration update (last one)
|
||||
addAction(
|
||||
"""
|
||||
|
73
back/src/org/kar/karso/migration/Migration20240515.java
Normal file
73
back/src/org/kar/karso/migration/Migration20240515.java
Normal file
@ -0,0 +1,73 @@
|
||||
package org.kar.karso.migration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
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.karso.migration.model.UUIDConversion;
|
||||
|
||||
public class Migration20240515 extends MigrationSqlStep {
|
||||
|
||||
public static final int KARSO_INITIALISATION_ID = 1;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "migration-2024-05-15: Update the link user application and the cover";
|
||||
}
|
||||
|
||||
public Migration20240515() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateStep() {
|
||||
// update migration update (last one)
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application` ADD `uuid` binary(16) AFTER `id`;
|
||||
""");
|
||||
addAction(() -> {
|
||||
final List<UUIDConversion> datas = DataAccess.gets(UUIDConversion.class, new AccessDeletedItems(),
|
||||
new OverrideTableName("user_link_application"));
|
||||
for (final UUIDConversion elem : datas) {
|
||||
elem.uuid = UuidUtils.nextUUID();
|
||||
}
|
||||
for (final UUIDConversion elem : datas) {
|
||||
DataAccess.update(elem, elem.id, List.of("uuid"), new OverrideTableName("user_link_application"));
|
||||
}
|
||||
});
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application`
|
||||
CHANGE `id` `id` bigint;
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application` DROP PRIMARY KEY;
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application`
|
||||
CHANGE `uuid` `uuid` binary(16) DEFAULT (UUID_TO_BIN(UUID(), TRUE));
|
||||
""");
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application`
|
||||
ADD PRIMARY KEY `uuid` (`uuid`);
|
||||
""");
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application`
|
||||
DROP `id`;
|
||||
""");
|
||||
|
||||
addAction("""
|
||||
DROP TABLE `user_link_cover`;
|
||||
""");
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `user`
|
||||
ADD `covers` json DEFAULT NULL COMMENT 'List of Id of the specific covers' AFTER `removed`;
|
||||
""");
|
||||
|
||||
}
|
||||
|
||||
}
|
11
back/src/org/kar/karso/migration/model/UUIDConversion.java
Normal file
11
back/src/org/kar/karso/migration/model/UUIDConversion.java
Normal file
@ -0,0 +1,11 @@
|
||||
package org.kar.karso.migration.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
public class UUIDConversion {
|
||||
@Id
|
||||
public Long id = null;
|
||||
public UUID uuid = null;
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class AddUserData {
|
||||
public Long userId;
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ApplicationSmall {
|
||||
public Long id;
|
||||
public String name;
|
||||
@ -8,8 +11,7 @@ public class ApplicationSmall {
|
||||
|
||||
public ApplicationSmall() {}
|
||||
|
||||
public ApplicationSmall(Long id, String name, String description, String redirect) {
|
||||
super();
|
||||
public ApplicationSmall(final Long id, final String name, final String description, final String redirect) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
|
@ -1,7 +1,10 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ChangePassword {
|
||||
@Column(length = 32)
|
||||
public String method;
|
||||
|
@ -1,7 +1,10 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ClientToken {
|
||||
@Column(length = 1024)
|
||||
public String url;
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class CreateTokenRequest {
|
||||
public CreateTokenRequest() {}
|
||||
|
||||
|
@ -4,6 +4,9 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public record DataGetToken(
|
||||
String login,
|
||||
String method,
|
||||
|
@ -1,5 +1,8 @@
|
||||
package org.kar.karso.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class DataGetTokenApplication {
|
||||
public String application;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ CREATE TABLE `application` (
|
||||
*/
|
||||
|
||||
import org.kar.archidata.annotation.DataIfNotExists;
|
||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||
import org.kar.archidata.model.UUIDGenericDataSoftDelete;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@ -22,7 +22,7 @@ import jakarta.persistence.Table;
|
||||
@Table(name = "user_link_application")
|
||||
@DataIfNotExists
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class UserLinkApplication extends GenericDataSoftDelete {
|
||||
public class UserLinkApplication extends UUIDGenericDataSoftDelete {
|
||||
@Column(name = "object1id")
|
||||
public Long userId;
|
||||
@Column(name = "object2id")
|
||||
|
89
back/test/src/test/kar/karso/TestUsers.java
Normal file
89
back/test/src/test/kar/karso/TestUsers.java
Normal file
@ -0,0 +1,89 @@
|
||||
package test.kar.karso;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.exception.RESTErrorResponseExeption;
|
||||
import org.kar.archidata.model.GetToken;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.kar.archidata.tools.RESTApi;
|
||||
import org.kar.karso.migration.Initialization;
|
||||
import org.kar.karso.model.DataGetToken;
|
||||
import org.kar.karso.model.UserAuthGet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ExtendWith(StepwiseExtension.class)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class TestUsers {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TestUsers.class);
|
||||
public final static String ENDPOINT_NAME = "users/";
|
||||
|
||||
static WebLauncherTest webInterface = null;
|
||||
static RESTApi api = null;
|
||||
|
||||
private static long idTest;
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws InterruptedException, RESTErrorResponseExeption, IOException {
|
||||
LOGGER.info("configure server ...");
|
||||
webInterface = new WebLauncherTest();
|
||||
LOGGER.info("Clean previous table");
|
||||
|
||||
try {
|
||||
Initialization.dropAll();
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
LOGGER.error("plop: {}", ex.getLocalizedMessage());
|
||||
throw ex;
|
||||
}
|
||||
|
||||
LOGGER.info("Create DB");
|
||||
try {
|
||||
webInterface.migrateDB();
|
||||
} catch (final Exception ex) {
|
||||
ex.printStackTrace();
|
||||
LOGGER.error("Detect an error: {}", ex.getMessage());
|
||||
}
|
||||
LOGGER.info("Start REST (BEGIN)");
|
||||
webInterface.process();
|
||||
LOGGER.info("Start REST (DONE)");
|
||||
api = new RESTApi(ConfigBaseVariable.apiAdress);
|
||||
final GetToken result = api.post(GetToken.class, "users/get_token",
|
||||
DataGetToken.generate("karadmin", "v1", "202515252", "adminA@666"));
|
||||
api.setToken(result.jwt);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void stopWebServer() throws IOException {
|
||||
LOGGER.info("Kill the web server");
|
||||
webInterface.stop();
|
||||
webInterface = null;
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
@Test
|
||||
public void getsValue() throws RESTErrorResponseExeption, IOException, InterruptedException {
|
||||
final List<UserAuthGet> listUsers = api.gets(UserAuthGet.class, TestUsers.ENDPOINT_NAME);
|
||||
Assertions.assertNotNull(listUsers);
|
||||
Assertions.assertEquals(1, listUsers.size());
|
||||
Assertions.assertEquals(1, listUsers.get(0).id);
|
||||
Assertions.assertEquals(true, listUsers.get(0).admin);
|
||||
Assertions.assertEquals(false, listUsers.get(0).blocked);
|
||||
Assertions.assertEquals(false, listUsers.get(0).avatar);
|
||||
Assertions.assertEquals("karadmin", listUsers.get(0).login);
|
||||
Assertions.assertEquals("admin@admin.ZZZ", listUsers.get(0).email);
|
||||
}
|
||||
}
|
@ -21,32 +21,32 @@
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.3.8",
|
||||
"@angular/cdk": "^17.3.8",
|
||||
"@angular/common": "^17.3.8",
|
||||
"@angular/compiler": "^17.3.8",
|
||||
"@angular/core": "^17.3.8",
|
||||
"@angular/forms": "^17.3.8",
|
||||
"@angular/material": "^17.3.8",
|
||||
"@angular/platform-browser": "^17.3.8",
|
||||
"@angular/platform-browser-dynamic": "^17.3.8",
|
||||
"@angular/router": "^17.3.8",
|
||||
"@angular/animations": "^18.0.1",
|
||||
"@angular/cdk": "^18.0.1",
|
||||
"@angular/common": "^18.0.1",
|
||||
"@angular/compiler": "^18.0.1",
|
||||
"@angular/core": "^18.0.1",
|
||||
"@angular/forms": "^18.0.1",
|
||||
"@angular/material": "^18.0.1",
|
||||
"@angular/platform-browser": "^18.0.1",
|
||||
"@angular/platform-browser-dynamic": "^18.0.1",
|
||||
"@angular/router": "^18.0.1",
|
||||
"rxjs": "^7.8.1",
|
||||
"zone.js": "^0.14.5",
|
||||
"zone.js": "^0.14.6",
|
||||
"zod": "3.23.8",
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.2.2"
|
||||
"@kangaroo-and-rabbit/kar-cw": "^0.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^17.3.7",
|
||||
"@angular-eslint/builder": "17.4.0",
|
||||
"@angular-eslint/eslint-plugin": "17.4.0",
|
||||
"@angular-eslint/eslint-plugin-template": "17.4.0",
|
||||
"@angular-eslint/schematics": "17.4.0",
|
||||
"@angular-eslint/template-parser": "17.4.0",
|
||||
"@angular/cli": "^17.3.7",
|
||||
"@angular/compiler-cli": "^17.3.8",
|
||||
"@angular/language-service": "^17.3.8",
|
||||
"@playwright/test": "^1.44.0",
|
||||
"@angular-devkit/build-angular": "^18.0.2",
|
||||
"@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.2",
|
||||
"@angular/compiler-cli": "^18.0.1",
|
||||
"@angular/language-service": "^18.0.1",
|
||||
"@playwright/test": "^1.44.1",
|
||||
"@types/jest": "^29.5.12",
|
||||
"jasmine": "^5.1.0",
|
||||
"jasmine-core": "^5.1.2",
|
||||
@ -57,7 +57,7 @@
|
||||
"karma-jasmine": "^5.1.0",
|
||||
"karma-jasmine-html-reporter": "^2.1.0",
|
||||
"karma-spec-reporter": "^0.0.36",
|
||||
"prettier": "^3.2.5",
|
||||
"prettier": "^3.3.0",
|
||||
"npm-check-updates": "^16.14.20",
|
||||
"tslib": "^2.6.2"
|
||||
}
|
||||
|
2605
front/pnpm-lock.yaml
generated
2605
front/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
||||
version="1.1"
|
||||
id="svg18"
|
||||
sodipodi:docname="ikon_red.svg"
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)"
|
||||
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
@ -72,9 +72,9 @@
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="5.6"
|
||||
inkscape:cx="42.410714"
|
||||
inkscape:cy="110.625"
|
||||
inkscape:zoom="7.9195959"
|
||||
inkscape:cx="89.966711"
|
||||
inkscape:cy="177.91312"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
@ -85,10 +85,18 @@
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="20"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:pagecheckerboard="0">
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:deskcolor="#d1d1d1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid4504" />
|
||||
id="grid4504"
|
||||
originx="0"
|
||||
originy="0"
|
||||
spacingy="1"
|
||||
spacingx="1"
|
||||
units="px"
|
||||
visible="true" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata5">
|
||||
@ -114,11 +122,9 @@
|
||||
transform="matrix(0.8407653,0,0,0.83753055,-37.28971,3.4402954)"
|
||||
aria-label="K">
|
||||
<path
|
||||
sodipodi:nodetypes="ccccccccccccc"
|
||||
inkscape:connector-curvature="0"
|
||||
id="path823-5"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:84.55024719px;font-family:'DejaVu Sans Mono';-inkscape-font-specification:'DejaVu Sans Mono, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;opacity:0.775;fill:#2b3137;fill-opacity:1;stroke-width:2.11405313;filter:url(#filter5338);stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 65.200546,279.9533 h 8.949095 v 27.37877 l 25.568842,-27.37877 6.392207,6.84469 -20.455071,21.90302 20.455071,27.37876 -6.392207,5.47576 -19.176632,-27.37877 -6.39221,6.84469 v 20.53408 h -8.949095 z" />
|
||||
d="M 65.200545 279.95309 L 65.200545 341.55532 L 74.14964 341.55532 L 74.14964 321.02125 L 80.541851 314.17676 L 99.718483 341.55532 L 106.11069 336.07998 L 85.655619 308.7008 L 106.11069 286.7982 L 99.718483 279.95309 L 74.14964 307.33227 L 74.14964 279.95309 L 65.200545 279.95309 z M 69.586585 307.95792 C 71.270821 307.95521 72.163105 308.76519 72.164982 309.94037 C 72.166858 311.11555 71.276967 311.92813 69.592731 311.93085 C 67.946259 311.9335 67.061695 311.12357 67.059818 309.94839 C 67.057941 308.77322 67.940113 307.96057 69.586585 307.95792 z M 69.588429 309.10309 C 68.568824 309.10473 68.017826 309.4316 68.01865 309.94716 C 68.019473 310.46272 68.571283 310.78793 69.590887 310.78629 C 70.655808 310.78458 71.206973 310.45717 71.20615 309.94161 C 71.205327 309.42604 70.653349 309.10138 69.588429 309.10309 z M 70.651134 317.13779 C 71.466818 317.13648 72.177771 317.82535 72.179733 319.0536 C 72.180798 319.7208 71.940317 320.4034 71.472902 320.93487 L 70.70891 320.29194 C 71.010421 319.91995 71.221049 319.45722 71.220287 318.97956 C 71.219524 318.50191 71.038049 318.28194 70.788812 318.28234 C 70.441392 318.2829 70.351355 318.5789 70.155738 319.04928 L 69.884683 319.68666 C 69.681646 320.24045 69.259204 320.7412 68.541704 320.74236 C 67.726021 320.74367 67.075662 320.0017 67.073955 318.93267 C 67.072998 318.33371 67.298319 317.73449 67.720551 317.28649 L 68.424309 317.85414 C 68.175617 318.19572 68.032626 318.50667 68.033401 318.9919 C 68.033994 319.36341 68.192626 319.61369 68.479626 319.61323 C 68.774179 319.61276 68.886895 319.27856 69.059842 318.80063 L 69.315531 318.20151 C 69.556173 317.54909 69.956292 317.13891 70.651134 317.13779 z M 72.09983 325.98324 L 72.102289 327.23453 L 70.32845 328.18534 L 70.32968 328.76904 L 72.104747 328.76595 L 72.106591 329.88027 L 67.18213 329.88829 L 67.179057 328.13722 C 67.177386 327.09093 67.538843 326.22575 68.7095 326.22387 C 69.434552 326.2227 69.895571 326.57849 70.130538 327.10126 L 72.09983 325.98324 z M 68.711344 327.32338 C 68.227976 327.32416 68.061959 327.6353 68.062903 328.22668 L 68.064133 328.77274 L 69.445833 328.77027 L 69.445219 328.22422 C 69.444274 327.63284 69.194712 327.3226 68.711344 327.32338 z M 72.114581 335.0286 L 72.116425 336.2114 L 70.946159 336.5088 L 70.948618 338.00258 L 72.119499 338.30368 L 72.121342 339.44145 L 67.195038 337.91003 L 67.192579 336.57544 L 72.114581 335.0286 z M 70.078294 336.73771 L 69.625307 336.85248 C 69.134592 336.98216 68.560497 337.13471 68.039547 337.24921 L 68.039547 337.27945 C 68.560872 337.39992 69.13541 337.53513 69.626536 337.66323 L 70.079523 337.77614 L 70.078294 336.73771 z " />
|
||||
</g>
|
||||
<g
|
||||
id="text821"
|
||||
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 7.6 KiB |
@ -1,29 +1,31 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import { z as zod } from "zod"
|
||||
import {
|
||||
AddUserData,
|
||||
Application,
|
||||
ApplicationSmall,
|
||||
ClientToken,
|
||||
Long,
|
||||
RightDescription,
|
||||
isRightDescription,
|
||||
isApplication,
|
||||
isLong,
|
||||
isApplicationSmall,
|
||||
isClientToken,
|
||||
} from "./model"
|
||||
AddUserDataWrite,
|
||||
Application,
|
||||
ApplicationSmall,
|
||||
ApplicationWrite,
|
||||
ClientToken,
|
||||
Long,
|
||||
RightDescription,
|
||||
ZodApplication,
|
||||
ZodApplicationSmall,
|
||||
ZodLong,
|
||||
ZodRightDescription,
|
||||
isApplication,
|
||||
isClientToken,
|
||||
} from "../model";
|
||||
|
||||
export namespace ApplicationResource {
|
||||
|
||||
export function addUser({
|
||||
@ -35,7 +37,7 @@ export namespace ApplicationResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: AddUserData,
|
||||
data: AddUserDataWrite,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
@ -53,11 +55,11 @@ export namespace ApplicationResource {
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Application,
|
||||
data: ApplicationWrite,
|
||||
}): Promise<Application> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application",
|
||||
endPoint: "/application/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
@ -85,6 +87,20 @@ export namespace ApplicationResource {
|
||||
params,
|
||||
}, isApplication);
|
||||
};
|
||||
|
||||
export const ZodGetApplicationUsersTypeReturn = zod.array(ZodLong);
|
||||
export type GetApplicationUsersTypeReturn = zod.infer<typeof ZodGetApplicationUsersTypeReturn>;
|
||||
|
||||
export function isGetApplicationUsersTypeReturn(data: any): data is GetApplicationUsersTypeReturn {
|
||||
try {
|
||||
ZodGetApplicationUsersTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetApplicationUsersTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getApplicationUsers({
|
||||
restConfig,
|
||||
params,
|
||||
@ -93,8 +109,8 @@ export namespace ApplicationResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<Long[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetApplicationUsersTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}/users",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -102,21 +118,35 @@ export namespace ApplicationResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isLong);
|
||||
}, isGetApplicationUsersTypeReturn);
|
||||
};
|
||||
|
||||
export const ZodGetApplicationsSmallTypeReturn = zod.array(ZodApplicationSmall);
|
||||
export type GetApplicationsSmallTypeReturn = zod.infer<typeof ZodGetApplicationsSmallTypeReturn>;
|
||||
|
||||
export function isGetApplicationsSmallTypeReturn(data: any): data is GetApplicationsSmallTypeReturn {
|
||||
try {
|
||||
ZodGetApplicationsSmallTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetApplicationsSmallTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getApplicationsSmall({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<ApplicationSmall[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetApplicationsSmallTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/small",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isApplicationSmall);
|
||||
}, isGetApplicationsSmallTypeReturn);
|
||||
};
|
||||
export function getClientToken({
|
||||
restConfig,
|
||||
@ -137,6 +167,20 @@ export namespace ApplicationResource {
|
||||
queries,
|
||||
}, isClientToken);
|
||||
};
|
||||
|
||||
export const ZodGetRightsDescriptionTypeReturn = zod.array(ZodRightDescription);
|
||||
export type GetRightsDescriptionTypeReturn = zod.infer<typeof ZodGetRightsDescriptionTypeReturn>;
|
||||
|
||||
export function isGetRightsDescriptionTypeReturn(data: any): data is GetRightsDescriptionTypeReturn {
|
||||
try {
|
||||
ZodGetRightsDescriptionTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetRightsDescriptionTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getRightsDescription({
|
||||
restConfig,
|
||||
params,
|
||||
@ -145,8 +189,8 @@ export namespace ApplicationResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
}): Promise<RightDescription[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetRightsDescriptionTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application/{id}/rights",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -154,21 +198,35 @@ export namespace ApplicationResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isRightDescription);
|
||||
}, isGetRightsDescriptionTypeReturn);
|
||||
};
|
||||
|
||||
export const ZodGetsTypeReturn = zod.array(ZodApplication);
|
||||
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||
|
||||
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
||||
try {
|
||||
ZodGetsTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function gets({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Application[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetsTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application",
|
||||
endPoint: "/application/",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isApplication);
|
||||
}, isGetsTypeReturn);
|
||||
};
|
||||
export function logOut({
|
||||
restConfig,
|
||||
@ -187,7 +245,7 @@ export namespace ApplicationResource {
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, null);
|
||||
});
|
||||
};
|
||||
export function patch({
|
||||
restConfig,
|
||||
@ -198,7 +256,7 @@ export namespace ApplicationResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Application,
|
||||
data: ApplicationWrite,
|
||||
}): Promise<Application> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
@ -1,23 +1,24 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import { z as zod } from "zod"
|
||||
import {
|
||||
ApplicationToken,
|
||||
CreateTokenRequest,
|
||||
Integer,
|
||||
Long,
|
||||
isApplicationToken,
|
||||
} from "./model"
|
||||
ApplicationToken,
|
||||
CreateTokenRequestWrite,
|
||||
Integer,
|
||||
Long,
|
||||
ZodApplicationToken,
|
||||
isApplicationToken,
|
||||
} from "../model";
|
||||
|
||||
export namespace ApplicationTokenResource {
|
||||
|
||||
export function create({
|
||||
@ -29,7 +30,7 @@ export namespace ApplicationTokenResource {
|
||||
params: {
|
||||
applicationId: Long,
|
||||
},
|
||||
data: CreateTokenRequest,
|
||||
data: CreateTokenRequestWrite,
|
||||
}): Promise<ApplicationToken> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -43,6 +44,20 @@ export namespace ApplicationTokenResource {
|
||||
data,
|
||||
}, isApplicationToken);
|
||||
};
|
||||
|
||||
export const ZodGetsTypeReturn = zod.array(ZodApplicationToken);
|
||||
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||
|
||||
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
||||
try {
|
||||
ZodGetsTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function gets({
|
||||
restConfig,
|
||||
params,
|
||||
@ -51,8 +66,8 @@ export namespace ApplicationTokenResource {
|
||||
params: {
|
||||
applicationId: Long,
|
||||
},
|
||||
}): Promise<ApplicationToken[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetsTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/application_token/{applicationId}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -60,7 +75,7 @@ export namespace ApplicationTokenResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, isApplicationToken);
|
||||
}, isGetsTypeReturn);
|
||||
};
|
||||
export function remove({
|
||||
restConfig,
|
@ -1,25 +1,23 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import {
|
||||
UUID,
|
||||
} from "./model"
|
||||
UUID,
|
||||
} from "../model";
|
||||
|
||||
export namespace DataResource {
|
||||
|
||||
/**
|
||||
* Get back some data from the data environment (with a beautiful name (permit download with basic name)
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataFull({
|
||||
restConfig,
|
||||
queries,
|
||||
@ -35,8 +33,8 @@ export namespace DataResource {
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/{uuid}/{name}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -50,7 +48,6 @@ export namespace DataResource {
|
||||
/**
|
||||
* Get back some data from the data environment
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataId({
|
||||
restConfig,
|
||||
queries,
|
||||
@ -65,8 +62,8 @@ export namespace DataResource {
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
@ -80,7 +77,6 @@ export namespace DataResource {
|
||||
/**
|
||||
* Get a thumbnail of from the data environment (if resize is possible)
|
||||
*/
|
||||
// TODO: unmanaged "Response" type: please specify @AsyncType or considered as 'void'.
|
||||
export function retrieveDataThumbnailId({
|
||||
restConfig,
|
||||
queries,
|
||||
@ -95,8 +91,8 @@ export namespace DataResource {
|
||||
uuid: UUID,
|
||||
},
|
||||
data: string,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
}): Promise<object> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/data/thumbnail/{uuid}",
|
||||
requestType: HTTPRequestModel.GET,
|
6
front/src/back-api/api/front.ts
Normal file
6
front/src/back-api/api/front.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
export namespace Front {
|
||||
|
||||
}
|
11
front/src/back-api/api/index.ts
Normal file
11
front/src/back-api/api/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
export * from "./application-resource"
|
||||
export * from "./application-token-resource"
|
||||
export * from "./data-resource"
|
||||
export * from "./front"
|
||||
export * from "./public-key-resource"
|
||||
export * from "./right-resource"
|
||||
export * from "./system-config-resource"
|
||||
export * from "./user-resource"
|
@ -1,20 +1,18 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
} from "../rest-tools";
|
||||
|
||||
import {
|
||||
PublicKey,
|
||||
isPublicKey,
|
||||
} from "./model"
|
||||
PublicKey,
|
||||
isPublicKey,
|
||||
} from "../model";
|
||||
|
||||
export namespace PublicKeyResource {
|
||||
|
||||
export function getKey({
|
||||
@ -24,7 +22,7 @@ export namespace PublicKeyResource {
|
||||
}): Promise<PublicKey> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/public_key",
|
||||
endPoint: "/public_key/",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
@ -43,6 +41,6 @@ export namespace PublicKeyResource {
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, null);
|
||||
});
|
||||
};
|
||||
}
|
@ -1,21 +1,23 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import { z as zod } from "zod"
|
||||
import {
|
||||
Long,
|
||||
Right,
|
||||
isRight,
|
||||
} from "./model"
|
||||
Long,
|
||||
Right,
|
||||
RightWrite,
|
||||
ZodRight,
|
||||
isRight,
|
||||
} from "../model";
|
||||
|
||||
export namespace RightResource {
|
||||
|
||||
export function get({
|
||||
@ -37,19 +39,33 @@ export namespace RightResource {
|
||||
params,
|
||||
}, isRight);
|
||||
};
|
||||
|
||||
export const ZodGetsTypeReturn = zod.array(ZodRight);
|
||||
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||
|
||||
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
||||
try {
|
||||
ZodGetsTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function gets({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<Right[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetsTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/right",
|
||||
endPoint: "/right/",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isRight);
|
||||
}, isGetsTypeReturn);
|
||||
};
|
||||
export function patch({
|
||||
restConfig,
|
||||
@ -60,7 +76,7 @@ export namespace RightResource {
|
||||
params: {
|
||||
id: Long,
|
||||
},
|
||||
data: Right,
|
||||
data: RightWrite,
|
||||
}): Promise<Right> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -79,11 +95,11 @@ export namespace RightResource {
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: Right,
|
||||
data: RightWrite,
|
||||
}): Promise<Right> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/right",
|
||||
endPoint: "/right/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
@ -1,22 +1,36 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import { z as zod } from "zod"
|
||||
import {
|
||||
GetSignUpAvailable,
|
||||
isGetSignUpAvailable,
|
||||
} from "./model"
|
||||
GetSignUpAvailable,
|
||||
isGetSignUpAvailable,
|
||||
} from "../model";
|
||||
|
||||
export namespace SystemConfigResource {
|
||||
|
||||
|
||||
export const ZodGetKeyTypeReturn = zod.record(zod.string(), zod.any());
|
||||
export type GetKeyTypeReturn = zod.infer<typeof ZodGetKeyTypeReturn>;
|
||||
|
||||
export function isGetKeyTypeReturn(data: any): data is GetKeyTypeReturn {
|
||||
try {
|
||||
ZodGetKeyTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetKeyTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getKey({
|
||||
restConfig,
|
||||
params,
|
||||
@ -25,7 +39,7 @@ export namespace SystemConfigResource {
|
||||
params: {
|
||||
key: string,
|
||||
},
|
||||
}): Promise<any> {
|
||||
}): Promise<GetKeyTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/system_config/key/{key}",
|
||||
@ -34,7 +48,7 @@ export namespace SystemConfigResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, null);
|
||||
}, isGetKeyTypeReturn);
|
||||
};
|
||||
export function isSignUpAvailable({
|
||||
restConfig,
|
||||
@ -59,7 +73,7 @@ export namespace SystemConfigResource {
|
||||
params: {
|
||||
key: string,
|
||||
},
|
||||
data: any,
|
||||
data: object,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
@ -1,30 +1,31 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestVoid,
|
||||
} from "../rest-tools";
|
||||
|
||||
import { z as zod } from "zod"
|
||||
import {
|
||||
ChangePassword,
|
||||
DataGetToken,
|
||||
GetToken,
|
||||
Long,
|
||||
UserAuth,
|
||||
UserAuthGet,
|
||||
UserCreate,
|
||||
UserOut,
|
||||
isUserAuth,
|
||||
isGetToken,
|
||||
isUserOut,
|
||||
isUserAuthGet,
|
||||
} from "./model"
|
||||
ChangePasswordWrite,
|
||||
DataGetTokenWrite,
|
||||
GetToken,
|
||||
Long,
|
||||
UserAuth,
|
||||
UserAuthGet,
|
||||
UserCreateWrite,
|
||||
UserOut,
|
||||
ZodUserAuthGet,
|
||||
isGetToken,
|
||||
isUserAuth,
|
||||
isUserAuthGet,
|
||||
isUserOut,
|
||||
} from "../model";
|
||||
|
||||
export namespace UserResource {
|
||||
|
||||
export function changePassword({
|
||||
@ -32,7 +33,7 @@ export namespace UserResource {
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: ChangePassword,
|
||||
data: ChangePasswordWrite,
|
||||
}): Promise<void> {
|
||||
return RESTRequestVoid({
|
||||
restModel: {
|
||||
@ -49,11 +50,11 @@ export namespace UserResource {
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: UserCreate,
|
||||
data: UserCreateWrite,
|
||||
}): Promise<UserAuthGet> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users",
|
||||
endPoint: "/users/",
|
||||
requestType: HTTPRequestModel.POST,
|
||||
contentType: HTTPMimeType.JSON,
|
||||
accept: HTTPMimeType.JSON,
|
||||
@ -62,6 +63,20 @@ export namespace UserResource {
|
||||
data,
|
||||
}, isUserAuthGet);
|
||||
};
|
||||
|
||||
export const ZodGetApplicationRightTypeReturn = zod.record(zod.string(), zod.any());
|
||||
export type GetApplicationRightTypeReturn = zod.infer<typeof ZodGetApplicationRightTypeReturn>;
|
||||
|
||||
export function isGetApplicationRightTypeReturn(data: any): data is GetApplicationRightTypeReturn {
|
||||
try {
|
||||
ZodGetApplicationRightTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetApplicationRightTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getApplicationRight({
|
||||
restConfig,
|
||||
params,
|
||||
@ -71,7 +86,7 @@ export namespace UserResource {
|
||||
applicationId: Long,
|
||||
userId: Long,
|
||||
},
|
||||
}): Promise<any> {
|
||||
}): Promise<GetApplicationRightTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||
@ -80,7 +95,7 @@ export namespace UserResource {
|
||||
},
|
||||
restConfig,
|
||||
params,
|
||||
}, null);
|
||||
}, isGetApplicationRightTypeReturn);
|
||||
};
|
||||
export function getMe({
|
||||
restConfig,
|
||||
@ -101,7 +116,7 @@ export namespace UserResource {
|
||||
data,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
data: DataGetToken,
|
||||
data: DataGetTokenWrite,
|
||||
}): Promise<GetToken> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
@ -133,19 +148,33 @@ export namespace UserResource {
|
||||
params,
|
||||
}, isUserAuthGet);
|
||||
};
|
||||
|
||||
export const ZodGetUsersTypeReturn = zod.array(ZodUserAuthGet);
|
||||
export type GetUsersTypeReturn = zod.infer<typeof ZodGetUsersTypeReturn>;
|
||||
|
||||
export function isGetUsersTypeReturn(data: any): data is GetUsersTypeReturn {
|
||||
try {
|
||||
ZodGetUsersTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetUsersTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getUsers({
|
||||
restConfig,
|
||||
}: {
|
||||
restConfig: RESTConfig,
|
||||
}): Promise<UserAuthGet[]> {
|
||||
return RESTRequestJsonArray({
|
||||
}): Promise<GetUsersTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users",
|
||||
endPoint: "/users/",
|
||||
requestType: HTTPRequestModel.GET,
|
||||
accept: HTTPMimeType.JSON,
|
||||
},
|
||||
restConfig,
|
||||
}, isUserAuthGet);
|
||||
}, isGetUsersTypeReturn);
|
||||
};
|
||||
export function isEmailExist({
|
||||
restConfig,
|
||||
@ -164,7 +193,7 @@ export namespace UserResource {
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, null);
|
||||
});
|
||||
};
|
||||
export function isLoginExist({
|
||||
restConfig,
|
||||
@ -183,7 +212,7 @@ export namespace UserResource {
|
||||
},
|
||||
restConfig,
|
||||
queries,
|
||||
}, null);
|
||||
});
|
||||
};
|
||||
export function linkApplication({
|
||||
restConfig,
|
||||
@ -208,6 +237,20 @@ export namespace UserResource {
|
||||
data,
|
||||
}, isUserAuth);
|
||||
};
|
||||
|
||||
export const ZodPatchApplicationRightTypeReturn = zod.record(zod.string(), zod.any());
|
||||
export type PatchApplicationRightTypeReturn = zod.infer<typeof ZodPatchApplicationRightTypeReturn>;
|
||||
|
||||
export function isPatchApplicationRightTypeReturn(data: any): data is PatchApplicationRightTypeReturn {
|
||||
try {
|
||||
ZodPatchApplicationRightTypeReturn.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodPatchApplicationRightTypeReturn' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function patchApplicationRight({
|
||||
restConfig,
|
||||
params,
|
||||
@ -218,8 +261,8 @@ export namespace UserResource {
|
||||
applicationId: Long,
|
||||
userId: Long,
|
||||
},
|
||||
data: any,
|
||||
}): Promise<any> {
|
||||
data: {[key: string]: object;},
|
||||
}): Promise<PatchApplicationRightTypeReturn> {
|
||||
return RESTRequestJson({
|
||||
restModel: {
|
||||
endPoint: "/users/{userId}/application/{applicationId}/rights",
|
||||
@ -230,7 +273,7 @@ export namespace UserResource {
|
||||
restConfig,
|
||||
params,
|
||||
data,
|
||||
}, null);
|
||||
}, isPatchApplicationRightTypeReturn);
|
||||
};
|
||||
export function setAdmin({
|
||||
restConfig,
|
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* API of the server (auto-generated code)
|
||||
*/
|
||||
import {
|
||||
HTTPMimeType,
|
||||
HTTPRequestModel,
|
||||
ModelResponseHttp,
|
||||
RESTCallbacks,
|
||||
RESTConfig,
|
||||
RESTRequestJson,
|
||||
RESTRequestJsonArray,
|
||||
RESTRequestVoid
|
||||
} from "./rest-tools"
|
||||
import {
|
||||
} from "./model"
|
||||
export namespace Front {
|
||||
|
||||
}
|
@ -1,12 +1,7 @@
|
||||
/**
|
||||
* Global import of the package
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
export * from "./model";
|
||||
export * from "./front";
|
||||
export * from "./data-resource";
|
||||
export * from "./application-resource";
|
||||
export * from "./application-token-resource";
|
||||
export * from "./public-key-resource";
|
||||
export * from "./right-resource";
|
||||
export * from "./user-resource";
|
||||
export * from "./system-config-resource";
|
||||
export * from "./api";
|
||||
export * from "./rest-tools";
|
||||
|
||||
|
@ -1,549 +0,0 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
export const ZodUUID = zod.string().uuid();
|
||||
export type UUID = zod.infer<typeof ZodUUID>;
|
||||
export function isUUID(data: any): data is UUID {
|
||||
try {
|
||||
ZodUUID.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodLong = zod.number();
|
||||
export type Long = zod.infer<typeof ZodLong>;
|
||||
export function isLong(data: any): data is Long {
|
||||
try {
|
||||
ZodLong.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodInteger = zod.number().safe();
|
||||
export type Integer = zod.infer<typeof ZodInteger>;
|
||||
export function isInteger(data: any): data is Integer {
|
||||
try {
|
||||
ZodInteger.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodFloat = zod.number();
|
||||
export type Float = zod.infer<typeof ZodFloat>;
|
||||
export function isFloat(data: any): data is Float {
|
||||
try {
|
||||
ZodFloat.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodInstant = zod.string();
|
||||
export type Instant = zod.infer<typeof ZodInstant>;
|
||||
export function isInstant(data: any): data is Instant {
|
||||
try {
|
||||
ZodInstant.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodDate = zod.string().datetime({ precision: 3 });
|
||||
export type Date = zod.infer<typeof ZodDate>;
|
||||
export function isDate(data: any): data is Date {
|
||||
try {
|
||||
ZodDate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodTimestamp = zod.string().datetime({ precision: 3 });
|
||||
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
||||
export function isTimestamp(data: any): data is Timestamp {
|
||||
try {
|
||||
ZodTimestamp.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodLocalDate = zod.string().date();
|
||||
export type LocalDate = zod.infer<typeof ZodLocalDate>;
|
||||
export function isLocalDate(data: any): data is LocalDate {
|
||||
try {
|
||||
ZodLocalDate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodLocalTime = zod.string().time();
|
||||
export type LocalTime = zod.infer<typeof ZodLocalTime>;
|
||||
export function isLocalTime(data: any): data is LocalTime {
|
||||
try {
|
||||
ZodLocalTime.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodRestErrorResponse = zod.object({
|
||||
uuid: ZodUUID.optional(),
|
||||
name: zod.string().max(255).optional(),
|
||||
message: zod.string().max(255).optional(),
|
||||
time: zod.string().max(255).optional(),
|
||||
status: ZodInteger,
|
||||
statusMessage: zod.string().max(255).optional()
|
||||
});
|
||||
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
||||
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||
try {
|
||||
ZodRestErrorResponse.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodAddUserData = zod.object({
|
||||
userId: ZodLong.optional()
|
||||
});
|
||||
export type AddUserData = zod.infer<typeof ZodAddUserData>;
|
||||
export function isAddUserData(data: any): data is AddUserData {
|
||||
try {
|
||||
ZodAddUserData.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericTiming = zod.object({
|
||||
// Create time of the object
|
||||
createdAt: ZodDate.readonly().optional(),
|
||||
// When update the object
|
||||
updatedAt: ZodDate.readonly().optional()
|
||||
});
|
||||
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
||||
export function isGenericTiming(data: any): data is GenericTiming {
|
||||
try {
|
||||
ZodGenericTiming.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericData = ZodGenericTiming.extend({
|
||||
// Unique Id of the object
|
||||
id: ZodLong.readonly().optional()
|
||||
});
|
||||
export type GenericData = zod.infer<typeof ZodGenericData>;
|
||||
export function isGenericData(data: any): data is GenericData {
|
||||
try {
|
||||
ZodGenericData.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||
// Deleted state
|
||||
deleted: zod.boolean().readonly().optional()
|
||||
});
|
||||
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
||||
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
||||
try {
|
||||
ZodGenericDataSoftDelete.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
||||
name: zod.string().max(256).optional(),
|
||||
description: zod.string().max(2048).optional(),
|
||||
redirect: zod.string().max(2048).optional(),
|
||||
redirectDev: zod.string().max(2048).optional(),
|
||||
notification: zod.string().max(2048).optional(),
|
||||
// Expiration time
|
||||
ttl: ZodInteger.optional(),
|
||||
// Right is manage with Karso
|
||||
manageRight: zod.boolean().optional()
|
||||
});
|
||||
export type Application = zod.infer<typeof ZodApplication>;
|
||||
export function isApplication(data: any): data is Application {
|
||||
try {
|
||||
ZodApplication.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodApplicationSmall = zod.object({
|
||||
id: ZodLong.optional(),
|
||||
name: zod.string().max(255).optional(),
|
||||
description: zod.string().max(255).optional(),
|
||||
redirect: zod.string().max(255).optional()
|
||||
});
|
||||
export type ApplicationSmall = zod.infer<typeof ZodApplicationSmall>;
|
||||
export function isApplicationSmall(data: any): data is ApplicationSmall {
|
||||
try {
|
||||
ZodApplicationSmall.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodClientToken = zod.object({
|
||||
url: zod.string().max(1024).optional(),
|
||||
jwt: zod.string().optional()
|
||||
});
|
||||
export type ClientToken = zod.infer<typeof ZodClientToken>;
|
||||
export function isClientToken(data: any): data is ClientToken {
|
||||
try {
|
||||
ZodClientToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
||||
// Application id that have the reference of the right
|
||||
applicationId: ZodLong.optional(),
|
||||
// Key of the property
|
||||
key: zod.string().max(64).optional(),
|
||||
// Title of the right
|
||||
title: zod.string().max(1024).optional(),
|
||||
// Description of the right
|
||||
description: zod.string().max(1024).optional(),
|
||||
// default value if Never set
|
||||
defaultValue: zod.string().max(1024).optional(),
|
||||
// Type of the property
|
||||
type: zod.string().max(16).optional()
|
||||
});
|
||||
export type RightDescription = zod.infer<typeof ZodRightDescription>;
|
||||
export function isRightDescription(data: any): data is RightDescription {
|
||||
try {
|
||||
ZodRightDescription.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||
parentId: ZodLong.optional(),
|
||||
name: zod.string().optional(),
|
||||
endValidityTime: ZodTimestamp.optional(),
|
||||
token: zod.string().optional()
|
||||
});
|
||||
export type GenericToken = zod.infer<typeof ZodGenericToken>;
|
||||
export function isGenericToken(data: any): data is GenericToken {
|
||||
try {
|
||||
ZodGenericToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodApplicationToken = ZodGenericToken.extend({
|
||||
});
|
||||
export type ApplicationToken = zod.infer<typeof ZodApplicationToken>;
|
||||
export function isApplicationToken(data: any): data is ApplicationToken {
|
||||
try {
|
||||
ZodApplicationToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodCreateTokenRequest = zod.object({
|
||||
name: zod.string().max(255).optional(),
|
||||
validity: ZodInteger.optional()
|
||||
});
|
||||
export type CreateTokenRequest = zod.infer<typeof ZodCreateTokenRequest>;
|
||||
export function isCreateTokenRequest(data: any): data is CreateTokenRequest {
|
||||
try {
|
||||
ZodCreateTokenRequest.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodPublicKey = zod.object({
|
||||
key: zod.string().max(255).optional()
|
||||
});
|
||||
export type PublicKey = zod.infer<typeof ZodPublicKey>;
|
||||
export function isPublicKey(data: any): data is PublicKey {
|
||||
try {
|
||||
ZodPublicKey.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
||||
// application-ID that have the reference of the right
|
||||
applicationId: ZodLong.optional(),
|
||||
// user-ID
|
||||
userId: ZodLong.optional(),
|
||||
// rightDescription-ID of the right description
|
||||
rightDescriptionId: ZodLong.optional(),
|
||||
// Value of the right
|
||||
value: zod.string().max(1024).optional()
|
||||
});
|
||||
export type Right = zod.infer<typeof ZodRight>;
|
||||
export function isRight(data: any): data is Right {
|
||||
try {
|
||||
ZodRight.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodChangePassword = zod.object({
|
||||
method: zod.string().max(32).optional(),
|
||||
login: zod.string().max(512).optional(),
|
||||
time: zod.string().max(64).optional(),
|
||||
password: zod.string().max(128).optional(),
|
||||
newPassword: zod.string().max(128).optional()
|
||||
});
|
||||
export type ChangePassword = zod.infer<typeof ZodChangePassword>;
|
||||
export function isChangePassword(data: any): data is ChangePassword {
|
||||
try {
|
||||
ZodChangePassword.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||
login: zod.string().max(128).optional(),
|
||||
lastConnection: ZodTimestamp.optional(),
|
||||
admin: zod.boolean(),
|
||||
blocked: zod.boolean(),
|
||||
removed: zod.boolean(),
|
||||
covers: zod.array(ZodLong).optional()
|
||||
});
|
||||
export type User = zod.infer<typeof ZodUser>;
|
||||
export function isUser(data: any): data is User {
|
||||
try {
|
||||
ZodUser.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserAuthGet = ZodUser.extend({
|
||||
email: zod.string().max(512).optional(),
|
||||
avatar: zod.boolean().optional()
|
||||
});
|
||||
export type UserAuthGet = zod.infer<typeof ZodUserAuthGet>;
|
||||
export function isUserAuthGet(data: any): data is UserAuthGet {
|
||||
try {
|
||||
ZodUserAuthGet.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserCreate = zod.object({
|
||||
login: zod.string().max(255).optional(),
|
||||
email: zod.string().max(255).optional(),
|
||||
password: zod.string().max(255).optional()
|
||||
});
|
||||
export type UserCreate = zod.infer<typeof ZodUserCreate>;
|
||||
export function isUserCreate(data: any): data is UserCreate {
|
||||
try {
|
||||
ZodUserCreate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserOut = zod.object({
|
||||
id: ZodLong,
|
||||
login: zod.string().max(255).optional()
|
||||
});
|
||||
export type UserOut = zod.infer<typeof ZodUserOut>;
|
||||
export function isUserOut(data: any): data is UserOut {
|
||||
try {
|
||||
ZodUserOut.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGetToken = zod.object({
|
||||
jwt: zod.string().optional()
|
||||
});
|
||||
export type GetToken = zod.infer<typeof ZodGetToken>;
|
||||
export function isGetToken(data: any): data is GetToken {
|
||||
try {
|
||||
ZodGetToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodDataGetToken = zod.object({
|
||||
});
|
||||
export type DataGetToken = zod.infer<typeof ZodDataGetToken>;
|
||||
export function isDataGetToken(data: any): data is DataGetToken {
|
||||
try {
|
||||
ZodDataGetToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodUserAuth = ZodUser.extend({
|
||||
password: zod.string().max(128).optional(),
|
||||
email: zod.string().max(512).optional(),
|
||||
emailValidate: ZodTimestamp.optional(),
|
||||
newEmail: zod.string().max(512).optional(),
|
||||
avatar: zod.boolean().optional(),
|
||||
// List of accessible application (if not set the application is not available)
|
||||
applications: zod.array(ZodLong).optional()
|
||||
});
|
||||
export type UserAuth = zod.infer<typeof ZodUserAuth>;
|
||||
export function isUserAuth(data: any): data is UserAuth {
|
||||
try {
|
||||
ZodUserAuth.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodGetSignUpAvailable = zod.object({
|
||||
signup: zod.boolean()
|
||||
});
|
||||
export type GetSignUpAvailable = zod.infer<typeof ZodGetSignUpAvailable>;
|
||||
export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
|
||||
try {
|
||||
ZodGetSignUpAvailable.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const ZodSettings = ZodGenericDataSoftDelete.extend({
|
||||
key: zod.string().max(512).optional(),
|
||||
// Right for the specific element(ADMIN [rw] USER [rw] other [rw])
|
||||
right: zod.string().max(6).optional(),
|
||||
// Type Of the data
|
||||
type: zod.string().max(10).optional(),
|
||||
// Value of the configuration
|
||||
value: zod.string().max(255).optional()
|
||||
});
|
||||
export type Settings = zod.infer<typeof ZodSettings>;
|
||||
export function isSettings(data: any): data is Settings {
|
||||
try {
|
||||
ZodSettings.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data ${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
37
front/src/back-api/model/add-user-data.ts
Normal file
37
front/src/back-api/model/add-user-data.ts
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
|
||||
export const ZodAddUserData = zod.object({
|
||||
userId: ZodLong.optional(),
|
||||
|
||||
});
|
||||
|
||||
export type AddUserData = zod.infer<typeof ZodAddUserData>;
|
||||
|
||||
export function isAddUserData(data: any): data is AddUserData {
|
||||
try {
|
||||
ZodAddUserData.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodAddUserData' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodAddUserDataWrite = ZodAddUserData.partial();
|
||||
|
||||
export type AddUserDataWrite = zod.infer<typeof ZodAddUserDataWrite>;
|
||||
|
||||
export function isAddUserDataWrite(data: any): data is AddUserDataWrite {
|
||||
try {
|
||||
ZodAddUserDataWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodAddUserDataWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
40
front/src/back-api/model/application-small.ts
Normal file
40
front/src/back-api/model/application-small.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
|
||||
export const ZodApplicationSmall = zod.object({
|
||||
id: ZodLong.optional(),
|
||||
name: zod.string().max(255).optional(),
|
||||
description: zod.string().max(255).optional(),
|
||||
redirect: zod.string().max(255).optional(),
|
||||
|
||||
});
|
||||
|
||||
export type ApplicationSmall = zod.infer<typeof ZodApplicationSmall>;
|
||||
|
||||
export function isApplicationSmall(data: any): data is ApplicationSmall {
|
||||
try {
|
||||
ZodApplicationSmall.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodApplicationSmall' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodApplicationSmallWrite = ZodApplicationSmall.partial();
|
||||
|
||||
export type ApplicationSmallWrite = zod.infer<typeof ZodApplicationSmallWrite>;
|
||||
|
||||
export function isApplicationSmallWrite(data: any): data is ApplicationSmallWrite {
|
||||
try {
|
||||
ZodApplicationSmallWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodApplicationSmallWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
42
front/src/back-api/model/application-token.ts
Normal file
42
front/src/back-api/model/application-token.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodGenericToken} from "./generic-token";
|
||||
|
||||
export const ZodApplicationToken = ZodGenericToken.extend({
|
||||
|
||||
});
|
||||
|
||||
export type ApplicationToken = zod.infer<typeof ZodApplicationToken>;
|
||||
|
||||
export function isApplicationToken(data: any): data is ApplicationToken {
|
||||
try {
|
||||
ZodApplicationToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodApplicationToken' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodApplicationTokenWrite = ZodApplicationToken.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type ApplicationTokenWrite = zod.infer<typeof ZodApplicationTokenWrite>;
|
||||
|
||||
export function isApplicationTokenWrite(data: any): data is ApplicationTokenWrite {
|
||||
try {
|
||||
ZodApplicationTokenWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodApplicationTokenWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
56
front/src/back-api/model/application.ts
Normal file
56
front/src/back-api/model/application.ts
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodInteger} from "./integer";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
||||
name: zod.string().max(256).optional(),
|
||||
description: zod.string().max(2048).optional(),
|
||||
redirect: zod.string().max(2048),
|
||||
redirectDev: zod.string().max(2048).optional(),
|
||||
notification: zod.string().max(2048).optional(),
|
||||
/**
|
||||
* Expiration time
|
||||
*/
|
||||
ttl: ZodInteger,
|
||||
/**
|
||||
* Right is manage with Karso
|
||||
*/
|
||||
manageRight: zod.boolean(),
|
||||
|
||||
});
|
||||
|
||||
export type Application = zod.infer<typeof ZodApplication>;
|
||||
|
||||
export function isApplication(data: any): data is Application {
|
||||
try {
|
||||
ZodApplication.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodApplication' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodApplicationWrite = ZodApplication.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type ApplicationWrite = zod.infer<typeof ZodApplicationWrite>;
|
||||
|
||||
export function isApplicationWrite(data: any): data is ApplicationWrite {
|
||||
try {
|
||||
ZodApplicationWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodApplicationWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
40
front/src/back-api/model/change-password.ts
Normal file
40
front/src/back-api/model/change-password.ts
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodChangePassword = zod.object({
|
||||
method: zod.string().max(32).optional(),
|
||||
login: zod.string().max(512).optional(),
|
||||
time: zod.string().max(64).optional(),
|
||||
password: zod.string().max(128).optional(),
|
||||
newPassword: zod.string().max(128).optional(),
|
||||
|
||||
});
|
||||
|
||||
export type ChangePassword = zod.infer<typeof ZodChangePassword>;
|
||||
|
||||
export function isChangePassword(data: any): data is ChangePassword {
|
||||
try {
|
||||
ZodChangePassword.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodChangePassword' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodChangePasswordWrite = ZodChangePassword.partial();
|
||||
|
||||
export type ChangePasswordWrite = zod.infer<typeof ZodChangePasswordWrite>;
|
||||
|
||||
export function isChangePasswordWrite(data: any): data is ChangePasswordWrite {
|
||||
try {
|
||||
ZodChangePasswordWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodChangePasswordWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
37
front/src/back-api/model/client-token.ts
Normal file
37
front/src/back-api/model/client-token.ts
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodClientToken = zod.object({
|
||||
url: zod.string().max(1024).optional(),
|
||||
jwt: zod.string().optional(),
|
||||
|
||||
});
|
||||
|
||||
export type ClientToken = zod.infer<typeof ZodClientToken>;
|
||||
|
||||
export function isClientToken(data: any): data is ClientToken {
|
||||
try {
|
||||
ZodClientToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodClientToken' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodClientTokenWrite = ZodClientToken.partial();
|
||||
|
||||
export type ClientTokenWrite = zod.infer<typeof ZodClientTokenWrite>;
|
||||
|
||||
export function isClientTokenWrite(data: any): data is ClientTokenWrite {
|
||||
try {
|
||||
ZodClientTokenWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodClientTokenWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
38
front/src/back-api/model/create-token-request.ts
Normal file
38
front/src/back-api/model/create-token-request.ts
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodInteger} from "./integer";
|
||||
|
||||
export const ZodCreateTokenRequest = zod.object({
|
||||
name: zod.string().max(255).optional(),
|
||||
validity: ZodInteger.optional(),
|
||||
|
||||
});
|
||||
|
||||
export type CreateTokenRequest = zod.infer<typeof ZodCreateTokenRequest>;
|
||||
|
||||
export function isCreateTokenRequest(data: any): data is CreateTokenRequest {
|
||||
try {
|
||||
ZodCreateTokenRequest.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodCreateTokenRequest' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodCreateTokenRequestWrite = ZodCreateTokenRequest.partial();
|
||||
|
||||
export type CreateTokenRequestWrite = zod.infer<typeof ZodCreateTokenRequestWrite>;
|
||||
|
||||
export function isCreateTokenRequestWrite(data: any): data is CreateTokenRequestWrite {
|
||||
try {
|
||||
ZodCreateTokenRequestWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodCreateTokenRequestWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
35
front/src/back-api/model/data-get-token.ts
Normal file
35
front/src/back-api/model/data-get-token.ts
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodDataGetToken = zod.object({
|
||||
|
||||
});
|
||||
|
||||
export type DataGetToken = zod.infer<typeof ZodDataGetToken>;
|
||||
|
||||
export function isDataGetToken(data: any): data is DataGetToken {
|
||||
try {
|
||||
ZodDataGetToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodDataGetToken' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodDataGetTokenWrite = ZodDataGetToken.partial();
|
||||
|
||||
export type DataGetTokenWrite = zod.infer<typeof ZodDataGetTokenWrite>;
|
||||
|
||||
export function isDataGetTokenWrite(data: any): data is DataGetTokenWrite {
|
||||
try {
|
||||
ZodDataGetTokenWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodDataGetTokenWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
46
front/src/back-api/model/generic-data-soft-delete.ts
Normal file
46
front/src/back-api/model/generic-data-soft-delete.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodGenericData} from "./generic-data";
|
||||
|
||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||
/**
|
||||
* Deleted state
|
||||
*/
|
||||
deleted: zod.boolean().readonly().optional(),
|
||||
|
||||
});
|
||||
|
||||
export type GenericDataSoftDelete = zod.infer<typeof ZodGenericDataSoftDelete>;
|
||||
|
||||
export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelete {
|
||||
try {
|
||||
ZodGenericDataSoftDelete.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericDataSoftDelete' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataSoftDelete.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
||||
|
||||
export function isGenericDataSoftDeleteWrite(data: any): data is GenericDataSoftDeleteWrite {
|
||||
try {
|
||||
ZodGenericDataSoftDeleteWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericDataSoftDeleteWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
46
front/src/back-api/model/generic-data.ts
Normal file
46
front/src/back-api/model/generic-data.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodGenericTiming} from "./generic-timing";
|
||||
|
||||
export const ZodGenericData = ZodGenericTiming.extend({
|
||||
/**
|
||||
* Unique Id of the object
|
||||
*/
|
||||
id: ZodLong.readonly(),
|
||||
|
||||
});
|
||||
|
||||
export type GenericData = zod.infer<typeof ZodGenericData>;
|
||||
|
||||
export function isGenericData(data: any): data is GenericData {
|
||||
try {
|
||||
ZodGenericData.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericData' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodGenericDataWrite = ZodGenericData.omit({
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
||||
|
||||
export function isGenericDataWrite(data: any): data is GenericDataWrite {
|
||||
try {
|
||||
ZodGenericDataWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericDataWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
48
front/src/back-api/model/generic-timing.ts
Normal file
48
front/src/back-api/model/generic-timing.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodIsoDate} from "./iso-date";
|
||||
|
||||
export const ZodGenericTiming = zod.object({
|
||||
/**
|
||||
* Create time of the object
|
||||
*/
|
||||
createdAt: ZodIsoDate.readonly().optional(),
|
||||
/**
|
||||
* When update the object
|
||||
*/
|
||||
updatedAt: ZodIsoDate.readonly().optional(),
|
||||
|
||||
});
|
||||
|
||||
export type GenericTiming = zod.infer<typeof ZodGenericTiming>;
|
||||
|
||||
export function isGenericTiming(data: any): data is GenericTiming {
|
||||
try {
|
||||
ZodGenericTiming.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericTiming' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodGenericTimingWrite = ZodGenericTiming.omit({
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
||||
|
||||
export function isGenericTimingWrite(data: any): data is GenericTimingWrite {
|
||||
try {
|
||||
ZodGenericTimingWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericTimingWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
48
front/src/back-api/model/generic-token.ts
Normal file
48
front/src/back-api/model/generic-token.ts
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodTimestamp} from "./timestamp";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||
parentId: ZodLong,
|
||||
name: zod.string(),
|
||||
endValidityTime: ZodTimestamp,
|
||||
token: zod.string(),
|
||||
|
||||
});
|
||||
|
||||
export type GenericToken = zod.infer<typeof ZodGenericToken>;
|
||||
|
||||
export function isGenericToken(data: any): data is GenericToken {
|
||||
try {
|
||||
ZodGenericToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericToken' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodGenericTokenWrite = ZodGenericToken.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type GenericTokenWrite = zod.infer<typeof ZodGenericTokenWrite>;
|
||||
|
||||
export function isGenericTokenWrite(data: any): data is GenericTokenWrite {
|
||||
try {
|
||||
ZodGenericTokenWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGenericTokenWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
36
front/src/back-api/model/get-sign-up-available.ts
Normal file
36
front/src/back-api/model/get-sign-up-available.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodGetSignUpAvailable = zod.object({
|
||||
signup: zod.boolean(),
|
||||
|
||||
});
|
||||
|
||||
export type GetSignUpAvailable = zod.infer<typeof ZodGetSignUpAvailable>;
|
||||
|
||||
export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
|
||||
try {
|
||||
ZodGetSignUpAvailable.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetSignUpAvailable' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodGetSignUpAvailableWrite = ZodGetSignUpAvailable.partial();
|
||||
|
||||
export type GetSignUpAvailableWrite = zod.infer<typeof ZodGetSignUpAvailableWrite>;
|
||||
|
||||
export function isGetSignUpAvailableWrite(data: any): data is GetSignUpAvailableWrite {
|
||||
try {
|
||||
ZodGetSignUpAvailableWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetSignUpAvailableWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
36
front/src/back-api/model/get-token.ts
Normal file
36
front/src/back-api/model/get-token.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodGetToken = zod.object({
|
||||
jwt: zod.string(),
|
||||
|
||||
});
|
||||
|
||||
export type GetToken = zod.infer<typeof ZodGetToken>;
|
||||
|
||||
export function isGetToken(data: any): data is GetToken {
|
||||
try {
|
||||
ZodGetToken.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetToken' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodGetTokenWrite = ZodGetToken.partial();
|
||||
|
||||
export type GetTokenWrite = zod.infer<typeof ZodGetTokenWrite>;
|
||||
|
||||
export function isGetTokenWrite(data: any): data is GetTokenWrite {
|
||||
try {
|
||||
ZodGetTokenWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodGetTokenWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
32
front/src/back-api/model/index.ts
Normal file
32
front/src/back-api/model/index.ts
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
export * from "./add-user-data"
|
||||
export * from "./application"
|
||||
export * from "./application-small"
|
||||
export * from "./application-token"
|
||||
export * from "./change-password"
|
||||
export * from "./client-token"
|
||||
export * from "./create-token-request"
|
||||
export * from "./data-get-token"
|
||||
export * from "./generic-data"
|
||||
export * from "./generic-data-soft-delete"
|
||||
export * from "./generic-timing"
|
||||
export * from "./generic-token"
|
||||
export * from "./get-sign-up-available"
|
||||
export * from "./get-token"
|
||||
export * from "./int"
|
||||
export * from "./integer"
|
||||
export * from "./iso-date"
|
||||
export * from "./long"
|
||||
export * from "./public-key"
|
||||
export * from "./rest-error-response"
|
||||
export * from "./right"
|
||||
export * from "./right-description"
|
||||
export * from "./timestamp"
|
||||
export * from "./user"
|
||||
export * from "./user-auth"
|
||||
export * from "./user-auth-get"
|
||||
export * from "./user-create"
|
||||
export * from "./user-out"
|
||||
export * from "./uuid"
|
35
front/src/back-api/model/int.ts
Normal file
35
front/src/back-api/model/int.ts
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const Zodint = zod.object({
|
||||
|
||||
});
|
||||
|
||||
export type int = zod.infer<typeof Zodint>;
|
||||
|
||||
export function isint(data: any): data is int {
|
||||
try {
|
||||
Zodint.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='Zodint' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodintWrite = Zodint.partial();
|
||||
|
||||
export type intWrite = zod.infer<typeof ZodintWrite>;
|
||||
|
||||
export function isintWrite(data: any): data is intWrite {
|
||||
try {
|
||||
ZodintWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodintWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
8
front/src/back-api/model/integer.ts
Normal file
8
front/src/back-api/model/integer.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodInteger = zod.number().safe();
|
||||
export type Integer = zod.infer<typeof ZodInteger>;
|
8
front/src/back-api/model/iso-date.ts
Normal file
8
front/src/back-api/model/iso-date.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodIsoDate = zod.string().datetime({ precision: 3 });
|
||||
export type IsoDate = zod.infer<typeof ZodIsoDate>;
|
8
front/src/back-api/model/long.ts
Normal file
8
front/src/back-api/model/long.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodLong = zod.number();
|
||||
export type Long = zod.infer<typeof ZodLong>;
|
36
front/src/back-api/model/public-key.ts
Normal file
36
front/src/back-api/model/public-key.ts
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodPublicKey = zod.object({
|
||||
key: zod.string().max(255).optional(),
|
||||
|
||||
});
|
||||
|
||||
export type PublicKey = zod.infer<typeof ZodPublicKey>;
|
||||
|
||||
export function isPublicKey(data: any): data is PublicKey {
|
||||
try {
|
||||
ZodPublicKey.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodPublicKey' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodPublicKeyWrite = ZodPublicKey.partial();
|
||||
|
||||
export type PublicKeyWrite = zod.infer<typeof ZodPublicKeyWrite>;
|
||||
|
||||
export function isPublicKeyWrite(data: any): data is PublicKeyWrite {
|
||||
try {
|
||||
ZodPublicKeyWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodPublicKeyWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
43
front/src/back-api/model/rest-error-response.ts
Normal file
43
front/src/back-api/model/rest-error-response.ts
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {Zodint} from "./int";
|
||||
|
||||
export const ZodRestErrorResponse = zod.object({
|
||||
uuid: ZodUUID.optional(),
|
||||
name: zod.string(),
|
||||
message: zod.string(),
|
||||
time: zod.string(),
|
||||
status: Zodint,
|
||||
statusMessage: zod.string(),
|
||||
|
||||
});
|
||||
|
||||
export type RestErrorResponse = zod.infer<typeof ZodRestErrorResponse>;
|
||||
|
||||
export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
||||
try {
|
||||
ZodRestErrorResponse.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodRestErrorResponse' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodRestErrorResponseWrite = ZodRestErrorResponse.partial();
|
||||
|
||||
export type RestErrorResponseWrite = zod.infer<typeof ZodRestErrorResponseWrite>;
|
||||
|
||||
export function isRestErrorResponseWrite(data: any): data is RestErrorResponseWrite {
|
||||
try {
|
||||
ZodRestErrorResponseWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodRestErrorResponseWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
67
front/src/back-api/model/right-description.ts
Normal file
67
front/src/back-api/model/right-description.ts
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* Application id that have the reference of the right
|
||||
*/
|
||||
applicationId: ZodLong,
|
||||
/**
|
||||
* Key of the property
|
||||
*/
|
||||
key: zod.string().max(64),
|
||||
/**
|
||||
* Title of the right
|
||||
*/
|
||||
title: zod.string().max(1024),
|
||||
/**
|
||||
* Description of the right
|
||||
*/
|
||||
description: zod.string().max(1024),
|
||||
/**
|
||||
* default value if Never set
|
||||
*/
|
||||
defaultValue: zod.string().max(1024).optional(),
|
||||
/**
|
||||
* Type of the property
|
||||
*/
|
||||
type: zod.string().max(16),
|
||||
|
||||
});
|
||||
|
||||
export type RightDescription = zod.infer<typeof ZodRightDescription>;
|
||||
|
||||
export function isRightDescription(data: any): data is RightDescription {
|
||||
try {
|
||||
ZodRightDescription.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodRightDescription' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodRightDescriptionWrite = ZodRightDescription.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type RightDescriptionWrite = zod.infer<typeof ZodRightDescriptionWrite>;
|
||||
|
||||
export function isRightDescriptionWrite(data: any): data is RightDescriptionWrite {
|
||||
try {
|
||||
ZodRightDescriptionWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodRightDescriptionWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
59
front/src/back-api/model/right.ts
Normal file
59
front/src/back-api/model/right.ts
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
||||
/**
|
||||
* application-ID that have the reference of the right
|
||||
*/
|
||||
applicationId: ZodLong,
|
||||
/**
|
||||
* user-ID
|
||||
*/
|
||||
userId: ZodLong,
|
||||
/**
|
||||
* rightDescription-ID of the right description
|
||||
*/
|
||||
rightDescriptionId: ZodLong,
|
||||
/**
|
||||
* Value of the right
|
||||
*/
|
||||
value: zod.string().max(1024),
|
||||
|
||||
});
|
||||
|
||||
export type Right = zod.infer<typeof ZodRight>;
|
||||
|
||||
export function isRight(data: any): data is Right {
|
||||
try {
|
||||
ZodRight.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodRight' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodRightWrite = ZodRight.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type RightWrite = zod.infer<typeof ZodRightWrite>;
|
||||
|
||||
export function isRightWrite(data: any): data is RightWrite {
|
||||
try {
|
||||
ZodRightWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodRightWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
8
front/src/back-api/model/timestamp.ts
Normal file
8
front/src/back-api/model/timestamp.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodTimestamp = zod.string().datetime({ precision: 3 });
|
||||
export type Timestamp = zod.infer<typeof ZodTimestamp>;
|
44
front/src/back-api/model/user-auth-get.ts
Normal file
44
front/src/back-api/model/user-auth-get.ts
Normal file
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodUser} from "./user";
|
||||
|
||||
export const ZodUserAuthGet = ZodUser.extend({
|
||||
email: zod.string().max(512),
|
||||
avatar: zod.boolean(),
|
||||
|
||||
});
|
||||
|
||||
export type UserAuthGet = zod.infer<typeof ZodUserAuthGet>;
|
||||
|
||||
export function isUserAuthGet(data: any): data is UserAuthGet {
|
||||
try {
|
||||
ZodUserAuthGet.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserAuthGet' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodUserAuthGetWrite = ZodUserAuthGet.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type UserAuthGetWrite = zod.infer<typeof ZodUserAuthGetWrite>;
|
||||
|
||||
export function isUserAuthGetWrite(data: any): data is UserAuthGetWrite {
|
||||
try {
|
||||
ZodUserAuthGetWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserAuthGetWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
53
front/src/back-api/model/user-auth.ts
Normal file
53
front/src/back-api/model/user-auth.ts
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodTimestamp} from "./timestamp";
|
||||
import {ZodLong} from "./long";
|
||||
import {ZodUser} from "./user";
|
||||
|
||||
export const ZodUserAuth = ZodUser.extend({
|
||||
password: zod.string().max(128),
|
||||
email: zod.string().max(512),
|
||||
emailValidate: ZodTimestamp.optional(),
|
||||
newEmail: zod.string().max(512).optional(),
|
||||
avatar: zod.boolean(),
|
||||
/**
|
||||
* List of accessible application (if not set the application is not available)
|
||||
*/
|
||||
applications: zod.array(ZodLong),
|
||||
|
||||
});
|
||||
|
||||
export type UserAuth = zod.infer<typeof ZodUserAuth>;
|
||||
|
||||
export function isUserAuth(data: any): data is UserAuth {
|
||||
try {
|
||||
ZodUserAuth.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserAuth' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodUserAuthWrite = ZodUserAuth.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type UserAuthWrite = zod.infer<typeof ZodUserAuthWrite>;
|
||||
|
||||
export function isUserAuthWrite(data: any): data is UserAuthWrite {
|
||||
try {
|
||||
ZodUserAuthWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserAuthWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
38
front/src/back-api/model/user-create.ts
Normal file
38
front/src/back-api/model/user-create.ts
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodUserCreate = zod.object({
|
||||
login: zod.string().max(255).optional(),
|
||||
email: zod.string().max(255).optional(),
|
||||
password: zod.string().max(255).optional(),
|
||||
|
||||
});
|
||||
|
||||
export type UserCreate = zod.infer<typeof ZodUserCreate>;
|
||||
|
||||
export function isUserCreate(data: any): data is UserCreate {
|
||||
try {
|
||||
ZodUserCreate.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserCreate' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodUserCreateWrite = ZodUserCreate.partial();
|
||||
|
||||
export type UserCreateWrite = zod.infer<typeof ZodUserCreateWrite>;
|
||||
|
||||
export function isUserCreateWrite(data: any): data is UserCreateWrite {
|
||||
try {
|
||||
ZodUserCreateWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserCreateWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
38
front/src/back-api/model/user-out.ts
Normal file
38
front/src/back-api/model/user-out.ts
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodLong} from "./long";
|
||||
|
||||
export const ZodUserOut = zod.object({
|
||||
id: ZodLong,
|
||||
login: zod.string().max(255).optional(),
|
||||
|
||||
});
|
||||
|
||||
export type UserOut = zod.infer<typeof ZodUserOut>;
|
||||
|
||||
export function isUserOut(data: any): data is UserOut {
|
||||
try {
|
||||
ZodUserOut.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserOut' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodUserOutWrite = ZodUserOut.partial();
|
||||
|
||||
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
||||
|
||||
export function isUserOutWrite(data: any): data is UserOutWrite {
|
||||
try {
|
||||
ZodUserOutWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserOutWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
53
front/src/back-api/model/user.ts
Normal file
53
front/src/back-api/model/user.ts
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
import {ZodTimestamp} from "./timestamp";
|
||||
import {ZodUUID} from "./uuid";
|
||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
||||
|
||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||
login: zod.string().max(128).optional(),
|
||||
lastConnection: ZodTimestamp.optional(),
|
||||
admin: zod.boolean(),
|
||||
blocked: zod.boolean(),
|
||||
removed: zod.boolean(),
|
||||
/**
|
||||
* List of Id of the specific covers
|
||||
*/
|
||||
covers: zod.array(ZodUUID).optional(),
|
||||
|
||||
});
|
||||
|
||||
export type User = zod.infer<typeof ZodUser>;
|
||||
|
||||
export function isUser(data: any): data is User {
|
||||
try {
|
||||
ZodUser.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUser' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const ZodUserWrite = ZodUser.omit({
|
||||
deleted: true,
|
||||
id: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
|
||||
}).partial();
|
||||
|
||||
export type UserWrite = zod.infer<typeof ZodUserWrite>;
|
||||
|
||||
export function isUserWrite(data: any): data is UserWrite {
|
||||
try {
|
||||
ZodUserWrite.parse(data);
|
||||
return true;
|
||||
} catch (e: any) {
|
||||
console.log(`Fail to parse data type='ZodUserWrite' error=${e}`);
|
||||
return false;
|
||||
}
|
||||
}
|
8
front/src/back-api/model/uuid.ts
Normal file
8
front/src/back-api/model/uuid.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Interface of the server (auto-generated code)
|
||||
*/
|
||||
import { z as zod } from "zod";
|
||||
|
||||
|
||||
export const ZodUUID = zod.string().uuid();
|
||||
export type UUID = zod.infer<typeof ZodUUID>;
|
@ -4,377 +4,442 @@
|
||||
* @license MPL-2
|
||||
*/
|
||||
|
||||
import { RestErrorResponse } from "./model"
|
||||
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||
|
||||
export enum HTTPRequestModel {
|
||||
DELETE = 'DELETE',
|
||||
GET = 'GET',
|
||||
PATCH = 'PATCH',
|
||||
POST = 'POST',
|
||||
PUT = 'PUT',
|
||||
DELETE = "DELETE",
|
||||
GET = "GET",
|
||||
PATCH = "PATCH",
|
||||
POST = "POST",
|
||||
PUT = "PUT",
|
||||
}
|
||||
export enum HTTPMimeType {
|
||||
ALL = '*/*',
|
||||
CSV = 'text/csv',
|
||||
IMAGE = 'image/*',
|
||||
IMAGE_JPEG = 'image/jpeg',
|
||||
IMAGE_PNG = 'image/png',
|
||||
JSON = 'application/json',
|
||||
MULTIPART = 'multipart/form-data',
|
||||
OCTET_STREAM = 'application/octet-stream',
|
||||
TEXT_PLAIN = 'text/plain',
|
||||
ALL = "*/*",
|
||||
CSV = "text/csv",
|
||||
IMAGE = "image/*",
|
||||
IMAGE_JPEG = "image/jpeg",
|
||||
IMAGE_PNG = "image/png",
|
||||
JSON = "application/json",
|
||||
MULTIPART = "multipart/form-data",
|
||||
OCTET_STREAM = "application/octet-stream",
|
||||
TEXT_PLAIN = "text/plain",
|
||||
}
|
||||
|
||||
export interface RESTConfig {
|
||||
// base of the server: http(s)://my.server.org/plop/api/
|
||||
server: string;
|
||||
// Token to access of the data.
|
||||
token?: string;
|
||||
// base of the server: http(s)://my.server.org/plop/api/
|
||||
server: string;
|
||||
// Token to access of the data.
|
||||
token?: string;
|
||||
}
|
||||
|
||||
export interface RESTModel {
|
||||
// base of the local API request: "sheep/{id}".
|
||||
endPoint: string;
|
||||
// Type of the request.
|
||||
requestType?: HTTPRequestModel;
|
||||
// Input type requested.
|
||||
accept?: HTTPMimeType;
|
||||
// Content of the local data.
|
||||
contentType?: HTTPMimeType;
|
||||
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||
tokenInUrl?: boolean;
|
||||
// base of the local API request: "sheep/{id}".
|
||||
endPoint: string;
|
||||
// Type of the request.
|
||||
requestType?: HTTPRequestModel;
|
||||
// Input type requested.
|
||||
accept?: HTTPMimeType;
|
||||
// Content of the local data.
|
||||
contentType?: HTTPMimeType;
|
||||
// Mode of the TOKEN in URL or Header (?token:${tokenInUrl})
|
||||
tokenInUrl?: boolean;
|
||||
}
|
||||
|
||||
export interface ModelResponseHttp {
|
||||
status: number;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export function isArrayOf<TYPE>(
|
||||
data: any,
|
||||
typeChecker: (subData: any) => subData is TYPE,
|
||||
length?: number
|
||||
): data is TYPE[] {
|
||||
if (!Array.isArray(data)) {
|
||||
return false;
|
||||
}
|
||||
if (!data.every(typeChecker)) {
|
||||
return false;
|
||||
}
|
||||
if (length !== undefined && data.length != length) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
status: number;
|
||||
data: any;
|
||||
}
|
||||
|
||||
function isNullOrUndefined(data: any): data is undefined | null {
|
||||
return data === undefined || data === null;
|
||||
return data === undefined || data === null;
|
||||
}
|
||||
|
||||
// generic progression callback
|
||||
export type ProgressCallback = (count: number, total: number) => void;
|
||||
|
||||
export interface RESTAbort {
|
||||
abort?: () => boolean
|
||||
abort?: () => boolean;
|
||||
}
|
||||
|
||||
|
||||
// Rest generic callback have a basic model to upload and download advancement.
|
||||
export interface RESTCallbacks {
|
||||
progressUpload?: ProgressCallback,
|
||||
progressDownload?: ProgressCallback,
|
||||
abortHandle?: RESTAbort,
|
||||
};
|
||||
progressUpload?: ProgressCallback;
|
||||
progressDownload?: ProgressCallback;
|
||||
abortHandle?: RESTAbort;
|
||||
}
|
||||
|
||||
export interface RESTRequestType {
|
||||
restModel: RESTModel,
|
||||
restConfig: RESTConfig,
|
||||
data?: any,
|
||||
params?: object,
|
||||
queries?: object,
|
||||
callback?: RESTCallbacks,
|
||||
};
|
||||
restModel: RESTModel;
|
||||
restConfig: RESTConfig;
|
||||
data?: any;
|
||||
params?: object;
|
||||
queries?: object;
|
||||
callback?: RESTCallbacks;
|
||||
}
|
||||
|
||||
function replaceAll(input, searchValue, replaceValue) {
|
||||
return input.split(searchValue).join(replaceValue);
|
||||
}
|
||||
|
||||
function removeTrailingSlashes(input: string): string {
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "undefined";
|
||||
}
|
||||
return input.replace(/\/+$/, '');
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "undefined";
|
||||
}
|
||||
return input.replace(/\/+$/, "");
|
||||
}
|
||||
function removeLeadingSlashes(input: string): string {
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "";
|
||||
}
|
||||
return input.replace(/^\/+/, '');
|
||||
if (isNullOrUndefined(input)) {
|
||||
return "";
|
||||
}
|
||||
return input.replace(/^\/+/, "");
|
||||
}
|
||||
|
||||
export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestType): string {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||
if (params !== undefined) {
|
||||
for (let key of Object.keys(params)) {
|
||||
generateUrl = replaceAll(generateUrl, `{${key}}`, `${params[key]}`);
|
||||
export function RESTUrl({
|
||||
restModel,
|
||||
restConfig,
|
||||
params,
|
||||
queries,
|
||||
}: RESTRequestType): string {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = `${removeTrailingSlashes(
|
||||
restConfig.server
|
||||
)}/${removeLeadingSlashes(restModel.endPoint)}`;
|
||||
if (params !== undefined) {
|
||||
for (let key of Object.keys(params)) {
|
||||
generateUrl = replaceAll(generateUrl, `{${key}}`, `${params[key]}`);
|
||||
}
|
||||
}
|
||||
if (
|
||||
queries === undefined &&
|
||||
(restConfig.token === undefined || restModel.tokenInUrl !== true)
|
||||
) {
|
||||
return generateUrl;
|
||||
}
|
||||
const searchParams = new URLSearchParams();
|
||||
if (queries !== undefined) {
|
||||
for (let key of Object.keys(queries)) {
|
||||
const value = queries[key];
|
||||
if (Array.isArray(value)) {
|
||||
for (const element of value) {
|
||||
searchParams.append(`${key}`, `${element}`);
|
||||
}
|
||||
} else {
|
||||
searchParams.append(`${key}`, `${value}`);
|
||||
}
|
||||
}
|
||||
if (queries === undefined && (restConfig.token === undefined || restModel.tokenInUrl !== true)) {
|
||||
return generateUrl;
|
||||
}
|
||||
const searchParams = new URLSearchParams();
|
||||
if (queries !== undefined) {
|
||||
for (let key of Object.keys(queries)) {
|
||||
const value = queries[key];
|
||||
if (Array.isArray(value)) {
|
||||
for (let iii = 0; iii < value.length; iii++) {
|
||||
searchParams.append(`${key}`, `${value[iii]}`);
|
||||
}
|
||||
} else {
|
||||
searchParams.append(`${key}`, `${value}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
|
||||
}
|
||||
return generateUrl + "?" + searchParams.toString();
|
||||
}
|
||||
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
|
||||
searchParams.append("Authorization", `Bearer ${restConfig.token}`);
|
||||
}
|
||||
return generateUrl + "?" + searchParams.toString();
|
||||
}
|
||||
|
||||
|
||||
export function fetchProgress(generateUrl: string, { method, headers, body }: {
|
||||
method: HTTPRequestModel,
|
||||
headers: any,
|
||||
body: any,
|
||||
}, { progressUpload, progressDownload, abortHandle }: RESTCallbacks): Promise<Response> {
|
||||
const xhr = {
|
||||
io: new XMLHttpRequest()
|
||||
export function fetchProgress(
|
||||
generateUrl: string,
|
||||
{
|
||||
method,
|
||||
headers,
|
||||
body,
|
||||
}: {
|
||||
method: HTTPRequestModel;
|
||||
headers: any;
|
||||
body: any;
|
||||
},
|
||||
{ progressUpload, progressDownload, abortHandle }: RESTCallbacks
|
||||
): Promise<Response> {
|
||||
const xhr: {
|
||||
io?: XMLHttpRequest;
|
||||
} = {
|
||||
io: new XMLHttpRequest(),
|
||||
};
|
||||
return new Promise((resolve, reject) => {
|
||||
// Stream the upload progress
|
||||
if (progressUpload) {
|
||||
xhr.io?.upload.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
});
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
// Stream the upload progress
|
||||
if (progressUpload) {
|
||||
xhr.io.upload.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
//console.log(` ==> has a progress event: ${dataEvent.loaded} / ${dataEvent.total}`);
|
||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
});
|
||||
// Stream the download progress
|
||||
if (progressDownload) {
|
||||
xhr.io?.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
progressDownload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
// Stream the download progress
|
||||
if (progressDownload) {
|
||||
xhr.io.addEventListener("progress", (dataEvent) => {
|
||||
if (dataEvent.lengthComputable) {
|
||||
//console.log(` ==> download progress:: ${dataEvent.loaded} / ${dataEvent.total}`);
|
||||
progressUpload(dataEvent.loaded, dataEvent.total);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if (abortHandle) {
|
||||
abortHandle.abort = () => {
|
||||
if (xhr.io) {
|
||||
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||
xhr.io.abort();
|
||||
return true;
|
||||
}
|
||||
if (abortHandle) {
|
||||
abortHandle.abort = () => {
|
||||
if (xhr.io) {
|
||||
console.log(`Request abort on the XMLHttpRequest: ${generateUrl}`);
|
||||
xhr.io.abort();
|
||||
return true;
|
||||
}
|
||||
console.log(`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check if we have an internal Fail:
|
||||
xhr.io.addEventListener('error', () => {
|
||||
xhr.io = undefined;
|
||||
reject(new TypeError('Failed to fetch'))
|
||||
});
|
||||
|
||||
// Capture the end of the stream
|
||||
xhr.io.addEventListener("loadend", () => {
|
||||
if (xhr.io.readyState !== XMLHttpRequest.DONE) {
|
||||
//console.log(` ==> READY state`);
|
||||
return;
|
||||
}
|
||||
if (xhr.io.status === 0) {
|
||||
//the stream has been aborted
|
||||
reject(new TypeError('Fetch has been aborted'));
|
||||
return;
|
||||
}
|
||||
// Stream is ended, transform in a generic response:
|
||||
const response = new Response(xhr.io.response, {
|
||||
status: xhr.io.status,
|
||||
statusText: xhr.io.statusText
|
||||
});
|
||||
const headersArray = replaceAll(xhr.io.getAllResponseHeaders().trim(), "\r\n", "\n").split('\n');
|
||||
headersArray.forEach(function (header) {
|
||||
const firstColonIndex = header.indexOf(':');
|
||||
if (firstColonIndex !== -1) {
|
||||
var key = header.substring(0, firstColonIndex).trim();
|
||||
var value = header.substring(firstColonIndex + 1).trim();
|
||||
response.headers.set(key, value);
|
||||
} else {
|
||||
response.headers.set(header, "");
|
||||
}
|
||||
});
|
||||
xhr.io = undefined;
|
||||
resolve(response);
|
||||
});
|
||||
xhr.io.open(method, generateUrl, true);
|
||||
if (!isNullOrUndefined(headers)) {
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
xhr.io.setRequestHeader(key, value as string);
|
||||
}
|
||||
}
|
||||
xhr.io.send(body);
|
||||
console.log(
|
||||
`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`
|
||||
);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// Check if we have an internal Fail:
|
||||
xhr.io?.addEventListener("error", () => {
|
||||
xhr.io = undefined;
|
||||
reject(new TypeError("Failed to fetch"));
|
||||
});
|
||||
|
||||
// Capture the end of the stream
|
||||
xhr.io?.addEventListener("loadend", () => {
|
||||
if (xhr.io?.readyState !== XMLHttpRequest.DONE) {
|
||||
return;
|
||||
}
|
||||
if (xhr.io?.status === 0) {
|
||||
//the stream has been aborted
|
||||
reject(new TypeError("Fetch has been aborted"));
|
||||
return;
|
||||
}
|
||||
// Stream is ended, transform in a generic response:
|
||||
const response = new Response(xhr.io.response, {
|
||||
status: xhr.io.status,
|
||||
statusText: xhr.io.statusText,
|
||||
});
|
||||
const headersArray = replaceAll(
|
||||
xhr.io.getAllResponseHeaders().trim(),
|
||||
"\r\n",
|
||||
"\n"
|
||||
).split("\n");
|
||||
headersArray.forEach(function (header) {
|
||||
const firstColonIndex = header.indexOf(":");
|
||||
if (firstColonIndex !== -1) {
|
||||
const key = header.substring(0, firstColonIndex).trim();
|
||||
const value = header.substring(firstColonIndex + 1).trim();
|
||||
response.headers.set(key, value);
|
||||
} else {
|
||||
response.headers.set(header, "");
|
||||
}
|
||||
});
|
||||
xhr.io = undefined;
|
||||
resolve(response);
|
||||
});
|
||||
xhr.io?.open(method, generateUrl, true);
|
||||
if (!isNullOrUndefined(headers)) {
|
||||
for (const [key, value] of Object.entries(headers)) {
|
||||
xhr.io?.setRequestHeader(key, value as string);
|
||||
}
|
||||
}
|
||||
xhr.io?.send(body);
|
||||
});
|
||||
}
|
||||
|
||||
export function RESTRequest({ restModel, restConfig, data, params, queries, callback }: RESTRequestType): Promise<ModelResponseHttp> {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||
let headers: any = {};
|
||||
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
||||
headers['Authorization'] = `Bearer ${restConfig.token}`;
|
||||
export function RESTRequest({
|
||||
restModel,
|
||||
restConfig,
|
||||
data,
|
||||
params,
|
||||
queries,
|
||||
callback,
|
||||
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||
// Create the URL PATH:
|
||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||
let headers: any = {};
|
||||
if (restConfig.token !== undefined && restModel.tokenInUrl !== true) {
|
||||
headers["Authorization"] = `Bearer ${restConfig.token}`;
|
||||
}
|
||||
if (restModel.accept !== undefined) {
|
||||
headers["Accept"] = restModel.accept;
|
||||
}
|
||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||
// if Get we have not a content type, the body is empty
|
||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||
headers["Content-Type"] = restModel.contentType;
|
||||
}
|
||||
if (restModel.accept !== undefined) {
|
||||
headers['Accept'] = restModel.accept;
|
||||
}
|
||||
let body = data;
|
||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||
body = JSON.stringify(data);
|
||||
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||
const formData = new FormData();
|
||||
for (const name in data) {
|
||||
formData.append(name, data[name]);
|
||||
}
|
||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
||||
// if Get we have not a content type, the body is empty
|
||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||
headers['Content-Type'] = restModel.contentType;
|
||||
}
|
||||
body = formData;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let action: undefined | Promise<Response> = undefined;
|
||||
if (
|
||||
isNullOrUndefined(callback) ||
|
||||
(isNullOrUndefined(callback.progressDownload) &&
|
||||
isNullOrUndefined(callback.progressUpload) &&
|
||||
isNullOrUndefined(callback.abortHandle))
|
||||
) {
|
||||
// No information needed: call the generic fetch interface
|
||||
action = fetch(generateUrl, {
|
||||
method: restModel.requestType,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
} else {
|
||||
// need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
|
||||
action = fetchProgress(
|
||||
generateUrl,
|
||||
{
|
||||
method: restModel.requestType ?? HTTPRequestModel.GET,
|
||||
headers,
|
||||
body,
|
||||
},
|
||||
callback
|
||||
);
|
||||
}
|
||||
let body = data;
|
||||
if (restModel.contentType === HTTPMimeType.JSON) {
|
||||
body = JSON.stringify(data);
|
||||
} else if (restModel.contentType === HTTPMimeType.MULTIPART) {
|
||||
const formData = new FormData();
|
||||
for (const name in data) {
|
||||
formData.append(name, data[name]);
|
||||
}
|
||||
body = formData
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
let action: undefined | Promise<Response> = undefined;
|
||||
if (isNullOrUndefined(callback)
|
||||
|| (isNullOrUndefined(callback.progressDownload)
|
||||
&& isNullOrUndefined(callback.progressUpload)
|
||||
&& isNullOrUndefined(callback.abortHandle))) {
|
||||
// No information needed: call the generic fetch interface
|
||||
action = fetch(generateUrl, {
|
||||
method: restModel.requestType,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
} else {
|
||||
// need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
|
||||
action = fetchProgress(generateUrl, {
|
||||
method: restModel.requestType ?? HTTPRequestModel.GET,
|
||||
headers,
|
||||
body,
|
||||
}, callback);
|
||||
}
|
||||
action.then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
const contentType = response.headers.get('Content-Type');
|
||||
if (!isNullOrUndefined(restModel.accept) && restModel.accept !== contentType) {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 901,
|
||||
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
|
||||
statusMessage: "Fetch error",
|
||||
message: "rest-tools.ts Wrong type in the message return type"
|
||||
} as RestErrorResponse);
|
||||
} else if (contentType === HTTPMimeType.JSON) {
|
||||
response
|
||||
.json()
|
||||
.then((value: any) => {
|
||||
//console.log(`RECEIVE ==> ${response.status}=${ JSON.stringify(value, null, 2)}`);
|
||||
resolve({ status: response.status, data: value });
|
||||
})
|
||||
.catch((reason: any) => {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 902,
|
||||
error: `REST parse json fail: ${reason}`,
|
||||
statusMessage: "Fetch parse error",
|
||||
message: "rest-tools.ts Wrong message model to parse"
|
||||
} as RestErrorResponse);
|
||||
});
|
||||
} else {
|
||||
resolve({ status: response.status, data: response.body });
|
||||
}
|
||||
} else {
|
||||
action
|
||||
.then((response: Response) => {
|
||||
if (response.status >= 200 && response.status <= 299) {
|
||||
const contentType = response.headers.get("Content-Type");
|
||||
if (
|
||||
!isNullOrUndefined(restModel.accept) &&
|
||||
restModel.accept !== contentType
|
||||
) {
|
||||
reject({
|
||||
name: "Model accept type incompatible",
|
||||
time: Date().toString(),
|
||||
status: 901,
|
||||
message: `REST Content type are not compatible: ${restModel.accept} != ${contentType}`,
|
||||
statusMessage: "Fetch error",
|
||||
error: "rest-tools.ts Wrong type in the message return type",
|
||||
} as RestErrorResponse);
|
||||
} else if (contentType === HTTPMimeType.JSON) {
|
||||
response
|
||||
.json()
|
||||
.then((value: any) => {
|
||||
resolve({ status: response.status, data: value });
|
||||
})
|
||||
.catch((reason: Error) => {
|
||||
reject({
|
||||
name: "API serialization error",
|
||||
time: Date().toString(),
|
||||
status: 902,
|
||||
message: `REST parse json fail: ${reason}`,
|
||||
statusMessage: "Fetch parse error",
|
||||
error: "rest-tools.ts Wrong message model to parse",
|
||||
} as RestErrorResponse);
|
||||
});
|
||||
} else {
|
||||
resolve({ status: response.status, data: response.body });
|
||||
}
|
||||
} else {
|
||||
// the answer is not correct not a 2XX
|
||||
// clone the response to keep the raw data if case of error:
|
||||
response
|
||||
.clone()
|
||||
.json()
|
||||
.then((value: any) => {
|
||||
if (isRestErrorResponse(value)) {
|
||||
reject(value);
|
||||
} else {
|
||||
response
|
||||
.text()
|
||||
.then((dataError: string) => {
|
||||
reject({
|
||||
name: "API serialization error",
|
||||
time: Date().toString(),
|
||||
status: 903,
|
||||
message: `REST parse error json with wrong type fail. ${dataError}`,
|
||||
statusMessage: "Fetch parse error",
|
||||
error: "rest-tools.ts Wrong message model to parse",
|
||||
} as RestErrorResponse);
|
||||
})
|
||||
.catch((reason: any) => {
|
||||
reject({
|
||||
name: "API serialization error",
|
||||
time: Date().toString(),
|
||||
status: response.status,
|
||||
message: `unmanaged error model: ??? with error: ${reason}`,
|
||||
statusMessage: "Fetch ERROR parse error",
|
||||
error: "rest-tools.ts Wrong message model to parse",
|
||||
} as RestErrorResponse);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((reason: Error) => {
|
||||
response
|
||||
.text()
|
||||
.then((dataError: string) => {
|
||||
reject({
|
||||
name: "API serialization error",
|
||||
time: Date().toString(),
|
||||
status: response.status,
|
||||
error: `${response.body}`,
|
||||
statusMessage: "Fetch code error",
|
||||
message: "rest-tools.ts Wrong return code"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((error: any) => {
|
||||
reject({
|
||||
time: Date(),
|
||||
status: 999,
|
||||
error: error,
|
||||
statusMessage: "Fetch catch error",
|
||||
message: "rest-tools.ts detect an error in the fetch request"
|
||||
message: `unmanaged error model: ${dataError} with error: ${reason}`,
|
||||
statusMessage: "Fetch ERROR TEXT parse error",
|
||||
error: "rest-tools.ts Wrong message model to parse",
|
||||
} as RestErrorResponse);
|
||||
})
|
||||
.catch((reason: any) => {
|
||||
reject({
|
||||
name: "API serialization error",
|
||||
time: Date().toString(),
|
||||
status: response.status,
|
||||
message: `unmanaged error model: ??? with error: ${reason}`,
|
||||
statusMessage: "Fetch ERROR TEXT FAIL",
|
||||
error: "rest-tools.ts Wrong message model to parse",
|
||||
} as RestErrorResponse);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
if (isRestErrorResponse(error)) {
|
||||
reject(error);
|
||||
} else {
|
||||
reject({
|
||||
name: "Request fail",
|
||||
time: Date(),
|
||||
status: 999,
|
||||
message: error,
|
||||
statusMessage: "Fetch catch error",
|
||||
error: "rest-tools.ts detect an error in the fetch request",
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
if (isNullOrUndefined(checker)) {
|
||||
console.log(`Have no check of MODEL in API: ${RESTUrl(request)}`);
|
||||
resolve(value.data);
|
||||
} else if (checker(value.data)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 950,
|
||||
error: "REST Fail to verify the data",
|
||||
statusMessage: "API cast ERROR",
|
||||
message: "api.ts Check type as fail"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
if (isArrayOf(value.data, checker)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
reject({
|
||||
time: Date().toString(),
|
||||
status: 950,
|
||||
error: "REST Fail to verify the data",
|
||||
statusMessage: "API cast ERROR",
|
||||
message: "api.ts Check type as fail"
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
export function RESTRequestJson<TYPE>(
|
||||
request: RESTRequestType,
|
||||
checker?: (data: any) => data is TYPE
|
||||
): Promise<TYPE> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request)
|
||||
.then((value: ModelResponseHttp) => {
|
||||
if (isNullOrUndefined(checker)) {
|
||||
console.log(`Have no check of MODEL in API: ${RESTUrl(request)}`);
|
||||
resolve(value.data);
|
||||
} else if (checker === undefined || checker(value.data)) {
|
||||
resolve(value.data);
|
||||
} else {
|
||||
reject({
|
||||
name: "Model check fail",
|
||||
time: Date().toString(),
|
||||
status: 950,
|
||||
error: "REST Fail to verify the data",
|
||||
statusMessage: "API cast ERROR",
|
||||
message: "api.ts Check type as fail",
|
||||
} as RestErrorResponse);
|
||||
}
|
||||
})
|
||||
.catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request).then((value: ModelResponseHttp) => {
|
||||
resolve();
|
||||
}).catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
return new Promise((resolve, reject) => {
|
||||
RESTRequest(request)
|
||||
.then((value: ModelResponseHttp) => {
|
||||
resolve();
|
||||
})
|
||||
.catch((reason: RestErrorResponse) => {
|
||||
reject(reason);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
updateButtonDisabled: number | undefined = undefined;
|
||||
dataUpdate: object = {}
|
||||
dataUpdate: { [key: string]: object; } = {}
|
||||
|
||||
onEditState(value: number) {
|
||||
console.log(`changeState : ${JSON.stringify(value, null, 2)}`);
|
||||
@ -147,7 +147,7 @@ export class applicationUserRightEditScene implements OnInit {
|
||||
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
onEditValues(value: any) {
|
||||
onEditValues(value: { [key: string]: object; }) {
|
||||
console.log(`onDeltaValues : ${JSON.stringify(value, null, 2)}`);
|
||||
this.dataUpdate = value;
|
||||
// we do not change the main ref ==> notify angular that something have change and need to be re-render???
|
||||
|
@ -219,7 +219,7 @@ export class AdminUserService {
|
||||
});
|
||||
}
|
||||
|
||||
updateApplicationRights(userId: number, applicationId: number, dataUpdate: object): Promise<any> {
|
||||
updateApplicationRights(userId: number, applicationId: number, dataUpdate: { [key: string]: object; }): Promise<any> {
|
||||
return UserResource.patchApplicationRight({
|
||||
restConfig: this.getRestConfig(),
|
||||
params: {
|
||||
|
@ -2,12 +2,15 @@
|
||||
.xdesktop {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.xtablette {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xphone {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xmobile {
|
||||
display: none;
|
||||
}
|
||||
@ -17,12 +20,15 @@
|
||||
.xdesktop {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xtablette {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.xphone {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xmobile {
|
||||
display: block;
|
||||
}
|
||||
@ -32,12 +38,15 @@
|
||||
.xdesktop {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xtablette {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.xphone {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.xmobile {
|
||||
display: block;
|
||||
}
|
||||
@ -206,6 +215,7 @@ html {
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.square-button {
|
||||
// background: #b3d4fc;
|
||||
text-shadow: none;
|
||||
@ -264,12 +274,15 @@ html {
|
||||
text-align: center;
|
||||
line-height: 36px;
|
||||
vertical-align: middle;
|
||||
|
||||
&:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
background: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -302,6 +315,7 @@ label {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
|
||||
.full-back {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
@ -312,12 +326,9 @@ label {
|
||||
|
||||
background-image: url('assets/images/ikon_red.svg');
|
||||
background-repeat: no-repeat;
|
||||
/*
|
||||
background-size: contain;
|
||||
*/
|
||||
background-size: 80%;
|
||||
background-attachment: fixed;
|
||||
background-position: 50% 50%;
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
0.6.0
|
||||
0.8.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user