gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated: fix #8655


From: gnunet
Subject: [taler-wallet-core] branch master updated: fix #8655
Date: Fri, 05 Apr 2024 23:11:21 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a commit to branch master
in repository wallet-core.

The following commit(s) were added to refs/heads/master by this push:
     new b95cc1876 fix #8655
b95cc1876 is described below

commit b95cc1876b7263913a3a18df9234fd0122f25cf2
Author: Sebastian <sebasjm@gmail.com>
AuthorDate: Fri Apr 5 18:11:15 2024 -0300

    fix #8655
---
 packages/aml-backoffice-ui/src/hooks/useBackend.ts | 72 +++++-----------------
 .../merchant-backoffice-ui/src/hooks/testing.tsx   | 18 +++++-
 packages/web-util/src/context/api.ts               |  3 +
 packages/web-util/src/tests/mock.ts                |  7 ++-
 packages/web-util/src/tests/swr.ts                 |  1 +
 packages/web-util/src/utils/request.ts             | 43 +++++++++++++
 6 files changed, 83 insertions(+), 61 deletions(-)

diff --git a/packages/aml-backoffice-ui/src/hooks/useBackend.ts 
b/packages/aml-backoffice-ui/src/hooks/useBackend.ts
index 0615c9c99..7b55568c8 100644
--- a/packages/aml-backoffice-ui/src/hooks/useBackend.ts
+++ b/packages/aml-backoffice-ui/src/hooks/useBackend.ts
@@ -1,65 +1,21 @@
-import { canonicalizeBaseUrl } from "@gnu-taler/taler-util";
-import {
-  HttpResponseOk,
-  RequestOptions,
-  useApiContext,
-} from "@gnu-taler/web-util/browser";
-import { useCallback } from "preact/hooks";
-import { uiSettings } from "../settings.js";
+/*
+ This file is part of GNU Taler
+ (C) 2022 Taler Systems S.A.
 
-interface useBackendType {
-  request: <T>(
-    path: string,
-    options?: RequestOptions,
-  ) => Promise<HttpResponseOk<T>>;
-  fetcher: <T>(args: [string, string]) => Promise<HttpResponseOk<T>>;
-  paginatedFetcher: <T>(
-    args: [string, number, number, string],
-  ) => Promise<HttpResponseOk<T>>;
-}
-export function usePublicBackend(): useBackendType {
-  const { request: requestHandler } = useApiContext();
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
 
-  const baseUrl = getInitialBackendBaseURL();
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 
-  const request = useCallback(
-    function requestImpl<T>(
-      path: string,
-      options: RequestOptions = {},
-    ): Promise<HttpResponseOk<T>> {
-      return requestHandler<T>(baseUrl, path, options);
-    },
-    [baseUrl],
-  );
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+ */
+ import { canonicalizeBaseUrl } from "@gnu-taler/taler-util";
+import { uiSettings } from "../settings.js";
 
-  const fetcher = useCallback(
-    function fetcherImpl<T>([endpoint, talerAmlOfficerSignature]: [string, 
string]): Promise<HttpResponseOk<T>> {
-      return requestHandler<T>(baseUrl, endpoint, {
-        talerAmlOfficerSignature
-      });
-    },
-    [baseUrl],
-  );
-  const paginatedFetcher = useCallback(
-    function fetcherImpl<T>([endpoint, page, size, talerAmlOfficerSignature]: [
-      string,
-      number,
-      number,
-      string,
-    ]): Promise<HttpResponseOk<T>> {
-      return requestHandler<T>(baseUrl, endpoint, {
-        params: { page: page || 1, size },
-        talerAmlOfficerSignature,
-      });
-    },
-    [baseUrl],
-  );
-  return {
-    request,
-    fetcher,
-    paginatedFetcher,
-  };
-}
 
 export function getInitialBackendBaseURL(): string {
   const overrideUrl =
diff --git a/packages/merchant-backoffice-ui/src/hooks/testing.tsx 
b/packages/merchant-backoffice-ui/src/hooks/testing.tsx
index 68b0479dd..fc78f6c58 100644
--- a/packages/merchant-backoffice-ui/src/hooks/testing.tsx
+++ b/packages/merchant-backoffice-ui/src/hooks/testing.tsx
@@ -24,9 +24,23 @@ import { ComponentChildren, FunctionalComponent, h, VNode } 
from "preact";
 import { HttpRequestLibrary, HttpRequestOptions, HttpResponse } from 
"@gnu-taler/taler-util/http";
 import { SWRConfig } from "swr";
 import { ApiContextProvider } from "@gnu-taler/web-util/browser";
-import { HttpResponseOk, RequestOptions } from "@gnu-taler/web-util/browser";
 import { TalerBankIntegrationHttpClient, TalerCoreBankHttpClient, 
TalerRevenueHttpClient, TalerWireGatewayHttpClient } from 
"@gnu-taler/taler-util";
 
+interface RequestOptions {
+  method?: "GET" | "POST" | "HEAD",
+  params?: any,
+  token?: string | undefined,
+  data?: any,
+}
+interface HttpResponseOk<T> {
+  ok: true,
+  data: T,
+  loading: boolean,
+  clientError: boolean,
+  serverError: boolean,
+  info: any,
+}
+
 export class ApiMockEnvironment extends MockEnvironment {
   constructor(debug = false) {
     super(debug);
@@ -156,7 +170,7 @@ export class ApiMockEnvironment extends MockEnvironment {
         //       changeToken: () => null,
         //     }}
         //   >
-            <ApiContextProvider value={{ request, bankCore, bankIntegration, 
bankRevenue, bankWire }}>
+            <ApiContextProvider value={{ request : undefined as any, bankCore, 
bankIntegration, bankRevenue, bankWire }}>
               <SC
                 value={{
                   loadingTimeout: 0,
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}`)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]