diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e47d14f..21ea3904 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,9 +20,9 @@ repos: - id: check-toml - id: check-yaml - id: trailing-whitespace - exclude: ^.*\.(lock)$ + exclude: ^web/src/api/generated/|^.*\.(lock)$ - id: end-of-file-fixer - exclude: ^.*\.(lock)$ + exclude: ^web/src/api/generated/|^.*\.(lock)$ - id: mixed-line-ending exclude: ^.*\.(lock)$ - id: detect-private-key diff --git a/web/generate-api-typescript-client-pre-commit.sh b/web/generate-api-typescript-client-pre-commit.sh index 66d7cde2..e2dc8aef 100755 --- a/web/generate-api-typescript-client-pre-commit.sh +++ b/web/generate-api-typescript-client-pre-commit.sh @@ -3,6 +3,8 @@ set -eo PATTERN="api/src/features/*" PATTERN+="|api/src/entities/*" +PATTERN+="|api/src/common/*" +PATTERN+="|api/src/authentication/*" CHANGED_API_FILES=() while read; do diff --git a/web/src/api/generated/core/request.ts b/web/src/api/generated/core/request.ts index 1142d432..1dc6fef4 100644 --- a/web/src/api/generated/core/request.ts +++ b/web/src/api/generated/core/request.ts @@ -1,4 +1,4 @@ -/* generated using openapi-typescript-codegen -- do no edit */ +/* generated using openapi-typescript-codegen -- do not edit */ /* istanbul ignore file */ /* tslint:disable */ /* eslint-disable */ @@ -145,10 +145,13 @@ export const resolve = async (options: ApiRequestOptions, resolver?: T | Reso }; export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions, formData?: FormData): Promise> => { - const token = await resolve(options, config.TOKEN); - const username = await resolve(options, config.USERNAME); - const password = await resolve(options, config.PASSWORD); - const additionalHeaders = await resolve(options, config.HEADERS); + const [token, username, password, additionalHeaders] = await Promise.all([ + resolve(options, config.TOKEN), + resolve(options, config.USERNAME), + resolve(options, config.PASSWORD), + resolve(options, config.HEADERS), + ]); + const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {} const headers = Object.entries({ @@ -172,7 +175,7 @@ export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptio headers['Authorization'] = `Basic ${credentials}`; } - if (options.body) { + if (options.body !== undefined) { if (options.mediaType) { headers['Content-Type'] = options.mediaType; } else if (isBlob(options.body)) { @@ -212,6 +215,7 @@ export const sendRequest = async ( data: body ?? formData, method: options.method, withCredentials: config.WITH_CREDENTIALS, + withXSRFToken: config.CREDENTIALS === 'include' ? config.WITH_CREDENTIALS : false, cancelToken: source.token, }; diff --git a/web/src/api/generated/index.ts b/web/src/api/generated/index.ts index 2b1a3e4d..a30fbd87 100644 --- a/web/src/api/generated/index.ts +++ b/web/src/api/generated/index.ts @@ -12,6 +12,7 @@ export type { AddTodoRequest } from './models/AddTodoRequest'; export type { AddTodoResponse } from './models/AddTodoResponse'; export type { DeleteTodoByIdResponse } from './models/DeleteTodoByIdResponse'; export type { ErrorResponse } from './models/ErrorResponse'; +export type { GetTodoAllResponse } from './models/GetTodoAllResponse'; export type { GetTodoByIdResponse } from './models/GetTodoByIdResponse'; export type { UpdateTodoRequest } from './models/UpdateTodoRequest'; export type { UpdateTodoResponse } from './models/UpdateTodoResponse'; diff --git a/web/src/api/generated/models/AddTodoRequest.ts b/web/src/api/generated/models/AddTodoRequest.ts index 6d2d4daa..dbe4b7af 100644 --- a/web/src/api/generated/models/AddTodoRequest.ts +++ b/web/src/api/generated/models/AddTodoRequest.ts @@ -6,3 +6,4 @@ export type AddTodoRequest = { title: string; }; + diff --git a/web/src/api/generated/models/AddTodoResponse.ts b/web/src/api/generated/models/AddTodoResponse.ts index 82863365..e1059771 100644 --- a/web/src/api/generated/models/AddTodoResponse.ts +++ b/web/src/api/generated/models/AddTodoResponse.ts @@ -8,3 +8,4 @@ export type AddTodoResponse = { title: string; is_completed: boolean; }; + diff --git a/web/src/api/generated/models/DeleteTodoByIdResponse.ts b/web/src/api/generated/models/DeleteTodoByIdResponse.ts index 3abeaf51..e2a8ce22 100644 --- a/web/src/api/generated/models/DeleteTodoByIdResponse.ts +++ b/web/src/api/generated/models/DeleteTodoByIdResponse.ts @@ -6,3 +6,4 @@ export type DeleteTodoByIdResponse = { success: boolean; }; + diff --git a/web/src/api/generated/models/ErrorResponse.ts b/web/src/api/generated/models/ErrorResponse.ts index 309e188c..7adcf7d0 100644 --- a/web/src/api/generated/models/ErrorResponse.ts +++ b/web/src/api/generated/models/ErrorResponse.ts @@ -10,3 +10,4 @@ export type ErrorResponse = { debug?: string; extra?: (Record | null); }; + diff --git a/web/src/api/generated/models/GetTodoAllResponse.ts b/web/src/api/generated/models/GetTodoAllResponse.ts new file mode 100644 index 00000000..0840c259 --- /dev/null +++ b/web/src/api/generated/models/GetTodoAllResponse.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type GetTodoAllResponse = { + id: string; + title: string; + is_completed: boolean; +}; + diff --git a/web/src/api/generated/models/GetTodoByIdResponse.ts b/web/src/api/generated/models/GetTodoByIdResponse.ts index 3c1b3e35..f1cd8bcb 100644 --- a/web/src/api/generated/models/GetTodoByIdResponse.ts +++ b/web/src/api/generated/models/GetTodoByIdResponse.ts @@ -8,3 +8,4 @@ export type GetTodoByIdResponse = { title: string; is_completed: boolean; }; + diff --git a/web/src/api/generated/models/UpdateTodoRequest.ts b/web/src/api/generated/models/UpdateTodoRequest.ts index a74763c6..f3e3c6cf 100644 --- a/web/src/api/generated/models/UpdateTodoRequest.ts +++ b/web/src/api/generated/models/UpdateTodoRequest.ts @@ -7,3 +7,4 @@ export type UpdateTodoRequest = { title?: string; is_completed: boolean; }; + diff --git a/web/src/api/generated/models/UpdateTodoResponse.ts b/web/src/api/generated/models/UpdateTodoResponse.ts index 03a633e3..8b203d0f 100644 --- a/web/src/api/generated/models/UpdateTodoResponse.ts +++ b/web/src/api/generated/models/UpdateTodoResponse.ts @@ -6,3 +6,4 @@ export type UpdateTodoResponse = { success: boolean; }; + diff --git a/web/src/api/generated/models/User.ts b/web/src/api/generated/models/User.ts index d10eae66..04f82ef0 100644 --- a/web/src/api/generated/models/User.ts +++ b/web/src/api/generated/models/User.ts @@ -12,3 +12,4 @@ export type User = { roles: Array; scope: AccessLevel; }; + diff --git a/web/src/api/generated/services/TodosService.ts b/web/src/api/generated/services/TodosService.ts index 3251773a..532f97e3 100644 --- a/web/src/api/generated/services/TodosService.ts +++ b/web/src/api/generated/services/TodosService.ts @@ -5,6 +5,7 @@ import type { AddTodoRequest } from '../models/AddTodoRequest'; import type { AddTodoResponse } from '../models/AddTodoResponse'; import type { DeleteTodoByIdResponse } from '../models/DeleteTodoByIdResponse'; +import type { GetTodoAllResponse } from '../models/GetTodoAllResponse'; import type { GetTodoByIdResponse } from '../models/GetTodoByIdResponse'; import type { UpdateTodoRequest } from '../models/UpdateTodoRequest'; import type { UpdateTodoResponse } from '../models/UpdateTodoResponse'; @@ -17,10 +18,10 @@ export class TodosService { /** * Get Todo All - * @returns any Successful Response + * @returns GetTodoAllResponse Successful Response * @throws ApiError */ - public static getAll(): CancelablePromise { + public static getAll(): CancelablePromise> { return __request(OpenAPI, { method: 'GET', url: '/todos',