[FEAT] update back with new archidata
This commit is contained in:
parent
396455d611
commit
83e019c8fa
@ -290,11 +290,15 @@ public class ApplicationResource {
|
|||||||
// If the USER is not override, the system add by default USER
|
// If the USER is not override, the system add by default USER
|
||||||
applicationRight.put("USER", PartRight.READ_WRITE);
|
applicationRight.put("USER", PartRight.READ_WRITE);
|
||||||
}
|
}
|
||||||
|
final Map<String, Integer> rightForFront = new HashMap<>();
|
||||||
|
for (final Map.Entry<String, PartRight> entry : applicationRight.entrySet()) {
|
||||||
|
rightForFront.put(entry.getKey(), entry.getValue().getValue());
|
||||||
|
}
|
||||||
final Map<String, Object> outRight = new HashMap<>();
|
final Map<String, Object> outRight = new HashMap<>();
|
||||||
// we set the right in the under map to manage multiple application group right.
|
// we set the right in the under map to manage multiple application group right.
|
||||||
// and in some application user can see other user or all user of the
|
// and in some application user can see other user or all user of the
|
||||||
// application
|
// application
|
||||||
outRight.put(applicationName, applicationRight);
|
outRight.put(applicationName, rightForFront);
|
||||||
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth",
|
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth",
|
||||||
applicationName, outRight, -appl.ttl);
|
applicationName, outRight, -appl.ttl);
|
||||||
// logger.debug(" ==> generate token: {}", ret);
|
// logger.debug(" ==> generate token: {}", ret);
|
||||||
|
@ -82,25 +82,26 @@ public class UserResource {
|
|||||||
|
|
||||||
@GET
|
@GET
|
||||||
@RolesAllowed("ADMIN")
|
@RolesAllowed("ADMIN")
|
||||||
public List<UserAuth> gets() throws Exception {
|
public List<UserAuthGet> gets() throws Exception {
|
||||||
return DataAccess.gets(UserAuth.class);
|
final List<UserAuthGet> out = DataAccess.gets(UserAuthGet.class);
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{id}")
|
@Path("{id}")
|
||||||
@RolesAllowed({ "ADMIN", "USER" })
|
@RolesAllowed({ "ADMIN", "USER" })
|
||||||
public UserAuth get(@Context final SecurityContext sc, @PathParam("id") final long id) throws Exception {
|
public UserAuthGet get(@Context final SecurityContext sc, @PathParam("id") final long id) throws Exception {
|
||||||
if (!sc.isUserInRole("ADMIN")) {
|
if (!sc.isUserInRole("ADMIN")) {
|
||||||
// in case of user we need to check if it get his own id parameters:
|
// in case of user we need to check if it get his own id parameters:
|
||||||
final UserAuth ret = DataAccess.get(UserAuth.class, id, new AccessDeletedItems());
|
final UserAuthGet ret = DataAccess.get(UserAuthGet.class, id, new AccessDeletedItems());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
final UserAuth ret = DataAccess.get(UserAuth.class, id);
|
final UserAuthGet ret = DataAccess.get(UserAuthGet.class, id);
|
||||||
if (ret != null) {
|
if (ret != null) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// Find element in deleted
|
// Find element in deleted
|
||||||
return DataAccess.get(UserAuth.class, id, new AccessDeletedItems(), new ReadAllColumn());
|
return DataAccess.get(UserAuthGet.class, id, new AccessDeletedItems(), new ReadAllColumn());
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -329,10 +330,14 @@ public class UserResource {
|
|||||||
// If the USER is not override, the system add by default USER
|
// If the USER is not override, the system add by default USER
|
||||||
ssoRight.put("USER", PartRight.READ_WRITE);
|
ssoRight.put("USER", PartRight.READ_WRITE);
|
||||||
}
|
}
|
||||||
|
final Map<String, Integer> rightForFront = new HashMap<>();
|
||||||
|
for (final Map.Entry<String, PartRight> entry : ssoRight.entrySet()) {
|
||||||
|
rightForFront.put(entry.getKey(), entry.getValue().getValue());
|
||||||
|
}
|
||||||
LOGGER.debug("Get new token with right: {}", ssoRight);
|
LOGGER.debug("Get new token with right: {}", ssoRight);
|
||||||
final Map<String, Object> outRight = new HashMap<>();
|
final Map<String, Object> outRight = new HashMap<>();
|
||||||
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application
|
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application
|
||||||
outRight.put(UserResource.APPLICATION, ssoRight);
|
outRight.put(UserResource.APPLICATION, rightForFront);
|
||||||
// TODO: maybe correct this get of TTL...
|
// TODO: maybe correct this get of TTL...
|
||||||
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", UserResource.APPLICATION,
|
final String ret = JWTWrapper.generateJWToken(user.id, user.login, "KarAuth", UserResource.APPLICATION,
|
||||||
outRight, expirationTimeInMinutes);
|
outRight, expirationTimeInMinutes);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.kar.karso.model;
|
package org.kar.karso.model;
|
||||||
|
|
||||||
import org.kar.archidata.annotation.DataIfNotExists;
|
import org.kar.archidata.annotation.DataIfNotExists;
|
||||||
|
import org.kar.archidata.annotation.DataJson;
|
||||||
import org.kar.archidata.filter.PartRight;
|
import org.kar.archidata.filter.PartRight;
|
||||||
import org.kar.archidata.model.GenericDataSoftDelete;
|
import org.kar.archidata.model.GenericDataSoftDelete;
|
||||||
|
|
||||||
@ -30,5 +31,6 @@ public class Right extends GenericDataSoftDelete {
|
|||||||
public Long rightDescriptionId;
|
public Long rightDescriptionId;
|
||||||
@Column(length = 1024, nullable = false)
|
@Column(length = 1024, nullable = false)
|
||||||
@Schema(description = "Value of the right")
|
@Schema(description = "Value of the right")
|
||||||
|
@DataJson
|
||||||
public PartRight value;
|
public PartRight value;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import org.kar.archidata.model.User;
|
|||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
@ -24,6 +25,7 @@ public class UserAuth extends User {
|
|||||||
@Column(length = 128, nullable = false)
|
@Column(length = 128, nullable = false)
|
||||||
@Size(min = 128, max = 128)
|
@Size(min = 128, max = 128)
|
||||||
@Pattern(regexp = "^[a-zA-Z0-9]{128}$")
|
@Pattern(regexp = "^[a-zA-Z0-9]{128}$")
|
||||||
|
@Nullable
|
||||||
public String password;
|
public String password;
|
||||||
/*
|
/*
|
||||||
@Column(length = 128)
|
@Column(length = 128)
|
||||||
|
@ -16,7 +16,7 @@ import org.kar.archidata.model.GetToken;
|
|||||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||||
import org.kar.archidata.tools.RESTApi;
|
import org.kar.archidata.tools.RESTApi;
|
||||||
import org.kar.karso.model.DataGetToken;
|
import org.kar.karso.model.DataGetToken;
|
||||||
import org.kar.karso.model.UserAuth;
|
import org.kar.karso.model.UserAuthGet;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ public class TestUsers {
|
|||||||
@Order(1)
|
@Order(1)
|
||||||
@Test
|
@Test
|
||||||
public void getsValue() throws RESTErrorResponseException, IOException, InterruptedException {
|
public void getsValue() throws RESTErrorResponseException, IOException, InterruptedException {
|
||||||
final List<UserAuth> listUsers = api.gets(UserAuth.class, TestUsers.ENDPOINT_NAME);
|
final List<UserAuthGet> listUsers = api.gets(UserAuthGet.class, TestUsers.ENDPOINT_NAME);
|
||||||
Assertions.assertNotNull(listUsers);
|
Assertions.assertNotNull(listUsers);
|
||||||
Assertions.assertEquals(1, listUsers.size());
|
Assertions.assertEquals(1, listUsers.size());
|
||||||
Assertions.assertEquals(1, listUsers.get(0).id);
|
Assertions.assertEquals(1, listUsers.get(0).id);
|
||||||
|
@ -10,7 +10,7 @@ import {
|
|||||||
} from "../rest-tools";
|
} from "../rest-tools";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
UUID,
|
ObjectId,
|
||||||
} from "../model";
|
} from "../model";
|
||||||
|
|
||||||
export namespace DataResource {
|
export namespace DataResource {
|
||||||
@ -30,13 +30,13 @@ export namespace DataResource {
|
|||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
name: string,
|
name: string,
|
||||||
uuid: UUID,
|
oid: ObjectId,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{uuid}/{name}",
|
endPoint: "/data/{oid}/{name}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -59,13 +59,13 @@ export namespace DataResource {
|
|||||||
Authorization?: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
uuid: UUID,
|
oid: ObjectId,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/{uuid}",
|
endPoint: "/data/{oid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -88,13 +88,13 @@ export namespace DataResource {
|
|||||||
Authorization?: string,
|
Authorization?: string,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
uuid: UUID,
|
oid: ObjectId,
|
||||||
},
|
},
|
||||||
data: string,
|
data: string,
|
||||||
}): Promise<object> {
|
}): Promise<object> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/data/thumbnail/{uuid}",
|
endPoint: "/data/thumbnail/{oid}",
|
||||||
requestType: HTTPRequestModel.GET,
|
requestType: HTTPRequestModel.GET,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
|
@ -15,10 +15,12 @@ import {
|
|||||||
DataGetTokenWrite,
|
DataGetTokenWrite,
|
||||||
GetToken,
|
GetToken,
|
||||||
Long,
|
Long,
|
||||||
|
PartRight,
|
||||||
UserAuth,
|
UserAuth,
|
||||||
UserAuthGet,
|
UserAuthGet,
|
||||||
UserCreateWrite,
|
UserCreateWrite,
|
||||||
UserOut,
|
UserOut,
|
||||||
|
ZodPartRight,
|
||||||
ZodUserAuthGet,
|
ZodUserAuthGet,
|
||||||
isGetToken,
|
isGetToken,
|
||||||
isUserAuth,
|
isUserAuth,
|
||||||
@ -63,8 +65,27 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}, isUserAuthGet);
|
}, isUserAuthGet);
|
||||||
};
|
};
|
||||||
|
export function get({
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}: {
|
||||||
|
restConfig: RESTConfig,
|
||||||
|
params: {
|
||||||
|
id: Long,
|
||||||
|
},
|
||||||
|
}): Promise<UserAuthGet> {
|
||||||
|
return RESTRequestJson({
|
||||||
|
restModel: {
|
||||||
|
endPoint: "/users/{id}",
|
||||||
|
requestType: HTTPRequestModel.GET,
|
||||||
|
accept: HTTPMimeType.JSON,
|
||||||
|
},
|
||||||
|
restConfig,
|
||||||
|
params,
|
||||||
|
}, isUserAuthGet);
|
||||||
|
};
|
||||||
|
|
||||||
export const ZodGetApplicationRightTypeReturn = zod.record(zod.string(), zod.any());
|
export const ZodGetApplicationRightTypeReturn = zod.record(zod.string(), ZodPartRight);
|
||||||
export type GetApplicationRightTypeReturn = zod.infer<typeof ZodGetApplicationRightTypeReturn>;
|
export type GetApplicationRightTypeReturn = zod.infer<typeof ZodGetApplicationRightTypeReturn>;
|
||||||
|
|
||||||
export function isGetApplicationRightTypeReturn(data: any): data is GetApplicationRightTypeReturn {
|
export function isGetApplicationRightTypeReturn(data: any): data is GetApplicationRightTypeReturn {
|
||||||
@ -129,44 +150,25 @@ export namespace UserResource {
|
|||||||
data,
|
data,
|
||||||
}, isGetToken);
|
}, isGetToken);
|
||||||
};
|
};
|
||||||
export function getUser({
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}: {
|
|
||||||
restConfig: RESTConfig,
|
|
||||||
params: {
|
|
||||||
id: Long,
|
|
||||||
},
|
|
||||||
}): Promise<UserAuthGet> {
|
|
||||||
return RESTRequestJson({
|
|
||||||
restModel: {
|
|
||||||
endPoint: "/users/{id}",
|
|
||||||
requestType: HTTPRequestModel.GET,
|
|
||||||
accept: HTTPMimeType.JSON,
|
|
||||||
},
|
|
||||||
restConfig,
|
|
||||||
params,
|
|
||||||
}, isUserAuthGet);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ZodGetUsersTypeReturn = zod.array(ZodUserAuthGet);
|
export const ZodGetsTypeReturn = zod.array(ZodUserAuthGet);
|
||||||
export type GetUsersTypeReturn = zod.infer<typeof ZodGetUsersTypeReturn>;
|
export type GetsTypeReturn = zod.infer<typeof ZodGetsTypeReturn>;
|
||||||
|
|
||||||
export function isGetUsersTypeReturn(data: any): data is GetUsersTypeReturn {
|
export function isGetsTypeReturn(data: any): data is GetsTypeReturn {
|
||||||
try {
|
try {
|
||||||
ZodGetUsersTypeReturn.parse(data);
|
ZodGetsTypeReturn.parse(data);
|
||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
console.log(`Fail to parse data type='ZodGetUsersTypeReturn' error=${e}`);
|
console.log(`Fail to parse data type='ZodGetsTypeReturn' error=${e}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUsers({
|
export function gets({
|
||||||
restConfig,
|
restConfig,
|
||||||
}: {
|
}: {
|
||||||
restConfig: RESTConfig,
|
restConfig: RESTConfig,
|
||||||
}): Promise<GetUsersTypeReturn> {
|
}): Promise<GetsTypeReturn> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
endPoint: "/users/",
|
endPoint: "/users/",
|
||||||
@ -174,7 +176,7 @@ export namespace UserResource {
|
|||||||
accept: HTTPMimeType.JSON,
|
accept: HTTPMimeType.JSON,
|
||||||
},
|
},
|
||||||
restConfig,
|
restConfig,
|
||||||
}, isGetUsersTypeReturn);
|
}, isGetsTypeReturn);
|
||||||
};
|
};
|
||||||
export function isEmailExist({
|
export function isEmailExist({
|
||||||
restConfig,
|
restConfig,
|
||||||
@ -238,7 +240,7 @@ export namespace UserResource {
|
|||||||
}, isUserAuth);
|
}, isUserAuth);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ZodPatchApplicationRightTypeReturn = zod.record(zod.string(), zod.any());
|
export const ZodPatchApplicationRightTypeReturn = zod.record(zod.string(), ZodPartRight);
|
||||||
export type PatchApplicationRightTypeReturn = zod.infer<typeof ZodPatchApplicationRightTypeReturn>;
|
export type PatchApplicationRightTypeReturn = zod.infer<typeof ZodPatchApplicationRightTypeReturn>;
|
||||||
|
|
||||||
export function isPatchApplicationRightTypeReturn(data: any): data is PatchApplicationRightTypeReturn {
|
export function isPatchApplicationRightTypeReturn(data: any): data is PatchApplicationRightTypeReturn {
|
||||||
@ -261,7 +263,7 @@ export namespace UserResource {
|
|||||||
applicationId: Long,
|
applicationId: Long,
|
||||||
userId: Long,
|
userId: Long,
|
||||||
},
|
},
|
||||||
data: {[key: string]: object;},
|
data: {[key: string]: PartRight;},
|
||||||
}): Promise<PatchApplicationRightTypeReturn> {
|
}): Promise<PatchApplicationRightTypeReturn> {
|
||||||
return RESTRequestJson({
|
return RESTRequestJson({
|
||||||
restModel: {
|
restModel: {
|
||||||
|
@ -21,8 +21,10 @@ export function isAddUserData(data: any): data is AddUserData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodAddUserDataWrite = zod.object({
|
||||||
|
userId: ZodLong.nullable().optional(),
|
||||||
|
|
||||||
export const ZodAddUserDataWrite = ZodAddUserData.partial();
|
});
|
||||||
|
|
||||||
export type AddUserDataWrite = zod.infer<typeof ZodAddUserDataWrite>;
|
export type AddUserDataWrite = zod.infer<typeof ZodAddUserDataWrite>;
|
||||||
|
|
||||||
|
@ -24,8 +24,13 @@ export function isApplicationSmall(data: any): data is ApplicationSmall {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodApplicationSmallWrite = zod.object({
|
||||||
|
id: ZodLong.nullable().optional(),
|
||||||
|
name: zod.string().max(255).nullable().optional(),
|
||||||
|
description: zod.string().max(255).nullable().optional(),
|
||||||
|
redirect: zod.string().max(255).nullable().optional(),
|
||||||
|
|
||||||
export const ZodApplicationSmallWrite = ZodApplicationSmall.partial();
|
});
|
||||||
|
|
||||||
export type ApplicationSmallWrite = zod.infer<typeof ZodApplicationSmallWrite>;
|
export type ApplicationSmallWrite = zod.infer<typeof ZodApplicationSmallWrite>;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodGenericToken} from "./generic-token";
|
import {ZodGenericToken, ZodGenericTokenWrite } from "./generic-token";
|
||||||
|
|
||||||
export const ZodApplicationToken = ZodGenericToken.extend({
|
export const ZodApplicationToken = ZodGenericToken.extend({
|
||||||
|
|
||||||
@ -20,14 +20,9 @@ export function isApplicationToken(data: any): data is ApplicationToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodApplicationTokenWrite = ZodGenericTokenWrite.extend({
|
||||||
|
|
||||||
export const ZodApplicationTokenWrite = ZodApplicationToken.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type ApplicationTokenWrite = zod.infer<typeof ZodApplicationTokenWrite>;
|
export type ApplicationTokenWrite = zod.infer<typeof ZodApplicationTokenWrite>;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodInteger} from "./integer";
|
import {ZodInteger} from "./integer";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
export const ZodApplication = ZodGenericDataSoftDelete.extend({
|
||||||
name: zod.string().max(256).optional(),
|
name: zod.string().max(256).optional(),
|
||||||
@ -34,14 +34,22 @@ export function isApplication(data: any): data is Application {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodApplicationWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
name: zod.string().max(256).nullable().optional(),
|
||||||
|
description: zod.string().max(2048).nullable().optional(),
|
||||||
|
redirect: zod.string().max(2048).optional(),
|
||||||
|
redirectDev: zod.string().max(2048).nullable().optional(),
|
||||||
|
notification: zod.string().max(2048).nullable().optional(),
|
||||||
|
/**
|
||||||
|
* Expiration time
|
||||||
|
*/
|
||||||
|
ttl: ZodInteger.optional(),
|
||||||
|
/**
|
||||||
|
* Right is manage with Karso
|
||||||
|
*/
|
||||||
|
manageRight: zod.boolean().optional(),
|
||||||
|
|
||||||
export const ZodApplicationWrite = ZodApplication.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type ApplicationWrite = zod.infer<typeof ZodApplicationWrite>;
|
export type ApplicationWrite = zod.infer<typeof ZodApplicationWrite>;
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
|
|
||||||
export const ZodChangePassword = zod.object({
|
export const ZodChangePassword = zod.object({
|
||||||
method: zod.string().max(32).optional(),
|
method: zod.string().min(2).max(2),
|
||||||
login: zod.string().max(512).optional(),
|
login: zod.string().min(3).max(128),
|
||||||
time: zod.string().max(64).optional(),
|
time: zod.string().min(20).max(64),
|
||||||
password: zod.string().max(128).optional(),
|
password: zod.string().min(128).max(128),
|
||||||
newPassword: zod.string().max(128).optional(),
|
newPassword: zod.string().min(128).max(128),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,8 +24,14 @@ export function isChangePassword(data: any): data is ChangePassword {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodChangePasswordWrite = zod.object({
|
||||||
|
method: zod.string().min(2).max(2).optional(),
|
||||||
|
login: zod.string().min(3).max(128).optional(),
|
||||||
|
time: zod.string().min(20).max(64).optional(),
|
||||||
|
password: zod.string().min(128).max(128).optional(),
|
||||||
|
newPassword: zod.string().min(128).max(128).optional(),
|
||||||
|
|
||||||
export const ZodChangePasswordWrite = ZodChangePassword.partial();
|
});
|
||||||
|
|
||||||
export type ChangePasswordWrite = zod.infer<typeof ZodChangePasswordWrite>;
|
export type ChangePasswordWrite = zod.infer<typeof ZodChangePasswordWrite>;
|
||||||
|
|
||||||
|
@ -21,8 +21,11 @@ export function isClientToken(data: any): data is ClientToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodClientTokenWrite = zod.object({
|
||||||
|
url: zod.string().max(1024).nullable().optional(),
|
||||||
|
jwt: zod.string().nullable().optional(),
|
||||||
|
|
||||||
export const ZodClientTokenWrite = ZodClientToken.partial();
|
});
|
||||||
|
|
||||||
export type ClientTokenWrite = zod.infer<typeof ZodClientTokenWrite>;
|
export type ClientTokenWrite = zod.infer<typeof ZodClientTokenWrite>;
|
||||||
|
|
||||||
|
@ -22,8 +22,11 @@ export function isCreateTokenRequest(data: any): data is CreateTokenRequest {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodCreateTokenRequestWrite = zod.object({
|
||||||
|
name: zod.string().max(255).nullable().optional(),
|
||||||
|
validity: ZodInteger.nullable().optional(),
|
||||||
|
|
||||||
export const ZodCreateTokenRequestWrite = ZodCreateTokenRequest.partial();
|
});
|
||||||
|
|
||||||
export type CreateTokenRequestWrite = zod.infer<typeof ZodCreateTokenRequestWrite>;
|
export type CreateTokenRequestWrite = zod.infer<typeof ZodCreateTokenRequestWrite>;
|
||||||
|
|
||||||
|
@ -5,6 +5,10 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
|
|
||||||
export const ZodDataGetToken = zod.object({
|
export const ZodDataGetToken = zod.object({
|
||||||
|
login: zod.string().min(3).max(128),
|
||||||
|
method: zod.string().min(2).max(2),
|
||||||
|
time: zod.string().min(20).max(64),
|
||||||
|
password: zod.string().min(128).max(128),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -19,8 +23,13 @@ export function isDataGetToken(data: any): data is DataGetToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodDataGetTokenWrite = zod.object({
|
||||||
|
login: zod.string().min(3).max(128).optional(),
|
||||||
|
method: zod.string().min(2).max(2).optional(),
|
||||||
|
time: zod.string().min(20).max(64).optional(),
|
||||||
|
password: zod.string().min(128).max(128).optional(),
|
||||||
|
|
||||||
export const ZodDataGetTokenWrite = ZodDataGetToken.partial();
|
});
|
||||||
|
|
||||||
export type DataGetTokenWrite = zod.infer<typeof ZodDataGetTokenWrite>;
|
export type DataGetTokenWrite = zod.infer<typeof ZodDataGetTokenWrite>;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodGenericData} from "./generic-data";
|
import {ZodGenericData, ZodGenericDataWrite } from "./generic-data";
|
||||||
|
|
||||||
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
export const ZodGenericDataSoftDelete = ZodGenericData.extend({
|
||||||
/**
|
/**
|
||||||
@ -24,14 +24,9 @@ export function isGenericDataSoftDelete(data: any): data is GenericDataSoftDelet
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataWrite.extend({
|
||||||
|
|
||||||
export const ZodGenericDataSoftDeleteWrite = ZodGenericDataSoftDelete.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
export type GenericDataSoftDeleteWrite = zod.infer<typeof ZodGenericDataSoftDeleteWrite>;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericTiming} from "./generic-timing";
|
import {ZodGenericTiming, ZodGenericTimingWrite } from "./generic-timing";
|
||||||
|
|
||||||
export const ZodGenericData = ZodGenericTiming.extend({
|
export const ZodGenericData = ZodGenericTiming.extend({
|
||||||
/**
|
/**
|
||||||
@ -25,13 +25,9 @@ export function isGenericData(data: any): data is GenericData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericDataWrite = ZodGenericTimingWrite.extend({
|
||||||
|
|
||||||
export const ZodGenericDataWrite = ZodGenericData.omit({
|
});
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
export type GenericDataWrite = zod.infer<typeof ZodGenericDataWrite>;
|
||||||
|
|
||||||
|
@ -28,12 +28,9 @@ export function isGenericTiming(data: any): data is GenericTiming {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericTimingWrite = zod.object({
|
||||||
|
|
||||||
export const ZodGenericTimingWrite = ZodGenericTiming.omit({
|
});
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
export type GenericTimingWrite = zod.infer<typeof ZodGenericTimingWrite>;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodTimestamp} from "./timestamp";
|
import {ZodTimestamp} from "./timestamp";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
export const ZodGenericToken = ZodGenericDataSoftDelete.extend({
|
||||||
parentId: ZodLong,
|
parentId: ZodLong,
|
||||||
@ -26,14 +26,13 @@ export function isGenericToken(data: any): data is GenericToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGenericTokenWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
parentId: ZodLong.optional(),
|
||||||
|
name: zod.string().optional(),
|
||||||
|
endValidityTime: ZodTimestamp.optional(),
|
||||||
|
token: zod.string().optional(),
|
||||||
|
|
||||||
export const ZodGenericTokenWrite = ZodGenericToken.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type GenericTokenWrite = zod.infer<typeof ZodGenericTokenWrite>;
|
export type GenericTokenWrite = zod.infer<typeof ZodGenericTokenWrite>;
|
||||||
|
|
||||||
|
@ -20,8 +20,10 @@ export function isGetSignUpAvailable(data: any): data is GetSignUpAvailable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGetSignUpAvailableWrite = zod.object({
|
||||||
|
signup: zod.boolean(),
|
||||||
|
|
||||||
export const ZodGetSignUpAvailableWrite = ZodGetSignUpAvailable.partial();
|
});
|
||||||
|
|
||||||
export type GetSignUpAvailableWrite = zod.infer<typeof ZodGetSignUpAvailableWrite>;
|
export type GetSignUpAvailableWrite = zod.infer<typeof ZodGetSignUpAvailableWrite>;
|
||||||
|
|
||||||
|
@ -20,8 +20,10 @@ export function isGetToken(data: any): data is GetToken {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodGetTokenWrite = zod.object({
|
||||||
|
jwt: zod.string().optional(),
|
||||||
|
|
||||||
export const ZodGetTokenWrite = ZodGetToken.partial();
|
});
|
||||||
|
|
||||||
export type GetTokenWrite = zod.infer<typeof ZodGetTokenWrite>;
|
export type GetTokenWrite = zod.infer<typeof ZodGetTokenWrite>;
|
||||||
|
|
||||||
|
@ -15,10 +15,11 @@ export * from "./generic-timing"
|
|||||||
export * from "./generic-token"
|
export * from "./generic-token"
|
||||||
export * from "./get-sign-up-available"
|
export * from "./get-sign-up-available"
|
||||||
export * from "./get-token"
|
export * from "./get-token"
|
||||||
export * from "./int"
|
|
||||||
export * from "./integer"
|
export * from "./integer"
|
||||||
export * from "./iso-date"
|
export * from "./iso-date"
|
||||||
export * from "./long"
|
export * from "./long"
|
||||||
|
export * from "./object-id"
|
||||||
|
export * from "./part-right"
|
||||||
export * from "./public-key"
|
export * from "./public-key"
|
||||||
export * from "./rest-error-response"
|
export * from "./rest-error-response"
|
||||||
export * from "./right"
|
export * from "./right"
|
||||||
|
8
front/src/back-api/model/object-id.ts
Normal file
8
front/src/back-api/model/object-id.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export const ZodObjectId = zod.string().length(24, "Invalid ObjectId length").regex(/^[a-fA-F0-9]{24}$/, "Invalid ObjectId format");
|
||||||
|
export type ObjectId = zod.infer<typeof ZodObjectId>;
|
24
front/src/back-api/model/part-right.ts
Normal file
24
front/src/back-api/model/part-right.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Interface of the server (auto-generated code)
|
||||||
|
*/
|
||||||
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
|
|
||||||
|
export enum PartRight {
|
||||||
|
READ = 1,
|
||||||
|
NONE = 0,
|
||||||
|
WRITE = 2,
|
||||||
|
READ_WRITE = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ZodPartRight = zod.nativeEnum(PartRight);
|
||||||
|
|
||||||
|
export function isPartRight(data: any): data is PartRight {
|
||||||
|
try {
|
||||||
|
ZodPartRight.parse(data);
|
||||||
|
return true;
|
||||||
|
} catch (e: any) {
|
||||||
|
console.log(`Fail to parse data type='ZodPartRight' error=${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -20,8 +20,10 @@ export function isPublicKey(data: any): data is PublicKey {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodPublicKeyWrite = zod.object({
|
||||||
|
key: zod.string().max(255).nullable().optional(),
|
||||||
|
|
||||||
export const ZodPublicKeyWrite = ZodPublicKey.partial();
|
});
|
||||||
|
|
||||||
export type PublicKeyWrite = zod.infer<typeof ZodPublicKeyWrite>;
|
export type PublicKeyWrite = zod.infer<typeof ZodPublicKeyWrite>;
|
||||||
|
|
||||||
|
@ -3,15 +3,15 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodUUID} from "./uuid";
|
import {ZodObjectId} from "./object-id";
|
||||||
import {Zodint} from "./int";
|
import {ZodInteger} from "./integer";
|
||||||
|
|
||||||
export const ZodRestErrorResponse = zod.object({
|
export const ZodRestErrorResponse = zod.object({
|
||||||
uuid: ZodUUID.optional(),
|
oid: ZodObjectId.optional(),
|
||||||
name: zod.string(),
|
name: zod.string(),
|
||||||
message: zod.string(),
|
message: zod.string(),
|
||||||
time: zod.string(),
|
time: zod.string(),
|
||||||
status: Zodint,
|
status: ZodInteger,
|
||||||
statusMessage: zod.string(),
|
statusMessage: zod.string(),
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -27,17 +27,3 @@ export function isRestErrorResponse(data: any): data is RestErrorResponse {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ZodRestErrorResponseWrite = ZodRestErrorResponse.partial();
|
|
||||||
|
|
||||||
export type RestErrorResponseWrite = zod.infer<typeof ZodRestErrorResponseWrite>;
|
|
||||||
|
|
||||||
export function isRestErrorResponseWrite(data: any): data is RestErrorResponseWrite {
|
|
||||||
try {
|
|
||||||
ZodRestErrorResponseWrite.parse(data);
|
|
||||||
return true;
|
|
||||||
} catch (e: any) {
|
|
||||||
console.log(`Fail to parse data type='ZodRestErrorResponseWrite' error=${e}`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -23,14 +23,6 @@ export const ZodRightDescription = ZodGenericDataSoftDelete.extend({
|
|||||||
* Description of the right
|
* Description of the right
|
||||||
*/
|
*/
|
||||||
description: zod.string().max(1024),
|
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),
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,14 +37,25 @@ export function isRightDescription(data: any): data is RightDescription {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodRightDescriptionWrite = ZodGenericDataSoftDeleteWrite.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(),
|
||||||
|
|
||||||
export const ZodRightDescriptionWrite = ZodRightDescription.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type RightDescriptionWrite = zod.infer<typeof ZodRightDescriptionWrite>;
|
export type RightDescriptionWrite = zod.infer<typeof ZodRightDescriptionWrite>;
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@
|
|||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodPartRight} from "./part-right";
|
||||||
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
export const ZodRight = ZodGenericDataSoftDelete.extend({
|
||||||
/**
|
/**
|
||||||
@ -22,7 +23,7 @@ export const ZodRight = ZodGenericDataSoftDelete.extend({
|
|||||||
/**
|
/**
|
||||||
* Value of the right
|
* Value of the right
|
||||||
*/
|
*/
|
||||||
value: zod.string().max(1024),
|
value: ZodPartRight,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,14 +38,25 @@ export function isRight(data: any): data is Right {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodRightWrite = ZodGenericDataSoftDeleteWrite.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: ZodPartRight.optional(),
|
||||||
|
|
||||||
export const ZodRightWrite = ZodRight.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type RightWrite = zod.infer<typeof ZodRightWrite>;
|
export type RightWrite = zod.infer<typeof ZodRightWrite>;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
import { z as zod } from "zod";
|
import { z as zod } from "zod";
|
||||||
|
|
||||||
import {ZodUser} from "./user";
|
import {ZodUser, ZodUserWrite } from "./user";
|
||||||
|
|
||||||
export const ZodUserAuthGet = ZodUser.extend({
|
export const ZodUserAuthGet = ZodUser.extend({
|
||||||
email: zod.string().max(512),
|
email: zod.string().max(512),
|
||||||
@ -22,14 +22,11 @@ export function isUserAuthGet(data: any): data is UserAuthGet {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodUserAuthGetWrite = ZodUserWrite.extend({
|
||||||
|
email: zod.string().max(512).optional(),
|
||||||
|
avatar: zod.boolean().optional(),
|
||||||
|
|
||||||
export const ZodUserAuthGetWrite = ZodUserAuthGet.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type UserAuthGetWrite = zod.infer<typeof ZodUserAuthGetWrite>;
|
export type UserAuthGetWrite = zod.infer<typeof ZodUserAuthGetWrite>;
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
import {ZodTimestamp} from "./timestamp";
|
import {ZodTimestamp} from "./timestamp";
|
||||||
import {ZodLong} from "./long";
|
import {ZodLong} from "./long";
|
||||||
import {ZodUser} from "./user";
|
import {ZodUser, ZodUserWrite } from "./user";
|
||||||
|
|
||||||
export const ZodUserAuth = ZodUser.extend({
|
export const ZodUserAuth = ZodUser.extend({
|
||||||
password: zod.string().max(128),
|
password: zod.string().min(128).max(128).optional(),
|
||||||
email: zod.string().max(512),
|
email: zod.string().min(5).max(128),
|
||||||
emailValidate: ZodTimestamp.optional(),
|
emailValidate: ZodTimestamp.optional(),
|
||||||
newEmail: zod.string().max(512).optional(),
|
newEmail: zod.string().min(5).max(128).optional(),
|
||||||
avatar: zod.boolean(),
|
avatar: zod.boolean(),
|
||||||
/**
|
/**
|
||||||
* List of accessible application (if not set the application is not available)
|
* List of accessible application (if not set the application is not available)
|
||||||
@ -31,14 +31,18 @@ export function isUserAuth(data: any): data is UserAuth {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodUserAuthWrite = ZodUserWrite.extend({
|
||||||
|
password: zod.string().min(128).max(128).nullable().optional(),
|
||||||
|
email: zod.string().min(5).max(128).optional(),
|
||||||
|
emailValidate: ZodTimestamp.nullable().optional(),
|
||||||
|
newEmail: zod.string().min(5).max(128).nullable().optional(),
|
||||||
|
avatar: zod.boolean().optional(),
|
||||||
|
/**
|
||||||
|
* List of accessible application (if not set the application is not available)
|
||||||
|
*/
|
||||||
|
applications: zod.array(ZodLong).optional(),
|
||||||
|
|
||||||
export const ZodUserAuthWrite = ZodUserAuth.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type UserAuthWrite = zod.infer<typeof ZodUserAuthWrite>;
|
export type UserAuthWrite = zod.infer<typeof ZodUserAuthWrite>;
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
|
|
||||||
export const ZodUserCreate = zod.object({
|
export const ZodUserCreate = zod.object({
|
||||||
login: zod.string().max(255).optional(),
|
login: zod.string().min(3).max(128),
|
||||||
email: zod.string().max(255).optional(),
|
email: zod.string().min(5).max(128),
|
||||||
password: zod.string().max(255).optional(),
|
password: zod.string().min(128).max(128),
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,8 +22,12 @@ export function isUserCreate(data: any): data is UserCreate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodUserCreateWrite = zod.object({
|
||||||
|
login: zod.string().min(3).max(128).optional(),
|
||||||
|
email: zod.string().min(5).max(128).optional(),
|
||||||
|
password: zod.string().min(128).max(128).optional(),
|
||||||
|
|
||||||
export const ZodUserCreateWrite = ZodUserCreate.partial();
|
});
|
||||||
|
|
||||||
export type UserCreateWrite = zod.infer<typeof ZodUserCreateWrite>;
|
export type UserCreateWrite = zod.infer<typeof ZodUserCreateWrite>;
|
||||||
|
|
||||||
|
@ -22,8 +22,11 @@ export function isUserOut(data: any): data is UserOut {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodUserOutWrite = zod.object({
|
||||||
|
id: ZodLong,
|
||||||
|
login: zod.string().max(255).nullable().optional(),
|
||||||
|
|
||||||
export const ZodUserOutWrite = ZodUserOut.partial();
|
});
|
||||||
|
|
||||||
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
export type UserOutWrite = zod.infer<typeof ZodUserOutWrite>;
|
||||||
|
|
||||||
|
@ -5,14 +5,13 @@ import { z as zod } from "zod";
|
|||||||
|
|
||||||
import {ZodTimestamp} from "./timestamp";
|
import {ZodTimestamp} from "./timestamp";
|
||||||
import {ZodUUID} from "./uuid";
|
import {ZodUUID} from "./uuid";
|
||||||
import {ZodGenericDataSoftDelete} from "./generic-data-soft-delete";
|
import {ZodGenericDataSoftDelete, ZodGenericDataSoftDeleteWrite } from "./generic-data-soft-delete";
|
||||||
|
|
||||||
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
export const ZodUser = ZodGenericDataSoftDelete.extend({
|
||||||
login: zod.string().max(128).optional(),
|
login: zod.string().min(3).max(128),
|
||||||
lastConnection: ZodTimestamp.optional(),
|
lastConnection: ZodTimestamp.optional(),
|
||||||
admin: zod.boolean(),
|
blocked: zod.boolean().optional(),
|
||||||
blocked: zod.boolean(),
|
blockedReason: zod.string().max(512).optional(),
|
||||||
removed: zod.boolean(),
|
|
||||||
/**
|
/**
|
||||||
* List of Id of the specific covers
|
* List of Id of the specific covers
|
||||||
*/
|
*/
|
||||||
@ -31,14 +30,17 @@ export function isUser(data: any): data is User {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const ZodUserWrite = ZodGenericDataSoftDeleteWrite.extend({
|
||||||
|
login: zod.string().min(3).max(128).optional(),
|
||||||
|
lastConnection: ZodTimestamp.nullable().optional(),
|
||||||
|
blocked: zod.boolean().nullable().optional(),
|
||||||
|
blockedReason: zod.string().max(512).nullable().optional(),
|
||||||
|
/**
|
||||||
|
* List of Id of the specific covers
|
||||||
|
*/
|
||||||
|
covers: zod.array(ZodUUID).nullable().optional(),
|
||||||
|
|
||||||
export const ZodUserWrite = ZodUser.omit({
|
});
|
||||||
deleted: true,
|
|
||||||
id: true,
|
|
||||||
createdAt: true,
|
|
||||||
updatedAt: true,
|
|
||||||
|
|
||||||
}).partial();
|
|
||||||
|
|
||||||
export type UserWrite = zod.infer<typeof ZodUserWrite>;
|
export type UserWrite = zod.infer<typeof ZodUserWrite>;
|
||||||
|
|
||||||
|
@ -7,11 +7,15 @@
|
|||||||
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
import { RestErrorResponse, isRestErrorResponse } from "./model";
|
||||||
|
|
||||||
export enum HTTPRequestModel {
|
export enum HTTPRequestModel {
|
||||||
|
ARCHIVE = "ARCHIVE",
|
||||||
DELETE = "DELETE",
|
DELETE = "DELETE",
|
||||||
|
HEAD = "HEAD",
|
||||||
GET = "GET",
|
GET = "GET",
|
||||||
|
OPTION = "OPTION",
|
||||||
PATCH = "PATCH",
|
PATCH = "PATCH",
|
||||||
POST = "POST",
|
POST = "POST",
|
||||||
PUT = "PUT",
|
PUT = "PUT",
|
||||||
|
RESTORE = "RESTORE",
|
||||||
}
|
}
|
||||||
export enum HTTPMimeType {
|
export enum HTTPMimeType {
|
||||||
ALL = "*/*",
|
ALL = "*/*",
|
||||||
@ -74,7 +78,7 @@ export interface RESTRequestType {
|
|||||||
data?: any;
|
data?: any;
|
||||||
params?: object;
|
params?: object;
|
||||||
queries?: object;
|
queries?: object;
|
||||||
callback?: RESTCallbacks;
|
callbacks?: RESTCallbacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAll(input, searchValue, replaceValue) {
|
function replaceAll(input, searchValue, replaceValue) {
|
||||||
@ -237,7 +241,7 @@ export function RESTRequest({
|
|||||||
data,
|
data,
|
||||||
params,
|
params,
|
||||||
queries,
|
queries,
|
||||||
callback,
|
callbacks,
|
||||||
}: RESTRequestType): Promise<ModelResponseHttp> {
|
}: RESTRequestType): Promise<ModelResponseHttp> {
|
||||||
// Create the URL PATH:
|
// Create the URL PATH:
|
||||||
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
let generateUrl = RESTUrl({ restModel, restConfig, data, params, queries });
|
||||||
@ -248,9 +252,14 @@ export function RESTRequest({
|
|||||||
if (restModel.accept !== undefined) {
|
if (restModel.accept !== undefined) {
|
||||||
headers["Accept"] = restModel.accept;
|
headers["Accept"] = restModel.accept;
|
||||||
}
|
}
|
||||||
if (restModel.requestType !== HTTPRequestModel.GET) {
|
if (restModel.requestType !== HTTPRequestModel.GET &&
|
||||||
|
restModel.requestType !== HTTPRequestModel.ARCHIVE &&
|
||||||
|
restModel.requestType !== HTTPRequestModel.RESTORE
|
||||||
|
) {
|
||||||
// if Get we have not a content type, the body is empty
|
// if Get we have not a content type, the body is empty
|
||||||
if (restModel.contentType !== HTTPMimeType.MULTIPART) {
|
if (restModel.contentType !== HTTPMimeType.MULTIPART &&
|
||||||
|
restModel.contentType !== undefined
|
||||||
|
) {
|
||||||
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
// special case of multi-part ==> no content type otherwise the browser does not set the ";bundary=--****"
|
||||||
headers["Content-Type"] = restModel.contentType;
|
headers["Content-Type"] = restModel.contentType;
|
||||||
}
|
}
|
||||||
@ -268,10 +277,10 @@ export function RESTRequest({
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let action: undefined | Promise<Response> = undefined;
|
let action: undefined | Promise<Response> = undefined;
|
||||||
if (
|
if (
|
||||||
isNullOrUndefined(callback) ||
|
isNullOrUndefined(callbacks) ||
|
||||||
(isNullOrUndefined(callback.progressDownload) &&
|
(isNullOrUndefined(callbacks.progressDownload) &&
|
||||||
isNullOrUndefined(callback.progressUpload) &&
|
isNullOrUndefined(callbacks.progressUpload) &&
|
||||||
isNullOrUndefined(callback.abortHandle))
|
isNullOrUndefined(callbacks.abortHandle))
|
||||||
) {
|
) {
|
||||||
// No information needed: call the generic fetch interface
|
// No information needed: call the generic fetch interface
|
||||||
action = fetch(generateUrl, {
|
action = fetch(generateUrl, {
|
||||||
@ -288,7 +297,7 @@ export function RESTRequest({
|
|||||||
headers,
|
headers,
|
||||||
body,
|
body,
|
||||||
},
|
},
|
||||||
callback
|
callbacks
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
action
|
action
|
||||||
|
Loading…
x
Reference in New Issue
Block a user