235 lines
7.0 KiB
TypeScript
235 lines
7.0 KiB
TypeScript
import { api } from "./api";
|
|
import type { Nullable } from "./apiTypes.ts";
|
|
import type * as responses from "./responses.ts";
|
|
import type * as tokens from "./tokens.ts";
|
|
|
|
// Typescript: TSEndpoint= path=/auth/refresh; name=refresh; method=POST; request=users.RefreshRequest; response=tokens.TokenPair
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 47
|
|
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=/users/:uuid; name=updateUser; method=PUT; request=users.UpdateUserRequest; response=users.User
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 34
|
|
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=/auth/me; name=me; method=GET; response=users.User
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 40
|
|
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/password/forgot; name=forgotPassword; method=POST; request=users.ForgotPasswordRequest; response=responses.SimpleResponse
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 53
|
|
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=/auth/password/reset; name=resetPassword; method=POST; request=users.ResetPasswordRequest; response=responses.SimpleResponse
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 56
|
|
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=/auth/password/valid; name=validToken; method=POST; request=string; response=responses.SimpleResponse
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 59
|
|
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/:uuid; name=deleteUser; method=DELETE; response=responses.SimpleResponse
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 37
|
|
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=/users/:uuid; name=getUser; method=GET; response=users.User
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 28
|
|
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/register; name=register; method=POST; request=users.UserCreateRequest; response=users.User
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 50
|
|
export const register = async (
|
|
data: UserCreateRequest,
|
|
): Promise<{ data: User; error: Nullable<string> }> => {
|
|
return (await api.POST("/auth/register", data)) as {
|
|
data: User;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/users; name=createUser; method=POST; request=users.UserCreateRequest; response=users.User
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 31
|
|
export const createUser = async (
|
|
data: UserCreateRequest,
|
|
): Promise<{ data: User; error: Nullable<string> }> => {
|
|
return (await api.POST("/users", data)) as {
|
|
data: User;
|
|
error: Nullable<string>;
|
|
};
|
|
};
|
|
|
|
// Typescript: TSEndpoint= path=/auth/login; name=login; method=POST; request=users.LoginRequest; response=tokens.TokenPair
|
|
|
|
// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 44
|
|
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>;
|
|
};
|
|
};
|
|
|
|
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 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 ForgotPasswordRequest {
|
|
email: string;
|
|
}
|
|
|
|
export interface ResetPasswordRequest {
|
|
token: string;
|
|
password: string;
|
|
}
|
|
|
|
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 UserCreateRequest {
|
|
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: Nullable<Date>;
|
|
updatedAt: Nullable<Date>;
|
|
}
|
|
|
|
export interface RefreshRequest {
|
|
refresh_token: string;
|
|
}
|
|
|
|
export type UserRoles = string[];
|
|
|
|
export type UserStatus = (typeof EnumUserStatus)[keyof typeof EnumUserStatus];
|
|
|
|
export type UserTypes = string[];
|
|
|
|
export const EnumUserStatus = {
|
|
UserStatusPending: "pending",
|
|
UserStatusActive: "active",
|
|
UserStatusDisabled: "disabled",
|
|
} as const;
|