240 lines
6.6 KiB
TypeScript
240 lines
6.6 KiB
TypeScript
import { api } from "./api.ts";
|
|
import { Nullable } from "./apiTypes.ts";
|
|
import * as responses from "./responses.ts";
|
|
import * as tokens from "./tokens.ts";
|
|
|
|
// Typescript: TSEndpoint= path=/auth/refresh; name=refresh; method=POST; request=users.RefreshRequest; response=tokens.TokenPair
|
|
// internal/user/routes.go Line: 46
|
|
export const refresh = async (
|
|
data: RefreshRequest,
|
|
): Promise<{ data: tokens.TokenPair; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/refresh", data)) as {
|
|
data: tokens.TokenPair;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/password/reset; name=resetPassword; method=POST; request=users.ResetPasswordRequest; response=responses.SimpleResponse
|
|
// internal/user/routes.go Line: 55
|
|
export const resetPassword = async (
|
|
data: ResetPasswordRequest,
|
|
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/password/reset", data)) as {
|
|
data: responses.SimpleResponse;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/users/:uuid; name=getUser; method=GET; response=users.User
|
|
// internal/user/routes.go Line: 27
|
|
export const getUser = async (
|
|
uuid: string,
|
|
): Promise<{ data: User; error: Nullable<string> }> => {
|
|
return (await api.GET(`/users/${uuid}`)) as {
|
|
data: User;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/me; name=me; method=GET; response=users.User
|
|
// internal/user/routes.go Line: 39
|
|
export const me = async (): Promise<{
|
|
data: User;
|
|
error: Nullable<string>;
|
|
}> => {
|
|
return (await api.GET("/auth/me")) as { data: User; error: Nullable<string> };
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/register; name=register; method=POST; request=users.UserCreateInput; response=users.User
|
|
// internal/user/routes.go Line: 49
|
|
export const register = async (
|
|
data: UserCreateInput,
|
|
): Promise<{ data: User; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/register", data)) as {
|
|
data: User;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/password/forgot; name=forgotPassword; method=POST; request=users.ForgotPasswordRequest; response=responses.SimpleResponse
|
|
// internal/user/routes.go Line: 52
|
|
export const forgotPassword = async (
|
|
data: ForgotPasswordRequest,
|
|
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/password/forgot", data)) as {
|
|
data: responses.SimpleResponse;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/users/:uuid; name=updateUser; method=PUT; request=users.UpdateUserRequest; response=users.User
|
|
// internal/user/routes.go Line: 33
|
|
export const updateUser = async (
|
|
data: UpdateUserRequest,
|
|
): Promise<{ data: User; error: Nullable<string> }> => {
|
|
return (await api.PUT("/users/:uuid", data)) as {
|
|
data: User;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/users/:uuid; name=deleteUser; method=DELETE; response=responses.SimpleResponse
|
|
// internal/user/routes.go Line: 36
|
|
export const deleteUser = async (
|
|
uuid: string,
|
|
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
|
|
return (await api.DELETE(`/users/${uuid}`)) as {
|
|
data: responses.SimpleResponse;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/login; name=login; method=POST; request=users.LoginRequest; response=tokens.TokenPair
|
|
// internal/user/routes.go Line: 43
|
|
export const login = async (
|
|
data: LoginRequest,
|
|
): Promise<{ data: tokens.TokenPair; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/login", data)) as {
|
|
data: tokens.TokenPair;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/password/valid; name=validToken; method=POST; request=string; response=responses.SimpleResponse
|
|
// internal/user/routes.go Line: 58
|
|
export const validToken = async (
|
|
data: string,
|
|
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/password/valid", data)) as {
|
|
data: responses.SimpleResponse;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/users; name=createUser; method=POST; request=users.UserCreateInput; response=users.User
|
|
// internal/user/routes.go Line: 30
|
|
export const createUser = async (
|
|
data: UserCreateInput,
|
|
): Promise<{ data: User; error: Nullable<string> }> => {
|
|
return (await api.POST("/users", data)) as {
|
|
data: User;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
export interface RefreshRequest {
|
|
refresh_token: string;
|
|
}
|
|
|
|
export interface User {
|
|
id: number;
|
|
email: string;
|
|
name: string;
|
|
roles: UserRoles;
|
|
types: UserTypes;
|
|
status: UserStatus;
|
|
activatedAt: Date;
|
|
uuid: string;
|
|
details: Nullable<UserDetails>;
|
|
preferences: Nullable<UserPreferences>;
|
|
avatar: Nullable<string>;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export interface UserCreateInput {
|
|
name: string;
|
|
email: string;
|
|
password: string;
|
|
roles: UserRoles;
|
|
status: UserStatus;
|
|
types: UserTypes;
|
|
avatar: Nullable<string>;
|
|
details: Nullable<UserDetails>;
|
|
preferences: Nullable<UserPreferences>;
|
|
}
|
|
|
|
export interface UserPreferences {
|
|
id: number;
|
|
userId: number;
|
|
useIdle: boolean;
|
|
idleTimeout: number;
|
|
useIdlePassword: boolean;
|
|
idlePin: string;
|
|
useDirectLogin: boolean;
|
|
useQuadcodeLogin: boolean;
|
|
sendNoticesMail: boolean;
|
|
language: string;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export interface ForgotPasswordRequest {
|
|
email: string;
|
|
}
|
|
|
|
export interface UpdateUserRequest {
|
|
name: string;
|
|
email: string;
|
|
password: string;
|
|
roles: UserRoles;
|
|
status: UserStatus;
|
|
types: UserTypes;
|
|
avatar: Nullable<string>;
|
|
details: Nullable<UserDetails>;
|
|
preferences: Nullable<UserPreferences>;
|
|
}
|
|
|
|
export interface LoginRequest {
|
|
username: string;
|
|
password: string;
|
|
}
|
|
|
|
export interface UserDetails {
|
|
id: number;
|
|
userId: number;
|
|
title: string;
|
|
firstName: string;
|
|
lastName: string;
|
|
address: string;
|
|
city: string;
|
|
zipCode: string;
|
|
country: string;
|
|
phone: string;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export interface UserProfile {
|
|
id: number;
|
|
email: string;
|
|
name: string;
|
|
roles: UserRoles;
|
|
types: UserTypes;
|
|
status: UserStatus;
|
|
activatedAt: Date;
|
|
uuid: string;
|
|
details: Nullable<UserDetails>;
|
|
preferences: Nullable<UserPreferences>;
|
|
avatar: Nullable<string>;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
}
|
|
|
|
export interface ResetPasswordRequest {
|
|
token: string;
|
|
password: string;
|
|
}
|
|
|
|
export type UserRoles = string[];
|
|
|
|
export type UserTypes = string[];
|
|
|
|
export type UserStatus = (typeof EnumUserStatus)[keyof typeof EnumUserStatus];
|
|
|
|
export const EnumUserStatus = {
|
|
UserStatusPending: "pending",
|
|
UserStatusActive: "active",
|
|
UserStatusDisabled: "disabled",
|
|
} as const;
|