diff options
author | Sebastian <sebasjm@gmail.com> | 2024-04-05 18:11:15 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-04-05 18:11:15 -0300 |
commit | b95cc1876b7263913a3a18df9234fd0122f25cf2 (patch) | |
tree | a349b631349aa342d705c6a4068eb91d0847be0b /packages/web-util | |
parent | cc38998803141c42511e878441a5a8b15a387436 (diff) | |
download | wallet-core-b95cc1876b7263913a3a18df9234fd0122f25cf2.tar.xz |
fix #8655
Diffstat (limited to 'packages/web-util')
-rw-r--r-- | packages/web-util/src/context/api.ts | 3 | ||||
-rw-r--r-- | packages/web-util/src/tests/mock.ts | 7 | ||||
-rw-r--r-- | packages/web-util/src/tests/swr.ts | 1 | ||||
-rw-r--r-- | packages/web-util/src/utils/request.ts | 43 |
4 files changed, 53 insertions, 1 deletions
diff --git a/packages/web-util/src/context/api.ts b/packages/web-util/src/context/api.ts index 7923532b6..c1eaa37f8 100644 --- a/packages/web-util/src/context/api.ts +++ b/packages/web-util/src/context/api.ts @@ -25,6 +25,9 @@ import { useContext } from "preact/hooks"; import { defaultRequestHandler } from "../utils/request.js"; interface Type { + /** + * @deprecated this show not be used + */ request: typeof defaultRequestHandler; bankCore: TalerCoreBankHttpClient, bankIntegration: TalerBankIntegrationHttpClient, diff --git a/packages/web-util/src/tests/mock.ts b/packages/web-util/src/tests/mock.ts index f4eb0e7aa..d09e8b4a6 100644 --- a/packages/web-util/src/tests/mock.ts +++ b/packages/web-util/src/tests/mock.ts @@ -15,7 +15,6 @@ */ import { Logger } from "@gnu-taler/taler-util"; -import { deprecate } from "util"; type HttpMethod = | "get" @@ -39,6 +38,9 @@ type HttpMethod = | "unlink" | "UNLINK"; +/** + * @deprecated do not use it, it will be removed + */ export type Query<Req, Res> = { method: HttpMethod; url: string; @@ -69,6 +71,9 @@ type MockedResponse = { expectedQuery?: ExpectationValues; }; +/** + * @deprecated do not use it, it will be removed + */ export abstract class MockEnvironment { expectations: Array<ExpectationValues> = []; queriesMade: Array<ExpectationValues> = []; diff --git a/packages/web-util/src/tests/swr.ts b/packages/web-util/src/tests/swr.ts index 903cd48d8..d5f4341f3 100644 --- a/packages/web-util/src/tests/swr.ts +++ b/packages/web-util/src/tests/swr.ts @@ -28,6 +28,7 @@ const logger = new Logger("tests/swr.ts"); * * buildTestingContext() will return a testing context * + * @deprecated do not use it, it will be removed */ export class SwrMockEnvironment extends MockEnvironment { constructor(debug = false) { diff --git a/packages/web-util/src/utils/request.ts b/packages/web-util/src/utils/request.ts index 70f943540..23d3af468 100644 --- a/packages/web-util/src/utils/request.ts +++ b/packages/web-util/src/utils/request.ts @@ -17,6 +17,9 @@ import { HttpStatusCode } from "@gnu-taler/taler-util"; import { base64encode } from "./base64.js"; +/** + * @deprecated do not use it, it will be removed + */ export enum ErrorType { CLIENT, SERVER, @@ -32,6 +35,7 @@ export enum ErrorType { * @param baseUrl URL where the service is located * @param endpoint endpoint of the service to be called * @param options auth, method and params + * @deprecated do not use it, it will be removed * @returns */ export async function defaultRequestHandler<T>( @@ -189,16 +193,25 @@ export async function defaultRequestHandler<T>( } } +/** + * @deprecated do not use it, it will be removed + */ export type HttpResponse<T, ErrorDetail> = | HttpResponseOk<T> | HttpResponseLoading<T> | HttpError<ErrorDetail>; +/** + * @deprecated do not use it, it will be removed + */ export type HttpResponsePaginated<T, ErrorDetail> = | HttpResponseOkPaginated<T> | HttpResponseLoading<T> | HttpError<ErrorDetail>; +/** + * @deprecated do not use it, it will be removed + */ export interface RequestInfo { url: string; hasToken: boolean; @@ -215,6 +228,9 @@ interface HttpResponseLoading<T> { data?: T; } +/** + * @deprecated do not use it, it will be removed + */ export interface HttpResponseOk<T> { ok: true; loading?: false; @@ -225,8 +241,14 @@ export interface HttpResponseOk<T> { info?: RequestInfo; } +/** + * @deprecated do not use it, it will be removed + */ export type HttpResponseOkPaginated<T> = HttpResponseOk<T> & WithPagination; +/** + * @deprecated do not use it, it will be removed + */ export interface WithPagination { loadMore: () => void; loadMorePrev: () => void; @@ -234,6 +256,9 @@ export interface WithPagination { isReachingStart?: boolean; } +/** + * @deprecated do not use it, it will be removed + */ export type HttpError<ErrorDetail> = | HttpRequestTimeoutError | HttpResponseClientError<ErrorDetail> @@ -241,6 +266,9 @@ export type HttpError<ErrorDetail> = | HttpResponseUnreadableError | HttpResponseUnexpectedError; +/** + * @deprecated do not use it, it will be removed + */ export interface HttpResponseServerError<ErrorDetail> { ok?: false; loading?: false; @@ -292,6 +320,9 @@ interface HttpResponseUnreadableError { body: string; message: string; } +/** + * @deprecated do not use it, it will be removed + */ export class RequestError<ErrorDetail> extends Error { /** * @deprecated use cause @@ -307,6 +338,9 @@ export class RequestError<ErrorDetail> extends Error { type Methods = "GET" | "POST" | "PATCH" | "DELETE" | "PUT"; +/** + * @deprecated do not use it, it will be removed + */ export interface RequestOptions { method?: Methods; token?: string; @@ -323,6 +357,9 @@ export interface RequestOptions { talerAmlOfficerSignature?: string; } +/** + * @deprecated do not use it, it will be removed + */ async function buildRequestOk<T>( response: Response, url: string, @@ -345,6 +382,9 @@ async function buildRequestOk<T>( }; } +/** + * @deprecated do not use it, it will be removed + */ export function buildRequestFailed<ErrorDetail>( url: string, dataTxt: string, @@ -424,6 +464,9 @@ export function buildRequestFailed<ErrorDetail>( } } +/** + * @deprecated do not use it, it will be removed + */ function validateURL(baseUrl: string, endpoint: string): URL | undefined { try { return new URL(`${baseUrl}${endpoint}`) |