[DEV] update new model generation of Typescript

This commit is contained in:
Edouard DUPIN 2024-05-29 00:04:24 +02:00
parent 4d1ae6f795
commit ad26736b80
64 changed files with 3100 additions and 1938 deletions

View File

@ -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>

View File

@ -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

View File

@ -20,7 +20,7 @@
<dependency>
<groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId>
<version>0.8.9</version>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>

View File

@ -36,6 +36,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 +80,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]");

View File

@ -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:");

View File

@ -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);
}
////////////////////////////////////////////////////////////////////////////////////////

View File

@ -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)));

View File

@ -0,0 +1,69 @@
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() throws Exception {
// 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("data"));
}
});
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`
ADD `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Deleted state' AFTER `uuid`;
""");
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`;
""");
}
}

View 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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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() {}

View File

@ -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,

View File

@ -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;
}

View File

@ -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")

View File

@ -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.0",
"@angular/cdk": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@angular/material": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"rxjs": "^7.8.1",
"zone.js": "^0.14.5",
"zone.js": "^0.14.6",
"zod": "3.23.8",
"@kangaroo-and-rabbit/kar-cw": "^0.3.0"
"@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.1",
"@angular-eslint/builder": "17.5.2",
"@angular-eslint/eslint-plugin": "17.5.2",
"@angular-eslint/eslint-plugin-template": "17.5.2",
"@angular-eslint/schematics": "17.5.2",
"@angular-eslint/template-parser": "17.5.2",
"@angular/cli": "^18.0.1",
"@angular/compiler-cli": "^18.0.0",
"@angular/language-service": "^18.0.0",
"@playwright/test": "^1.44.1",
"@types/jest": "^29.5.12",
"jasmine": "^5.1.0",
"jasmine-core": "^5.1.2",

File diff suppressed because it is too large Load Diff

View File

@ -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"
RESTRequestVoid,
} from "../rest-tools";
import { z as zod } from "zod"
import {
AddUserData,
AddUserDataWrite,
Application,
ApplicationSmall,
ApplicationWrite,
ClientToken,
Long,
RightDescription,
ZodApplication,
ZodApplicationSmall,
ZodLong,
ZodRightDescription,
isApplication,
isLong,
isRightDescription,
isApplicationSmall,
isClientToken,
} from "./model"
} 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: {

View File

@ -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"
RESTRequestVoid,
} from "../rest-tools";
import { z as zod } from "zod"
import {
ApplicationToken,
CreateTokenRequest,
CreateTokenRequestWrite,
Integer,
Long,
ZodApplicationToken,
isApplicationToken,
} from "./model"
} 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,

View File

@ -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"
RESTRequestVoid,
} from "../rest-tools";
import {
UUID,
} from "./model"
} 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,

View File

@ -0,0 +1,6 @@
/**
* Interface of the server (auto-generated code)
*/
export namespace Front {
}

View 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"

View File

@ -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"
} from "../rest-tools";
import {
PublicKey,
isPublicKey,
} from "./model"
} 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);
});
};
}

View File

@ -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"
RESTRequestVoid,
} from "../rest-tools";
import { z as zod } from "zod"
import {
Long,
Right,
RightWrite,
ZodRight,
isRight,
} from "./model"
} 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,

View File

@ -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"
RESTRequestVoid,
} from "../rest-tools";
import { z as zod } from "zod"
import {
GetSignUpAvailable,
isGetSignUpAvailable,
} from "./model"
} 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: {

View File

@ -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"
RESTRequestVoid,
} from "../rest-tools";
import { z as zod } from "zod"
import {
ChangePassword,
DataGetToken,
ChangePasswordWrite,
DataGetTokenWrite,
GetToken,
Long,
UserAuth,
UserAuthGet,
UserCreate,
UserCreateWrite,
UserOut,
ZodUserAuthGet,
isGetToken,
isUserAuth,
isUserOut,
isUserAuthGet,
} from "./model"
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,

View File

@ -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 {
}

