🎨 Run biome after OpenAPI client generation (#1226)
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"ignore": ["node_modules", "src/client/", "src/routeTree.gen.ts"]
|
"ignore": ["node_modules", "src/routeTree.gen.ts"]
|
||||||
},
|
},
|
||||||
"linter": {
|
"linter": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
"lint": "biome check --apply-unsafe --no-errors-on-unmatched --files-ignore-unknown=true ./",
|
"lint": "biome check --apply-unsafe --no-errors-on-unmatched --files-ignore-unknown=true ./",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios --exportSchemas true"
|
"generate-client": "openapi-ts --input ./openapi.json --output ./src/client --client axios --exportSchemas true && biome format --write ./src/client"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chakra-ui/icons": "2.1.1",
|
"@chakra-ui/icons": "2.1.1",
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
import type { ApiRequestOptions } from './ApiRequestOptions';
|
import type { ApiRequestOptions } from "./ApiRequestOptions"
|
||||||
import type { ApiResult } from './ApiResult';
|
import type { ApiResult } from "./ApiResult"
|
||||||
|
|
||||||
export class ApiError extends Error {
|
export class ApiError extends Error {
|
||||||
public readonly url: string;
|
public readonly url: string
|
||||||
public readonly status: number;
|
public readonly status: number
|
||||||
public readonly statusText: string;
|
public readonly statusText: string
|
||||||
public readonly body: unknown;
|
public readonly body: unknown
|
||||||
public readonly request: ApiRequestOptions;
|
public readonly request: ApiRequestOptions
|
||||||
|
|
||||||
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
constructor(
|
||||||
super(message);
|
request: ApiRequestOptions,
|
||||||
|
response: ApiResult,
|
||||||
|
message: string,
|
||||||
|
) {
|
||||||
|
super(message)
|
||||||
|
|
||||||
this.name = 'ApiError';
|
this.name = "ApiError"
|
||||||
this.url = response.url;
|
this.url = response.url
|
||||||
this.status = response.status;
|
this.status = response.status
|
||||||
this.statusText = response.statusText;
|
this.statusText = response.statusText
|
||||||
this.body = response.body;
|
this.body = response.body
|
||||||
this.request = request;
|
this.request = request
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,20 @@
|
|||||||
export type ApiRequestOptions = {
|
export type ApiRequestOptions = {
|
||||||
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
readonly method:
|
||||||
readonly url: string;
|
| "GET"
|
||||||
readonly path?: Record<string, unknown>;
|
| "PUT"
|
||||||
readonly cookies?: Record<string, unknown>;
|
| "POST"
|
||||||
readonly headers?: Record<string, unknown>;
|
| "DELETE"
|
||||||
readonly query?: Record<string, unknown>;
|
| "OPTIONS"
|
||||||
readonly formData?: Record<string, unknown>;
|
| "HEAD"
|
||||||
readonly body?: any;
|
| "PATCH"
|
||||||
readonly mediaType?: string;
|
readonly url: string
|
||||||
readonly responseHeader?: string;
|
readonly path?: Record<string, unknown>
|
||||||
readonly errors?: Record<number, string>;
|
readonly cookies?: Record<string, unknown>
|
||||||
};
|
readonly headers?: Record<string, unknown>
|
||||||
|
readonly query?: Record<string, unknown>
|
||||||
|
readonly formData?: Record<string, unknown>
|
||||||
|
readonly body?: any
|
||||||
|
readonly mediaType?: string
|
||||||
|
readonly responseHeader?: string
|
||||||
|
readonly errors?: Record<number, string>
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export type ApiResult<TData = any> = {
|
export type ApiResult<TData = any> = {
|
||||||
readonly body: TData;
|
readonly body: TData
|
||||||
readonly ok: boolean;
|
readonly ok: boolean
|
||||||
readonly status: number;
|
readonly status: number
|
||||||
readonly statusText: string;
|
readonly statusText: string
|
||||||
readonly url: string;
|
readonly url: string
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,126 +1,126 @@
|
|||||||
export class CancelError extends Error {
|
export class CancelError extends Error {
|
||||||
constructor(message: string) {
|
constructor(message: string) {
|
||||||
super(message);
|
super(message)
|
||||||
this.name = 'CancelError';
|
this.name = "CancelError"
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isCancelled(): boolean {
|
public get isCancelled(): boolean {
|
||||||
return true;
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OnCancel {
|
export interface OnCancel {
|
||||||
readonly isResolved: boolean;
|
readonly isResolved: boolean
|
||||||
readonly isRejected: boolean;
|
readonly isRejected: boolean
|
||||||
readonly isCancelled: boolean;
|
readonly isCancelled: boolean
|
||||||
|
|
||||||
(cancelHandler: () => void): void;
|
(cancelHandler: () => void): void
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CancelablePromise<T> implements Promise<T> {
|
export class CancelablePromise<T> implements Promise<T> {
|
||||||
private _isResolved: boolean;
|
private _isResolved: boolean
|
||||||
private _isRejected: boolean;
|
private _isRejected: boolean
|
||||||
private _isCancelled: boolean;
|
private _isCancelled: boolean
|
||||||
readonly cancelHandlers: (() => void)[];
|
readonly cancelHandlers: (() => void)[]
|
||||||
readonly promise: Promise<T>;
|
readonly promise: Promise<T>
|
||||||
private _resolve?: (value: T | PromiseLike<T>) => void;
|
private _resolve?: (value: T | PromiseLike<T>) => void
|
||||||
private _reject?: (reason?: unknown) => void;
|
private _reject?: (reason?: unknown) => void
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
executor: (
|
executor: (
|
||||||
resolve: (value: T | PromiseLike<T>) => void,
|
resolve: (value: T | PromiseLike<T>) => void,
|
||||||
reject: (reason?: unknown) => void,
|
reject: (reason?: unknown) => void,
|
||||||
onCancel: OnCancel
|
onCancel: OnCancel,
|
||||||
) => void
|
) => void,
|
||||||
) {
|
) {
|
||||||
this._isResolved = false;
|
this._isResolved = false
|
||||||
this._isRejected = false;
|
this._isRejected = false
|
||||||
this._isCancelled = false;
|
this._isCancelled = false
|
||||||
this.cancelHandlers = [];
|
this.cancelHandlers = []
|
||||||
this.promise = new Promise<T>((resolve, reject) => {
|
this.promise = new Promise<T>((resolve, reject) => {
|
||||||
this._resolve = resolve;
|
this._resolve = resolve
|
||||||
this._reject = reject;
|
this._reject = reject
|
||||||
|
|
||||||
const onResolve = (value: T | PromiseLike<T>): void => {
|
const onResolve = (value: T | PromiseLike<T>): void => {
|
||||||
if (this._isResolved || this._isRejected || this._isCancelled) {
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
||||||
return;
|
return
|
||||||
|
}
|
||||||
|
this._isResolved = true
|
||||||
|
if (this._resolve) this._resolve(value)
|
||||||
}
|
}
|
||||||
this._isResolved = true;
|
|
||||||
if (this._resolve) this._resolve(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onReject = (reason?: unknown): void => {
|
const onReject = (reason?: unknown): void => {
|
||||||
if (this._isResolved || this._isRejected || this._isCancelled) {
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
||||||
return;
|
return
|
||||||
|
}
|
||||||
|
this._isRejected = true
|
||||||
|
if (this._reject) this._reject(reason)
|
||||||
}
|
}
|
||||||
this._isRejected = true;
|
|
||||||
if (this._reject) this._reject(reason);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onCancel = (cancelHandler: () => void): void => {
|
const onCancel = (cancelHandler: () => void): void => {
|
||||||
if (this._isResolved || this._isRejected || this._isCancelled) {
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
||||||
return;
|
return
|
||||||
|
}
|
||||||
|
this.cancelHandlers.push(cancelHandler)
|
||||||
}
|
}
|
||||||
this.cancelHandlers.push(cancelHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
Object.defineProperty(onCancel, 'isResolved', {
|
Object.defineProperty(onCancel, "isResolved", {
|
||||||
get: (): boolean => this._isResolved,
|
get: (): boolean => this._isResolved,
|
||||||
});
|
})
|
||||||
|
|
||||||
Object.defineProperty(onCancel, 'isRejected', {
|
Object.defineProperty(onCancel, "isRejected", {
|
||||||
get: (): boolean => this._isRejected,
|
get: (): boolean => this._isRejected,
|
||||||
});
|
})
|
||||||
|
|
||||||
Object.defineProperty(onCancel, 'isCancelled', {
|
Object.defineProperty(onCancel, "isCancelled", {
|
||||||
get: (): boolean => this._isCancelled,
|
get: (): boolean => this._isCancelled,
|
||||||
});
|
})
|
||||||
|
|
||||||
return executor(onResolve, onReject, onCancel as OnCancel);
|
return executor(onResolve, onReject, onCancel as OnCancel)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get [Symbol.toStringTag]() {
|
get [Symbol.toStringTag]() {
|
||||||
return "Cancellable Promise";
|
return "Cancellable Promise"
|
||||||
}
|
}
|
||||||
|
|
||||||
public then<TResult1 = T, TResult2 = never>(
|
public then<TResult1 = T, TResult2 = never>(
|
||||||
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
||||||
onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null
|
onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null,
|
||||||
): Promise<TResult1 | TResult2> {
|
): Promise<TResult1 | TResult2> {
|
||||||
return this.promise.then(onFulfilled, onRejected);
|
return this.promise.then(onFulfilled, onRejected)
|
||||||
}
|
}
|
||||||
|
|
||||||
public catch<TResult = never>(
|
public catch<TResult = never>(
|
||||||
onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null
|
onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null,
|
||||||
): Promise<T | TResult> {
|
): Promise<T | TResult> {
|
||||||
return this.promise.catch(onRejected);
|
return this.promise.catch(onRejected)
|
||||||
}
|
}
|
||||||
|
|
||||||
public finally(onFinally?: (() => void) | null): Promise<T> {
|
public finally(onFinally?: (() => void) | null): Promise<T> {
|
||||||
return this.promise.finally(onFinally);
|
return this.promise.finally(onFinally)
|
||||||
}
|
}
|
||||||
|
|
||||||
public cancel(): void {
|
public cancel(): void {
|
||||||
if (this._isResolved || this._isRejected || this._isCancelled) {
|
if (this._isResolved || this._isRejected || this._isCancelled) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
this._isCancelled = true;
|
this._isCancelled = true
|
||||||
if (this.cancelHandlers.length) {
|
if (this.cancelHandlers.length) {
|
||||||
try {
|
try {
|
||||||
for (const cancelHandler of this.cancelHandlers) {
|
for (const cancelHandler of this.cancelHandlers) {
|
||||||
cancelHandler();
|
cancelHandler()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Cancellation threw an error', error);
|
console.warn("Cancellation threw an error", error)
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.cancelHandlers.length = 0;
|
this.cancelHandlers.length = 0
|
||||||
if (this._reject) this._reject(new CancelError('Request aborted'));
|
if (this._reject) this._reject(new CancelError("Request aborted"))
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isCancelled(): boolean {
|
public get isCancelled(): boolean {
|
||||||
return this._isCancelled;
|
return this._isCancelled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,58 +1,57 @@
|
|||||||
import type { AxiosRequestConfig, AxiosResponse } from 'axios';import type { ApiRequestOptions } from './ApiRequestOptions';
|
import type { AxiosRequestConfig, AxiosResponse } from "axios"
|
||||||
import type { TResult } from './types';
|
import type { ApiRequestOptions } from "./ApiRequestOptions"
|
||||||
|
import type { TResult } from "./types"
|
||||||
|
|
||||||
type Headers = Record<string, string>;
|
type Headers = Record<string, string>
|
||||||
type Middleware<T> = (value: T) => T | Promise<T>;
|
type Middleware<T> = (value: T) => T | Promise<T>
|
||||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>
|
||||||
|
|
||||||
export class Interceptors<T> {
|
export class Interceptors<T> {
|
||||||
_fns: Middleware<T>[];
|
_fns: Middleware<T>[]
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._fns = [];
|
this._fns = []
|
||||||
}
|
}
|
||||||
|
|
||||||
eject(fn: Middleware<T>) {
|
eject(fn: Middleware<T>) {
|
||||||
const index = this._fns.indexOf(fn);
|
const index = this._fns.indexOf(fn)
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this._fns = [
|
this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]
|
||||||
...this._fns.slice(0, index),
|
|
||||||
...this._fns.slice(index + 1),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use(fn: Middleware<T>) {
|
use(fn: Middleware<T>) {
|
||||||
this._fns = [...this._fns, fn];
|
this._fns = [...this._fns, fn]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OpenAPIConfig = {
|
export type OpenAPIConfig = {
|
||||||
BASE: string;
|
BASE: string
|
||||||
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
CREDENTIALS: "include" | "omit" | "same-origin"
|
||||||
ENCODE_PATH?: ((path: string) => string) | undefined;
|
ENCODE_PATH?: ((path: string) => string) | undefined
|
||||||
HEADERS?: Headers | Resolver<Headers> | undefined;
|
HEADERS?: Headers | Resolver<Headers> | undefined
|
||||||
PASSWORD?: string | Resolver<string> | undefined;
|
PASSWORD?: string | Resolver<string> | undefined
|
||||||
RESULT?: TResult;
|
RESULT?: TResult
|
||||||
TOKEN?: string | Resolver<string> | undefined;
|
TOKEN?: string | Resolver<string> | undefined
|
||||||
USERNAME?: string | Resolver<string> | undefined;
|
USERNAME?: string | Resolver<string> | undefined
|
||||||
VERSION: string;
|
VERSION: string
|
||||||
WITH_CREDENTIALS: boolean;
|
WITH_CREDENTIALS: boolean
|
||||||
interceptors: {request: Interceptors<AxiosRequestConfig>;
|
interceptors: {
|
||||||
response: Interceptors<AxiosResponse>;};
|
request: Interceptors<AxiosRequestConfig>
|
||||||
};
|
response: Interceptors<AxiosResponse>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const OpenAPI: OpenAPIConfig = {
|
export const OpenAPI: OpenAPIConfig = {
|
||||||
BASE: '',
|
BASE: "",
|
||||||
CREDENTIALS: 'include',
|
CREDENTIALS: "include",
|
||||||
ENCODE_PATH: undefined,
|
ENCODE_PATH: undefined,
|
||||||
HEADERS: undefined,
|
HEADERS: undefined,
|
||||||
PASSWORD: undefined,
|
PASSWORD: undefined,
|
||||||
RESULT: 'body',
|
RESULT: "body",
|
||||||
TOKEN: undefined,
|
TOKEN: undefined,
|
||||||
USERNAME: undefined,
|
USERNAME: undefined,
|
||||||
VERSION: '0.1.0',
|
VERSION: "0.1.0",
|
||||||
WITH_CREDENTIALS: false,
|
WITH_CREDENTIALS: false,
|
||||||
interceptors: {request: new Interceptors(),response: new Interceptors(),
|
interceptors: { request: new Interceptors(), response: new Interceptors() },
|
||||||
},
|
}
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,173 +1,189 @@
|
|||||||
import axios from 'axios';
|
import axios from "axios"
|
||||||
import type { AxiosError, AxiosRequestConfig, AxiosResponse, AxiosInstance } from 'axios';
|
import type {
|
||||||
|
AxiosError,
|
||||||
|
AxiosRequestConfig,
|
||||||
|
AxiosResponse,
|
||||||
|
AxiosInstance,
|
||||||
|
} from "axios"
|
||||||
|
|
||||||
import { ApiError } from './ApiError';
|
import { ApiError } from "./ApiError"
|
||||||
import type { ApiRequestOptions } from './ApiRequestOptions';
|
import type { ApiRequestOptions } from "./ApiRequestOptions"
|
||||||
import type { ApiResult } from './ApiResult';
|
import type { ApiResult } from "./ApiResult"
|
||||||
import { CancelablePromise } from './CancelablePromise';
|
import { CancelablePromise } from "./CancelablePromise"
|
||||||
import type { OnCancel } from './CancelablePromise';
|
import type { OnCancel } from "./CancelablePromise"
|
||||||
import type { OpenAPIConfig } from './OpenAPI';
|
import type { OpenAPIConfig } from "./OpenAPI"
|
||||||
|
|
||||||
export const isString = (value: unknown): value is string => {
|
export const isString = (value: unknown): value is string => {
|
||||||
return typeof value === 'string';
|
return typeof value === "string"
|
||||||
};
|
}
|
||||||
|
|
||||||
export const isStringWithValue = (value: unknown): value is string => {
|
export const isStringWithValue = (value: unknown): value is string => {
|
||||||
return isString(value) && value !== '';
|
return isString(value) && value !== ""
|
||||||
};
|
}
|
||||||
|
|
||||||
export const isBlob = (value: any): value is Blob => {
|
export const isBlob = (value: any): value is Blob => {
|
||||||
return value instanceof Blob;
|
return value instanceof Blob
|
||||||
};
|
}
|
||||||
|
|
||||||
export const isFormData = (value: unknown): value is FormData => {
|
export const isFormData = (value: unknown): value is FormData => {
|
||||||
return value instanceof FormData;
|
return value instanceof FormData
|
||||||
};
|
}
|
||||||
|
|
||||||
export const isSuccess = (status: number): boolean => {
|
export const isSuccess = (status: number): boolean => {
|
||||||
return status >= 200 && status < 300;
|
return status >= 200 && status < 300
|
||||||
};
|
}
|
||||||
|
|
||||||
export const base64 = (str: string): string => {
|
export const base64 = (str: string): string => {
|
||||||
try {
|
try {
|
||||||
return btoa(str);
|
return btoa(str)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
return Buffer.from(str).toString('base64');
|
return Buffer.from(str).toString("base64")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const getQueryString = (params: Record<string, unknown>): string => {
|
export const getQueryString = (params: Record<string, unknown>): string => {
|
||||||
const qs: string[] = [];
|
const qs: string[] = []
|
||||||
|
|
||||||
const append = (key: string, value: unknown) => {
|
const append = (key: string, value: unknown) => {
|
||||||
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
|
||||||
};
|
}
|
||||||
|
|
||||||
const encodePair = (key: string, value: unknown) => {
|
const encodePair = (key: string, value: unknown) => {
|
||||||
if (value === undefined || value === null) {
|
if (value === undefined || value === null) {
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value.forEach(v => encodePair(key, v));
|
value.forEach((v) => encodePair(key, v))
|
||||||
} else if (typeof value === 'object') {
|
} else if (typeof value === "object") {
|
||||||
Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v));
|
Object.entries(value).forEach(([k, v]) => encodePair(`${key}[${k}]`, v))
|
||||||
} else {
|
} else {
|
||||||
append(key, value);
|
append(key, value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Object.entries(params).forEach(([key, value]) => encodePair(key, value));
|
Object.entries(params).forEach(([key, value]) => encodePair(key, value))
|
||||||
|
|
||||||
return qs.length ? `?${qs.join('&')}` : '';
|
return qs.length ? `?${qs.join("&")}` : ""
|
||||||
};
|
}
|
||||||
|
|
||||||
const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
|
const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
|
||||||
const encoder = config.ENCODE_PATH || encodeURI;
|
const encoder = config.ENCODE_PATH || encodeURI
|
||||||
|
|
||||||
const path = options.url
|
const path = options.url
|
||||||
.replace('{api-version}', config.VERSION)
|
.replace("{api-version}", config.VERSION)
|
||||||
.replace(/{(.*?)}/g, (substring: string, group: string) => {
|
.replace(/{(.*?)}/g, (substring: string, group: string) => {
|
||||||
if (options.path?.hasOwnProperty(group)) {
|
if (options.path?.hasOwnProperty(group)) {
|
||||||
return encoder(String(options.path[group]));
|
return encoder(String(options.path[group]))
|
||||||
}
|
}
|
||||||
return substring;
|
return substring
|
||||||
});
|
})
|
||||||
|
|
||||||
const url = config.BASE + path;
|
const url = config.BASE + path
|
||||||
return options.query ? url + getQueryString(options.query) : url;
|
return options.query ? url + getQueryString(options.query) : url
|
||||||
};
|
}
|
||||||
|
|
||||||
export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
|
export const getFormData = (
|
||||||
|
options: ApiRequestOptions,
|
||||||
|
): FormData | undefined => {
|
||||||
if (options.formData) {
|
if (options.formData) {
|
||||||
const formData = new FormData();
|
const formData = new FormData()
|
||||||
|
|
||||||
const process = (key: string, value: unknown) => {
|
const process = (key: string, value: unknown) => {
|
||||||
if (isString(value) || isBlob(value)) {
|
if (isString(value) || isBlob(value)) {
|
||||||
formData.append(key, value);
|
formData.append(key, value)
|
||||||
} else {
|
} else {
|
||||||
formData.append(key, JSON.stringify(value));
|
formData.append(key, JSON.stringify(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
Object.entries(options.formData)
|
Object.entries(options.formData)
|
||||||
.filter(([, value]) => value !== undefined && value !== null)
|
.filter(([, value]) => value !== undefined && value !== null)
|
||||||
.forEach(([key, value]) => {
|
.forEach(([key, value]) => {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
value.forEach(v => process(key, v));
|
value.forEach((v) => process(key, v))
|
||||||
} else {
|
} else {
|
||||||
process(key, value);
|
process(key, value)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
return formData;
|
return formData
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined
|
||||||
};
|
|
||||||
|
|
||||||
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
||||||
|
|
||||||
export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
|
|
||||||
if (typeof resolver === 'function') {
|
|
||||||
return (resolver as Resolver<T>)(options);
|
|
||||||
}
|
}
|
||||||
return resolver;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Record<string, string>> => {
|
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>
|
||||||
|
|
||||||
|
export const resolve = async <T>(
|
||||||
|
options: ApiRequestOptions,
|
||||||
|
resolver?: T | Resolver<T>,
|
||||||
|
): Promise<T | undefined> => {
|
||||||
|
if (typeof resolver === "function") {
|
||||||
|
return (resolver as Resolver<T>)(options)
|
||||||
|
}
|
||||||
|
return resolver
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getHeaders = async (
|
||||||
|
config: OpenAPIConfig,
|
||||||
|
options: ApiRequestOptions,
|
||||||
|
): Promise<Record<string, string>> => {
|
||||||
const [token, username, password, additionalHeaders] = await Promise.all([
|
const [token, username, password, additionalHeaders] = await Promise.all([
|
||||||
resolve(options, config.TOKEN),
|
resolve(options, config.TOKEN),
|
||||||
resolve(options, config.USERNAME),
|
resolve(options, config.USERNAME),
|
||||||
resolve(options, config.PASSWORD),
|
resolve(options, config.PASSWORD),
|
||||||
resolve(options, config.HEADERS),
|
resolve(options, config.HEADERS),
|
||||||
]);
|
])
|
||||||
|
|
||||||
const headers = Object.entries({
|
const headers = Object.entries({
|
||||||
Accept: 'application/json',
|
Accept: "application/json",
|
||||||
...additionalHeaders,
|
...additionalHeaders,
|
||||||
...options.headers,
|
...options.headers,
|
||||||
})
|
})
|
||||||
.filter(([, value]) => value !== undefined && value !== null)
|
.filter(([, value]) => value !== undefined && value !== null)
|
||||||
.reduce((headers, [key, value]) => ({
|
.reduce(
|
||||||
|
(headers, [key, value]) => ({
|
||||||
...headers,
|
...headers,
|
||||||
[key]: String(value),
|
[key]: String(value),
|
||||||
}), {} as Record<string, string>);
|
}),
|
||||||
|
{} as Record<string, string>,
|
||||||
|
)
|
||||||
|
|
||||||
if (isStringWithValue(token)) {
|
if (isStringWithValue(token)) {
|
||||||
headers['Authorization'] = `Bearer ${token}`;
|
headers["Authorization"] = `Bearer ${token}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isStringWithValue(username) && isStringWithValue(password)) {
|
if (isStringWithValue(username) && isStringWithValue(password)) {
|
||||||
const credentials = base64(`${username}:${password}`);
|
const credentials = base64(`${username}:${password}`)
|
||||||
headers['Authorization'] = `Basic ${credentials}`;
|
headers["Authorization"] = `Basic ${credentials}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.body !== undefined) {
|
if (options.body !== undefined) {
|
||||||
if (options.mediaType) {
|
if (options.mediaType) {
|
||||||
headers['Content-Type'] = options.mediaType;
|
headers["Content-Type"] = options.mediaType
|
||||||
} else if (isBlob(options.body)) {
|
} else if (isBlob(options.body)) {
|
||||||
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
headers["Content-Type"] = options.body.type || "application/octet-stream"
|
||||||
} else if (isString(options.body)) {
|
} else if (isString(options.body)) {
|
||||||
headers['Content-Type'] = 'text/plain';
|
headers["Content-Type"] = "text/plain"
|
||||||
} else if (!isFormData(options.body)) {
|
} else if (!isFormData(options.body)) {
|
||||||
headers['Content-Type'] = 'application/json';
|
headers["Content-Type"] = "application/json"
|
||||||
}
|
}
|
||||||
} else if (options.formData !== undefined) {
|
} else if (options.formData !== undefined) {
|
||||||
if (options.mediaType) {
|
if (options.mediaType) {
|
||||||
headers['Content-Type'] = options.mediaType;
|
headers["Content-Type"] = options.mediaType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return headers;
|
return headers
|
||||||
};
|
}
|
||||||
|
|
||||||
export const getRequestBody = (options: ApiRequestOptions): unknown => {
|
export const getRequestBody = (options: ApiRequestOptions): unknown => {
|
||||||
if (options.body) {
|
if (options.body) {
|
||||||
return options.body;
|
return options.body
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const sendRequest = async <T>(
|
export const sendRequest = async <T>(
|
||||||
config: OpenAPIConfig,
|
config: OpenAPIConfig,
|
||||||
@@ -177,9 +193,9 @@ export const sendRequest = async <T>(
|
|||||||
formData: FormData | undefined,
|
formData: FormData | undefined,
|
||||||
headers: Record<string, string>,
|
headers: Record<string, string>,
|
||||||
onCancel: OnCancel,
|
onCancel: OnCancel,
|
||||||
axiosClient: AxiosInstance
|
axiosClient: AxiosInstance,
|
||||||
): Promise<AxiosResponse<T>> => {
|
): Promise<AxiosResponse<T>> => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController()
|
||||||
|
|
||||||
let requestConfig: AxiosRequestConfig = {
|
let requestConfig: AxiosRequestConfig = {
|
||||||
data: body ?? formData,
|
data: body ?? formData,
|
||||||
@@ -188,108 +204,116 @@ export const sendRequest = async <T>(
|
|||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
url,
|
url,
|
||||||
withCredentials: config.WITH_CREDENTIALS,
|
withCredentials: config.WITH_CREDENTIALS,
|
||||||
};
|
}
|
||||||
|
|
||||||
onCancel(() => controller.abort());
|
onCancel(() => controller.abort())
|
||||||
|
|
||||||
for (const fn of config.interceptors.request._fns) {
|
for (const fn of config.interceptors.request._fns) {
|
||||||
requestConfig = await fn(requestConfig)
|
requestConfig = await fn(requestConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await axiosClient.request(requestConfig);
|
return await axiosClient.request(requestConfig)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const axiosError = error as AxiosError<T>;
|
const axiosError = error as AxiosError<T>
|
||||||
if (axiosError.response) {
|
if (axiosError.response) {
|
||||||
return axiosError.response;
|
return axiosError.response
|
||||||
|
}
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
export const getResponseHeader = (response: AxiosResponse<unknown>, responseHeader?: string): string | undefined => {
|
export const getResponseHeader = (
|
||||||
|
response: AxiosResponse<unknown>,
|
||||||
|
responseHeader?: string,
|
||||||
|
): string | undefined => {
|
||||||
if (responseHeader) {
|
if (responseHeader) {
|
||||||
const content = response.headers[responseHeader];
|
const content = response.headers[responseHeader]
|
||||||
if (isString(content)) {
|
if (isString(content)) {
|
||||||
return content;
|
return content
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined
|
||||||
};
|
}
|
||||||
|
|
||||||
export const getResponseBody = (response: AxiosResponse<unknown>): unknown => {
|
export const getResponseBody = (response: AxiosResponse<unknown>): unknown => {
|
||||||
if (response.status !== 204) {
|
if (response.status !== 204) {
|
||||||
return response.data;
|
return response.data
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
}
|
}
|
||||||
return undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
|
export const catchErrorCodes = (
|
||||||
|
options: ApiRequestOptions,
|
||||||
|
result: ApiResult,
|
||||||
|
): void => {
|
||||||
const errors: Record<number, string> = {
|
const errors: Record<number, string> = {
|
||||||
400: 'Bad Request',
|
400: "Bad Request",
|
||||||
401: 'Unauthorized',
|
401: "Unauthorized",
|
||||||
402: 'Payment Required',
|
402: "Payment Required",
|
||||||
403: 'Forbidden',
|
403: "Forbidden",
|
||||||
404: 'Not Found',
|
404: "Not Found",
|
||||||
405: 'Method Not Allowed',
|
405: "Method Not Allowed",
|
||||||
406: 'Not Acceptable',
|
406: "Not Acceptable",
|
||||||
407: 'Proxy Authentication Required',
|
407: "Proxy Authentication Required",
|
||||||
408: 'Request Timeout',
|
408: "Request Timeout",
|
||||||
409: 'Conflict',
|
409: "Conflict",
|
||||||
410: 'Gone',
|
410: "Gone",
|
||||||
411: 'Length Required',
|
411: "Length Required",
|
||||||
412: 'Precondition Failed',
|
412: "Precondition Failed",
|
||||||
413: 'Payload Too Large',
|
413: "Payload Too Large",
|
||||||
414: 'URI Too Long',
|
414: "URI Too Long",
|
||||||
415: 'Unsupported Media Type',
|
415: "Unsupported Media Type",
|
||||||
416: 'Range Not Satisfiable',
|
416: "Range Not Satisfiable",
|
||||||
417: 'Expectation Failed',
|
417: "Expectation Failed",
|
||||||
418: 'Im a teapot',
|
418: "Im a teapot",
|
||||||
421: 'Misdirected Request',
|
421: "Misdirected Request",
|
||||||
422: 'Unprocessable Content',
|
422: "Unprocessable Content",
|
||||||
423: 'Locked',
|
423: "Locked",
|
||||||
424: 'Failed Dependency',
|
424: "Failed Dependency",
|
||||||
425: 'Too Early',
|
425: "Too Early",
|
||||||
426: 'Upgrade Required',
|
426: "Upgrade Required",
|
||||||
428: 'Precondition Required',
|
428: "Precondition Required",
|
||||||
429: 'Too Many Requests',
|
429: "Too Many Requests",
|
||||||
431: 'Request Header Fields Too Large',
|
431: "Request Header Fields Too Large",
|
||||||
451: 'Unavailable For Legal Reasons',
|
451: "Unavailable For Legal Reasons",
|
||||||
500: 'Internal Server Error',
|
500: "Internal Server Error",
|
||||||
501: 'Not Implemented',
|
501: "Not Implemented",
|
||||||
502: 'Bad Gateway',
|
502: "Bad Gateway",
|
||||||
503: 'Service Unavailable',
|
503: "Service Unavailable",
|
||||||
504: 'Gateway Timeout',
|
504: "Gateway Timeout",
|
||||||
505: 'HTTP Version Not Supported',
|
505: "HTTP Version Not Supported",
|
||||||
506: 'Variant Also Negotiates',
|
506: "Variant Also Negotiates",
|
||||||
507: 'Insufficient Storage',
|
507: "Insufficient Storage",
|
||||||
508: 'Loop Detected',
|
508: "Loop Detected",
|
||||||
510: 'Not Extended',
|
510: "Not Extended",
|
||||||
511: 'Network Authentication Required',
|
511: "Network Authentication Required",
|
||||||
...options.errors,
|
...options.errors,
|
||||||
}
|
}
|
||||||
|
|
||||||
const error = errors[result.status];
|
const error = errors[result.status]
|
||||||
if (error) {
|
if (error) {
|
||||||
throw new ApiError(options, result, error);
|
throw new ApiError(options, result, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
const errorStatus = result.status ?? 'unknown';
|
const errorStatus = result.status ?? "unknown"
|
||||||
const errorStatusText = result.statusText ?? 'unknown';
|
const errorStatusText = result.statusText ?? "unknown"
|
||||||
const errorBody = (() => {
|
const errorBody = (() => {
|
||||||
try {
|
try {
|
||||||
return JSON.stringify(result.body, null, 2);
|
return JSON.stringify(result.body, null, 2)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return undefined;
|
return undefined
|
||||||
}
|
}
|
||||||
})();
|
})()
|
||||||
|
|
||||||
throw new ApiError(options, result,
|
throw new ApiError(
|
||||||
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
|
options,
|
||||||
);
|
result,
|
||||||
|
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request method
|
* Request method
|
||||||
@@ -299,23 +323,39 @@ export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult):
|
|||||||
* @returns CancelablePromise<T>
|
* @returns CancelablePromise<T>
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions, axiosClient: AxiosInstance = axios): CancelablePromise<T> => {
|
export const request = <T>(
|
||||||
|
config: OpenAPIConfig,
|
||||||
|
options: ApiRequestOptions,
|
||||||
|
axiosClient: AxiosInstance = axios,
|
||||||
|
): CancelablePromise<T> => {
|
||||||
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
||||||
try {
|
try {
|
||||||
const url = getUrl(config, options);
|
const url = getUrl(config, options)
|
||||||
const formData = getFormData(options);
|
const formData = getFormData(options)
|
||||||
const body = getRequestBody(options);
|
const body = getRequestBody(options)
|
||||||
const headers = await getHeaders(config, options);
|
const headers = await getHeaders(config, options)
|
||||||
|
|
||||||
if (!onCancel.isCancelled) {
|
if (!onCancel.isCancelled) {
|
||||||
let response = await sendRequest<T>(config, options, url, body, formData, headers, onCancel, axiosClient);
|
let response = await sendRequest<T>(
|
||||||
|
config,
|
||||||
|
options,
|
||||||
|
url,
|
||||||
|
body,
|
||||||
|
formData,
|
||||||
|
headers,
|
||||||
|
onCancel,
|
||||||
|
axiosClient,
|
||||||
|
)
|
||||||
|
|
||||||
for (const fn of config.interceptors.response._fns) {
|
for (const fn of config.interceptors.response._fns) {
|
||||||
response = await fn(response)
|
response = await fn(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
const responseBody = getResponseBody(response);
|
const responseBody = getResponseBody(response)
|
||||||
const responseHeader = getResponseHeader(response, options.responseHeader);
|
const responseHeader = getResponseHeader(
|
||||||
|
response,
|
||||||
|
options.responseHeader,
|
||||||
|
)
|
||||||
|
|
||||||
const result: ApiResult = {
|
const result: ApiResult = {
|
||||||
url,
|
url,
|
||||||
@@ -323,14 +363,14 @@ export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions, ax
|
|||||||
status: response.status,
|
status: response.status,
|
||||||
statusText: response.statusText,
|
statusText: response.statusText,
|
||||||
body: responseHeader ?? responseBody,
|
body: responseHeader ?? responseBody,
|
||||||
};
|
}
|
||||||
|
|
||||||
catchErrorCodes(options, result);
|
catchErrorCodes(options, result)
|
||||||
|
|
||||||
resolve(result.body);
|
resolve(result.body)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
import type { ApiResult } from './ApiResult';
|
import type { ApiResult } from "./ApiResult"
|
||||||
|
|
||||||
export type TResult = 'body' | 'raw';
|
export type TResult = "body" | "raw"
|
||||||
|
|
||||||
export type TApiResponse<T extends TResult, TData> =
|
export type TApiResponse<T extends TResult, TData> = Exclude<
|
||||||
Exclude<T, 'raw'> extends never
|
T,
|
||||||
|
"raw"
|
||||||
|
> extends never
|
||||||
? ApiResult<TData>
|
? ApiResult<TData>
|
||||||
: ApiResult<TData>['body'];
|
: ApiResult<TData>["body"]
|
||||||
|
|
||||||
export type TConfig<T extends TResult> = {
|
export type TConfig<T extends TResult> = {
|
||||||
_result?: T;
|
_result?: T
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
export { ApiError } from "./core/ApiError"
|
||||||
|
export { CancelablePromise, CancelError } from "./core/CancelablePromise"
|
||||||
|
export { OpenAPI } from "./core/OpenAPI"
|
||||||
|
export type { OpenAPIConfig } from "./core/OpenAPI"
|
||||||
|
|
||||||
export { ApiError } from './core/ApiError';
|
export * from "./models"
|
||||||
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
export * from "./schemas"
|
||||||
export { OpenAPI } from './core/OpenAPI';
|
export * from "./services"
|
||||||
export type { OpenAPIConfig } from './core/OpenAPI';
|
|
||||||
|
|
||||||
export * from './models'
|
|
||||||
export * from './schemas'
|
|
||||||
export * from './services'
|
|
||||||
|
|||||||
@@ -1,132 +1,99 @@
|
|||||||
export type Body_login_login_access_token = {
|
export type Body_login_login_access_token = {
|
||||||
grant_type?: string | null;
|
grant_type?: string | null
|
||||||
username: string;
|
username: string
|
||||||
password: string;
|
password: string
|
||||||
scope?: string;
|
scope?: string
|
||||||
client_id?: string | null;
|
client_id?: string | null
|
||||||
client_secret?: string | null;
|
client_secret?: string | null
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type HTTPValidationError = {
|
export type HTTPValidationError = {
|
||||||
detail?: Array<ValidationError>;
|
detail?: Array<ValidationError>
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type ItemCreate = {
|
export type ItemCreate = {
|
||||||
title: string;
|
title: string
|
||||||
description?: string | null;
|
description?: string | null
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type ItemPublic = {
|
export type ItemPublic = {
|
||||||
title: string;
|
title: string
|
||||||
description?: string | null;
|
description?: string | null
|
||||||
id: number;
|
id: number
|
||||||
owner_id: number;
|
owner_id: number
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type ItemUpdate = {
|
export type ItemUpdate = {
|
||||||
title?: string | null;
|
title?: string | null
|
||||||
description?: string | null;
|
description?: string | null
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type ItemsPublic = {
|
export type ItemsPublic = {
|
||||||
data: Array<ItemPublic>;
|
data: Array<ItemPublic>
|
||||||
count: number;
|
count: number
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type Message = {
|
export type Message = {
|
||||||
message: string;
|
message: string
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type NewPassword = {
|
export type NewPassword = {
|
||||||
token: string;
|
token: string
|
||||||
new_password: string;
|
new_password: string
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type Token = {
|
export type Token = {
|
||||||
access_token: string;
|
access_token: string
|
||||||
token_type?: string;
|
token_type?: string
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UpdatePassword = {
|
export type UpdatePassword = {
|
||||||
current_password: string;
|
current_password: string
|
||||||
new_password: string;
|
new_password: string
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UserCreate = {
|
export type UserCreate = {
|
||||||
email: string;
|
email: string
|
||||||
is_active?: boolean;
|
is_active?: boolean
|
||||||
is_superuser?: boolean;
|
is_superuser?: boolean
|
||||||
full_name?: string | null;
|
full_name?: string | null
|
||||||
password: string;
|
password: string
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UserPublic = {
|
export type UserPublic = {
|
||||||
email: string;
|
email: string
|
||||||
is_active?: boolean;
|
is_active?: boolean
|
||||||
is_superuser?: boolean;
|
is_superuser?: boolean
|
||||||
full_name?: string | null;
|
full_name?: string | null
|
||||||
id: number;
|
id: number
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UserRegister = {
|
export type UserRegister = {
|
||||||
email: string;
|
email: string
|
||||||
password: string;
|
password: string
|
||||||
full_name?: string | null;
|
full_name?: string | null
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UserUpdate = {
|
export type UserUpdate = {
|
||||||
email?: string | null;
|
email?: string | null
|
||||||
is_active?: boolean;
|
is_active?: boolean
|
||||||
is_superuser?: boolean;
|
is_superuser?: boolean
|
||||||
full_name?: string | null;
|
full_name?: string | null
|
||||||
password?: string | null;
|
password?: string | null
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UserUpdateMe = {
|
export type UserUpdateMe = {
|
||||||
full_name?: string | null;
|
full_name?: string | null
|
||||||
email?: string | null;
|
email?: string | null
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type UsersPublic = {
|
export type UsersPublic = {
|
||||||
data: Array<UserPublic>;
|
data: Array<UserPublic>
|
||||||
count: number;
|
count: number
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export type ValidationError = {
|
export type ValidationError = {
|
||||||
loc: Array<string | number>;
|
loc: Array<string | number>
|
||||||
msg: string;
|
msg: string
|
||||||
type: string;
|
type: string
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,357 +1,405 @@
|
|||||||
export const $Body_login_login_access_token = {
|
export const $Body_login_login_access_token = {
|
||||||
properties: {
|
properties: {
|
||||||
grant_type: {
|
grant_type: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
pattern: 'password',
|
type: "string",
|
||||||
}, {
|
pattern: "password",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
scope: {
|
scope: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
default: '',
|
default: "",
|
||||||
},
|
},
|
||||||
client_id: {
|
client_id: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
client_secret: {
|
client_secret: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $HTTPValidationError = {
|
export const $HTTPValidationError = {
|
||||||
properties: {
|
properties: {
|
||||||
detail: {
|
detail: {
|
||||||
type: 'array',
|
type: "array",
|
||||||
contains: {
|
contains: {
|
||||||
type: 'ValidationError',
|
type: "ValidationError",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $ItemCreate = {
|
export const $ItemCreate = {
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $ItemPublic = {
|
export const $ItemPublic = {
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
type: 'number',
|
type: "number",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
owner_id: {
|
owner_id: {
|
||||||
type: 'number',
|
type: "number",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $ItemUpdate = {
|
export const $ItemUpdate = {
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $ItemsPublic = {
|
export const $ItemsPublic = {
|
||||||
properties: {
|
properties: {
|
||||||
data: {
|
data: {
|
||||||
type: 'array',
|
type: "array",
|
||||||
contains: {
|
contains: {
|
||||||
type: 'ItemPublic',
|
type: "ItemPublic",
|
||||||
},
|
},
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
count: {
|
count: {
|
||||||
type: 'number',
|
type: "number",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $Message = {
|
export const $Message = {
|
||||||
properties: {
|
properties: {
|
||||||
message: {
|
message: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $NewPassword = {
|
export const $NewPassword = {
|
||||||
properties: {
|
properties: {
|
||||||
token: {
|
token: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
new_password: {
|
new_password: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $Token = {
|
export const $Token = {
|
||||||
properties: {
|
properties: {
|
||||||
access_token: {
|
access_token: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
token_type: {
|
token_type: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
default: 'bearer',
|
default: "bearer",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UpdatePassword = {
|
export const $UpdatePassword = {
|
||||||
properties: {
|
properties: {
|
||||||
current_password: {
|
current_password: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
new_password: {
|
new_password: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UserCreate = {
|
export const $UserCreate = {
|
||||||
properties: {
|
properties: {
|
||||||
email: {
|
email: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
is_active: {
|
is_active: {
|
||||||
type: 'boolean',
|
type: "boolean",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
is_superuser: {
|
is_superuser: {
|
||||||
type: 'boolean',
|
type: "boolean",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UserPublic = {
|
export const $UserPublic = {
|
||||||
properties: {
|
properties: {
|
||||||
email: {
|
email: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
is_active: {
|
is_active: {
|
||||||
type: 'boolean',
|
type: "boolean",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
is_superuser: {
|
is_superuser: {
|
||||||
type: 'boolean',
|
type: "boolean",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
id: {
|
id: {
|
||||||
type: 'number',
|
type: "number",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UserRegister = {
|
export const $UserRegister = {
|
||||||
properties: {
|
properties: {
|
||||||
email: {
|
email: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UserUpdate = {
|
export const $UserUpdate = {
|
||||||
properties: {
|
properties: {
|
||||||
email: {
|
email: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
is_active: {
|
is_active: {
|
||||||
type: 'boolean',
|
type: "boolean",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
is_superuser: {
|
is_superuser: {
|
||||||
type: 'boolean',
|
type: "boolean",
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
full_name: {
|
full_name: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UserUpdateMe = {
|
export const $UserUpdateMe = {
|
||||||
properties: {
|
properties: {
|
||||||
full_name: {
|
full_name: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
email: {
|
email: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'null',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "null",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $UsersPublic = {
|
export const $UsersPublic = {
|
||||||
properties: {
|
properties: {
|
||||||
data: {
|
data: {
|
||||||
type: 'array',
|
type: "array",
|
||||||
contains: {
|
contains: {
|
||||||
type: 'UserPublic',
|
type: "UserPublic",
|
||||||
},
|
},
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
count: {
|
count: {
|
||||||
type: 'number',
|
type: "number",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|
||||||
export const $ValidationError = {
|
export const $ValidationError = {
|
||||||
properties: {
|
properties: {
|
||||||
loc: {
|
loc: {
|
||||||
type: 'array',
|
type: "array",
|
||||||
contains: {
|
contains: {
|
||||||
type: 'any-of',
|
type: "any-of",
|
||||||
contains: [{
|
contains: [
|
||||||
type: 'string',
|
{
|
||||||
}, {
|
type: "string",
|
||||||
type: 'number',
|
},
|
||||||
}],
|
{
|
||||||
|
type: "number",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
msg: {
|
msg: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
type: 'string',
|
type: "string",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const
|
||||||
|
|||||||
@@ -1,47 +1,58 @@
|
|||||||
import type { CancelablePromise } from './core/CancelablePromise';
|
import type { CancelablePromise } from "./core/CancelablePromise"
|
||||||
import { OpenAPI } from './core/OpenAPI';
|
import { OpenAPI } from "./core/OpenAPI"
|
||||||
import { request as __request } from './core/request';
|
import { request as __request } from "./core/request"
|
||||||
|
|
||||||
import type { Body_login_login_access_token,Message,NewPassword,Token,UserPublic,UpdatePassword,UserCreate,UserRegister,UsersPublic,UserUpdate,UserUpdateMe,ItemCreate,ItemPublic,ItemsPublic,ItemUpdate } from './models';
|
import type {
|
||||||
|
Body_login_login_access_token,
|
||||||
|
Message,
|
||||||
|
NewPassword,
|
||||||
|
Token,
|
||||||
|
UserPublic,
|
||||||
|
UpdatePassword,
|
||||||
|
UserCreate,
|
||||||
|
UserRegister,
|
||||||
|
UsersPublic,
|
||||||
|
UserUpdate,
|
||||||
|
UserUpdateMe,
|
||||||
|
ItemCreate,
|
||||||
|
ItemPublic,
|
||||||
|
ItemsPublic,
|
||||||
|
ItemUpdate,
|
||||||
|
} from "./models"
|
||||||
|
|
||||||
export type TDataLoginAccessToken = {
|
export type TDataLoginAccessToken = {
|
||||||
formData: Body_login_login_access_token
|
formData: Body_login_login_access_token
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataRecoverPassword = {
|
export type TDataRecoverPassword = {
|
||||||
email: string
|
email: string
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataResetPassword = {
|
export type TDataResetPassword = {
|
||||||
requestBody: NewPassword
|
requestBody: NewPassword
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataRecoverPasswordHtmlContent = {
|
export type TDataRecoverPasswordHtmlContent = {
|
||||||
email: string
|
email: string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LoginService {
|
export class LoginService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login Access Token
|
* Login Access Token
|
||||||
* OAuth2 compatible token login, get an access token for future requests
|
* OAuth2 compatible token login, get an access token for future requests
|
||||||
* @returns Token Successful Response
|
* @returns Token Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static loginAccessToken(data: TDataLoginAccessToken): CancelablePromise<Token> {
|
public static loginAccessToken(
|
||||||
const {
|
data: TDataLoginAccessToken,
|
||||||
formData,
|
): CancelablePromise<Token> {
|
||||||
} = data;
|
const { formData } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/login/access-token',
|
url: "/api/v1/login/access-token",
|
||||||
formData: formData,
|
formData: formData,
|
||||||
mediaType: 'application/x-www-form-urlencoded',
|
mediaType: "application/x-www-form-urlencoded",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,9 +63,9 @@ formData,
|
|||||||
*/
|
*/
|
||||||
public static testToken(): CancelablePromise<UserPublic> {
|
public static testToken(): CancelablePromise<UserPublic> {
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/login/test-token',
|
url: "/api/v1/login/test-token",
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,20 +74,20 @@ formData,
|
|||||||
* @returns Message Successful Response
|
* @returns Message Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static recoverPassword(data: TDataRecoverPassword): CancelablePromise<Message> {
|
public static recoverPassword(
|
||||||
const {
|
data: TDataRecoverPassword,
|
||||||
email,
|
): CancelablePromise<Message> {
|
||||||
} = data;
|
const { email } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/password-recovery/{email}',
|
url: "/api/v1/password-recovery/{email}",
|
||||||
path: {
|
path: {
|
||||||
email
|
email,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,19 +96,19 @@ email,
|
|||||||
* @returns Message Successful Response
|
* @returns Message Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static resetPassword(data: TDataResetPassword): CancelablePromise<Message> {
|
public static resetPassword(
|
||||||
const {
|
data: TDataResetPassword,
|
||||||
requestBody,
|
): CancelablePromise<Message> {
|
||||||
} = data;
|
const { requestBody } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/reset-password/',
|
url: "/api/v1/reset-password/",
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,82 +117,72 @@ requestBody,
|
|||||||
* @returns string Successful Response
|
* @returns string Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static recoverPasswordHtmlContent(data: TDataRecoverPasswordHtmlContent): CancelablePromise<string> {
|
public static recoverPasswordHtmlContent(
|
||||||
const {
|
data: TDataRecoverPasswordHtmlContent,
|
||||||
email,
|
): CancelablePromise<string> {
|
||||||
} = data;
|
const { email } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/password-recovery-html-content/{email}',
|
url: "/api/v1/password-recovery-html-content/{email}",
|
||||||
path: {
|
path: {
|
||||||
email
|
email,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TDataReadUsers = {
|
export type TDataReadUsers = {
|
||||||
limit?: number
|
limit?: number
|
||||||
skip?: number
|
skip?: number
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataCreateUser = {
|
export type TDataCreateUser = {
|
||||||
requestBody: UserCreate
|
requestBody: UserCreate
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataUpdateUserMe = {
|
export type TDataUpdateUserMe = {
|
||||||
requestBody: UserUpdateMe
|
requestBody: UserUpdateMe
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataUpdatePasswordMe = {
|
export type TDataUpdatePasswordMe = {
|
||||||
requestBody: UpdatePassword
|
requestBody: UpdatePassword
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataRegisterUser = {
|
export type TDataRegisterUser = {
|
||||||
requestBody: UserRegister
|
requestBody: UserRegister
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataReadUserById = {
|
export type TDataReadUserById = {
|
||||||
userId: number
|
userId: number
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataUpdateUser = {
|
export type TDataUpdateUser = {
|
||||||
requestBody: UserUpdate
|
requestBody: UserUpdate
|
||||||
userId: number
|
userId: number
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataDeleteUser = {
|
export type TDataDeleteUser = {
|
||||||
userId: number
|
userId: number
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UsersService {
|
export class UsersService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read Users
|
* Read Users
|
||||||
* Retrieve users.
|
* Retrieve users.
|
||||||
* @returns UsersPublic Successful Response
|
* @returns UsersPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static readUsers(data: TDataReadUsers = {}): CancelablePromise<UsersPublic> {
|
public static readUsers(
|
||||||
const {
|
data: TDataReadUsers = {},
|
||||||
limit = 100,
|
): CancelablePromise<UsersPublic> {
|
||||||
skip = 0,
|
const { limit = 100, skip = 0 } = data
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
url: '/api/v1/users/',
|
url: "/api/v1/users/",
|
||||||
query: {
|
query: {
|
||||||
skip, limit
|
skip,
|
||||||
|
limit,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -190,19 +191,19 @@ skip = 0,
|
|||||||
* @returns UserPublic Successful Response
|
* @returns UserPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static createUser(data: TDataCreateUser): CancelablePromise<UserPublic> {
|
public static createUser(
|
||||||
const {
|
data: TDataCreateUser,
|
||||||
requestBody,
|
): CancelablePromise<UserPublic> {
|
||||||
} = data;
|
const { requestBody } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/users/',
|
url: "/api/v1/users/",
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,9 +214,9 @@ requestBody,
|
|||||||
*/
|
*/
|
||||||
public static readUserMe(): CancelablePromise<UserPublic> {
|
public static readUserMe(): CancelablePromise<UserPublic> {
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
url: '/api/v1/users/me',
|
url: "/api/v1/users/me",
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,9 +227,9 @@ requestBody,
|
|||||||
*/
|
*/
|
||||||
public static deleteUserMe(): CancelablePromise<Message> {
|
public static deleteUserMe(): CancelablePromise<Message> {
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'DELETE',
|
method: "DELETE",
|
||||||
url: '/api/v1/users/me',
|
url: "/api/v1/users/me",
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -237,19 +238,19 @@ requestBody,
|
|||||||
* @returns UserPublic Successful Response
|
* @returns UserPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static updateUserMe(data: TDataUpdateUserMe): CancelablePromise<UserPublic> {
|
public static updateUserMe(
|
||||||
const {
|
data: TDataUpdateUserMe,
|
||||||
requestBody,
|
): CancelablePromise<UserPublic> {
|
||||||
} = data;
|
const { requestBody } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'PATCH',
|
method: "PATCH",
|
||||||
url: '/api/v1/users/me',
|
url: "/api/v1/users/me",
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -258,19 +259,19 @@ requestBody,
|
|||||||
* @returns Message Successful Response
|
* @returns Message Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static updatePasswordMe(data: TDataUpdatePasswordMe): CancelablePromise<Message> {
|
public static updatePasswordMe(
|
||||||
const {
|
data: TDataUpdatePasswordMe,
|
||||||
requestBody,
|
): CancelablePromise<Message> {
|
||||||
} = data;
|
const { requestBody } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'PATCH',
|
method: "PATCH",
|
||||||
url: '/api/v1/users/me/password',
|
url: "/api/v1/users/me/password",
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,19 +280,19 @@ requestBody,
|
|||||||
* @returns UserPublic Successful Response
|
* @returns UserPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static registerUser(data: TDataRegisterUser): CancelablePromise<UserPublic> {
|
public static registerUser(
|
||||||
const {
|
data: TDataRegisterUser,
|
||||||
requestBody,
|
): CancelablePromise<UserPublic> {
|
||||||
} = data;
|
const { requestBody } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/users/signup',
|
url: "/api/v1/users/signup",
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -300,20 +301,20 @@ requestBody,
|
|||||||
* @returns UserPublic Successful Response
|
* @returns UserPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static readUserById(data: TDataReadUserById): CancelablePromise<UserPublic> {
|
public static readUserById(
|
||||||
const {
|
data: TDataReadUserById,
|
||||||
userId,
|
): CancelablePromise<UserPublic> {
|
||||||
} = data;
|
const { userId } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
url: '/api/v1/users/{user_id}',
|
url: "/api/v1/users/{user_id}",
|
||||||
path: {
|
path: {
|
||||||
user_id: userId
|
user_id: userId,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -322,23 +323,22 @@ userId,
|
|||||||
* @returns UserPublic Successful Response
|
* @returns UserPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static updateUser(data: TDataUpdateUser): CancelablePromise<UserPublic> {
|
public static updateUser(
|
||||||
const {
|
data: TDataUpdateUser,
|
||||||
requestBody,
|
): CancelablePromise<UserPublic> {
|
||||||
userId,
|
const { requestBody, userId } = data
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'PATCH',
|
method: "PATCH",
|
||||||
url: '/api/v1/users/{user_id}',
|
url: "/api/v1/users/{user_id}",
|
||||||
path: {
|
path: {
|
||||||
user_id: userId
|
user_id: userId,
|
||||||
},
|
},
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -348,30 +348,25 @@ userId,
|
|||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static deleteUser(data: TDataDeleteUser): CancelablePromise<Message> {
|
public static deleteUser(data: TDataDeleteUser): CancelablePromise<Message> {
|
||||||
const {
|
const { userId } = data
|
||||||
userId,
|
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'DELETE',
|
method: "DELETE",
|
||||||
url: '/api/v1/users/{user_id}',
|
url: "/api/v1/users/{user_id}",
|
||||||
path: {
|
path: {
|
||||||
user_id: userId
|
user_id: userId,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TDataTestEmail = {
|
export type TDataTestEmail = {
|
||||||
emailTo: string
|
emailTo: string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UtilsService {
|
export class UtilsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Email
|
* Test Email
|
||||||
* Test emails.
|
* Test emails.
|
||||||
@@ -379,69 +374,60 @@ export class UtilsService {
|
|||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static testEmail(data: TDataTestEmail): CancelablePromise<Message> {
|
public static testEmail(data: TDataTestEmail): CancelablePromise<Message> {
|
||||||
const {
|
const { emailTo } = data
|
||||||
emailTo,
|
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/utils/test-email/',
|
url: "/api/v1/utils/test-email/",
|
||||||
query: {
|
query: {
|
||||||
email_to: emailTo
|
email_to: emailTo,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TDataReadItems = {
|
export type TDataReadItems = {
|
||||||
limit?: number
|
limit?: number
|
||||||
skip?: number
|
skip?: number
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataCreateItem = {
|
export type TDataCreateItem = {
|
||||||
requestBody: ItemCreate
|
requestBody: ItemCreate
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataReadItem = {
|
export type TDataReadItem = {
|
||||||
id: number
|
id: number
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataUpdateItem = {
|
export type TDataUpdateItem = {
|
||||||
id: number
|
id: number
|
||||||
requestBody: ItemUpdate
|
requestBody: ItemUpdate
|
||||||
|
|
||||||
}
|
}
|
||||||
export type TDataDeleteItem = {
|
export type TDataDeleteItem = {
|
||||||
id: number
|
id: number
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ItemsService {
|
export class ItemsService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read Items
|
* Read Items
|
||||||
* Retrieve items.
|
* Retrieve items.
|
||||||
* @returns ItemsPublic Successful Response
|
* @returns ItemsPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static readItems(data: TDataReadItems = {}): CancelablePromise<ItemsPublic> {
|
public static readItems(
|
||||||
const {
|
data: TDataReadItems = {},
|
||||||
limit = 100,
|
): CancelablePromise<ItemsPublic> {
|
||||||
skip = 0,
|
const { limit = 100, skip = 0 } = data
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
url: '/api/v1/items/',
|
url: "/api/v1/items/",
|
||||||
query: {
|
query: {
|
||||||
skip, limit
|
skip,
|
||||||
|
limit,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -450,19 +436,19 @@ skip = 0,
|
|||||||
* @returns ItemPublic Successful Response
|
* @returns ItemPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static createItem(data: TDataCreateItem): CancelablePromise<ItemPublic> {
|
public static createItem(
|
||||||
const {
|
data: TDataCreateItem,
|
||||||
requestBody,
|
): CancelablePromise<ItemPublic> {
|
||||||
} = data;
|
const { requestBody } = data
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'POST',
|
method: "POST",
|
||||||
url: '/api/v1/items/',
|
url: "/api/v1/items/",
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -472,19 +458,17 @@ requestBody,
|
|||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static readItem(data: TDataReadItem): CancelablePromise<ItemPublic> {
|
public static readItem(data: TDataReadItem): CancelablePromise<ItemPublic> {
|
||||||
const {
|
const { id } = data
|
||||||
id,
|
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
url: '/api/v1/items/{id}',
|
url: "/api/v1/items/{id}",
|
||||||
path: {
|
path: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -493,23 +477,22 @@ id,
|
|||||||
* @returns ItemPublic Successful Response
|
* @returns ItemPublic Successful Response
|
||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static updateItem(data: TDataUpdateItem): CancelablePromise<ItemPublic> {
|
public static updateItem(
|
||||||
const {
|
data: TDataUpdateItem,
|
||||||
id,
|
): CancelablePromise<ItemPublic> {
|
||||||
requestBody,
|
const { id, requestBody } = data
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'PUT',
|
method: "PUT",
|
||||||
url: '/api/v1/items/{id}',
|
url: "/api/v1/items/{id}",
|
||||||
path: {
|
path: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
body: requestBody,
|
body: requestBody,
|
||||||
mediaType: 'application/json',
|
mediaType: "application/json",
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -519,19 +502,16 @@ requestBody,
|
|||||||
* @throws ApiError
|
* @throws ApiError
|
||||||
*/
|
*/
|
||||||
public static deleteItem(data: TDataDeleteItem): CancelablePromise<Message> {
|
public static deleteItem(data: TDataDeleteItem): CancelablePromise<Message> {
|
||||||
const {
|
const { id } = data
|
||||||
id,
|
|
||||||
} = data;
|
|
||||||
return __request(OpenAPI, {
|
return __request(OpenAPI, {
|
||||||
method: 'DELETE',
|
method: "DELETE",
|
||||||
url: '/api/v1/items/{id}',
|
url: "/api/v1/items/{id}",
|
||||||
path: {
|
path: {
|
||||||
id
|
id,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
422: `Validation Error`,
|
422: `Validation Error`,
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user