View File

@ -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";

View File

@ -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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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"

View 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;
}
}

View 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>;

View 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>;

View 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>;

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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>;

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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>;

View File

@ -4,25 +4,25 @@
* @license MPL-2
*/
import { RestErrorResponse } from "./model"
import { RestErrorResponse } 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 {
@ -50,23 +50,6 @@ export interface ModelResponseHttp {
data: any;
}
export function isArrayOf<TYPE>(
data: any,
typeChecker: (subData: any) => subData is TYPE,
length?: number
): data is TYPE[] {
if (!Array.isArray(data)) {
return false;
}
if (!data.every(typeChecker)) {
return false;
}
if (length !== undefined && data.length != length) {
return false;
}
return true;
}
function isNullOrUndefined(data: any): data is undefined | null {
return data === undefined || data === null;
}
@ -75,25 +58,24 @@ function isNullOrUndefined(data: any): data is undefined | null {
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);
@ -103,24 +85,34 @@ function removeTrailingSlashes(input: string): string {
if (isNullOrUndefined(input)) {
return "undefined";
}
return input.replace(/\/+$/, '');
return input.replace(/\/+$/, "");
}
function removeLeadingSlashes(input: string): string {
if (isNullOrUndefined(input)) {
return "";
}
return input.replace(/^\/+/, '');
return input.replace(/^\/+/, "");
}
export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestType): string {
export function RESTUrl({
restModel,
restConfig,
params,
queries,
}: RESTRequestType): string {
// Create the URL PATH:
let generateUrl = `${removeTrailingSlashes(restConfig.server)}/${removeLeadingSlashes(restModel.endPoint)}`;
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)) {
if (
queries === undefined &&
(restConfig.token === undefined || restModel.tokenInUrl !== true)
) {
return generateUrl;
}
const searchParams = new URLSearchParams();
@ -128,8 +120,8 @@ export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestT
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]}`);
for (const element of value) {
searchParams.append(`${key}`, `${element}`);
}
} else {
searchParams.append(`${key}`, `${value}`);
@ -137,36 +129,43 @@ export function RESTUrl({ restModel, restConfig, params, queries }: RESTRequestT
}
}
if (restConfig.token !== undefined && restModel.tokenInUrl === true) {
searchParams.append('Authorization', `Bearer ${restConfig.token}`);
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) => {
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) => {
xhr.io?.addEventListener("progress", (dataEvent) => {
if (dataEvent.lengthComputable) {
//console.log(` ==> download progress:: ${dataEvent.loaded} / ${dataEvent.total}`);
progressUpload(dataEvent.loaded, dataEvent.total);
progressDownload(dataEvent.loaded, dataEvent.total);
}
});
}
@ -177,38 +176,43 @@ export function fetchProgress(generateUrl: string, { method, headers, body }: {
xhr.io.abort();
return true;
}
console.log(`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`);
console.log(
`Request abort (FAIL) on the XMLHttpRequest: ${generateUrl}`
);
return false;
}
};
}
// Check if we have an internal Fail:
xhr.io.addEventListener('error', () => {
xhr.io?.addEventListener("error", () => {
xhr.io = undefined;
reject(new TypeError('Failed to fetch'))
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`);
xhr.io?.addEventListener("loadend", () => {
if (xhr.io?.readyState !== XMLHttpRequest.DONE) {
return;
}
if (xhr.io.status === 0) {
if (xhr.io?.status === 0) {
//the stream has been aborted
reject(new TypeError('Fetch 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
statusText: xhr.io.statusText,
});
const headersArray = replaceAll(xhr.io.getAllResponseHeaders().trim(), "\r\n", "\n").split('\n');
const headersArray = replaceAll(
xhr.io.getAllResponseHeaders().trim(),
"\r\n",
"\n"
).split("\n");
headersArray.forEach(function (header) {
const firstColonIndex = header.indexOf(':');
const firstColonIndex = header.indexOf(":");
if (firstColonIndex !== -1) {
var key = header.substring(0, firstColonIndex).trim();
var value = header.substring(firstColonIndex + 1).trim();
const key = header.substring(0, firstColonIndex).trim();
const value = header.substring(firstColonIndex + 1).trim();
response.headers.set(key, value);
} else {
response.headers.set(header, "");
@ -217,31 +221,38 @@ export function fetchProgress(generateUrl: string, { method, headers, body }: {
xhr.io = undefined;
resolve(response);
});
xhr.io.open(method, generateUrl, true);
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?.setRequestHeader(key, value as string);
}
}
xhr.io.send(body);
xhr.io?.send(body);
});
}
export function RESTRequest({ restModel, restConfig, data, params, queries, callback }: RESTRequestType): Promise<ModelResponseHttp> {
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}`;
headers["Authorization"] = `Bearer ${restConfig.token}`;
}
if (restModel.accept !== undefined) {
headers['Accept'] = restModel.accept;
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;
headers["Content-Type"] = restModel.contentType;
}
}
let body = data;
@ -252,14 +263,16 @@ export function RESTRequest({ restModel, restConfig, data, params, queries, call
for (const name in data) {
formData.append(name, data[name]);
}
body = formData
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))) {
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,
@ -268,37 +281,46 @@ export function RESTRequest({ restModel, restConfig, data, params, queries, call
});
} else {
// need progression information: call old fetch model (XMLHttpRequest) that permit to keep % upload and % download for HTTP1.x
action = fetchProgress(generateUrl, {
action = fetchProgress(
generateUrl,
{
method: restModel.requestType ?? HTTPRequestModel.GET,
headers,
body,
}, callback);
},
callback
);
}
action.then((response: Response) => {
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) {
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,
error: `REST check wrong type: ${restModel.accept} != ${contentType}`,
statusMessage: "Fetch error",
message: "rest-tools.ts Wrong type in the message return type"
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({
name: "API serialization error",
time: Date().toString(),
status: 902,
error: `REST parse json fail: ${reason}`,
statusMessage: "Fetch parse error",
message: "rest-tools.ts Wrong message model to parse"
message: "rest-tools.ts Wrong message model to parse",
} as RestErrorResponse);
});
} else {
@ -306,64 +328,52 @@ export function RESTRequest({ restModel, restConfig, data, params, queries, call
}
} else {
reject({
name: "REST return no OK status",
time: Date().toString(),
status: response.status,
error: `${response.body}`,
statusMessage: "Fetch code error",
message: "rest-tools.ts Wrong return code"
message: "rest-tools.ts Wrong return code",
} as RestErrorResponse);
}
}).catch((error: any) => {
})
.catch((error: any) => {
reject({
name: "Request fail",
time: Date(),
status: 999,
error: error,
statusMessage: "Fetch catch error",
message: "rest-tools.ts detect an error in the fetch request"
message: "rest-tools.ts detect an error in the fetch request",
});
});
});
}
export function RESTRequestJson<TYPE>(request: RESTRequestType, checker: (data: any) => data is TYPE): Promise<TYPE> {
export function RESTRequestJson<TYPE>(
request: RESTRequestType,
checker?: (data: any) => data is TYPE
): Promise<TYPE> {
return new Promise((resolve, reject) => {
RESTRequest(request).then((value: ModelResponseHttp) => {
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)) {
} 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"
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) => {
})
.catch((reason: RestErrorResponse) => {
reject(reason);
});
});
@ -371,9 +381,11 @@ export function RESTRequestJsonArray<TYPE>(request: RESTRequestType, checker: (d
export function RESTRequestVoid(request: RESTRequestType): Promise<void> {
return new Promise((resolve, reject) => {
RESTRequest(request).then((value: ModelResponseHttp) => {
RESTRequest(request)
.then((value: ModelResponseHttp) => {
resolve();
}).catch((reason: RestErrorResponse) => {
})
.catch((reason: RestErrorResponse) => {
reject(reason);
});
});

View File

@ -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???

View File

@ -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: {