diff options
Diffstat (limited to 'packages/taler-util')
-rw-r--r-- | packages/taler-util/src/http-common.ts | 3 | ||||
-rw-r--r-- | packages/taler-util/src/notifications.ts | 73 | ||||
-rw-r--r-- | packages/taler-util/src/observability.ts | 25 | ||||
-rw-r--r-- | packages/taler-util/src/taler-types.ts | 46 |
4 files changed, 94 insertions, 53 deletions
diff --git a/packages/taler-util/src/http-common.ts b/packages/taler-util/src/http-common.ts index 3973e66fb..885bd32e6 100644 --- a/packages/taler-util/src/http-common.ts +++ b/packages/taler-util/src/http-common.ts @@ -26,6 +26,7 @@ import { stringToBytes, } from "./index.js"; import { Logger } from "./logging.js"; +import { ObservabilityContext } from "./observability.js"; import { TalerErrorCode } from "./taler-error-codes.js"; import { AbsoluteTime, Duration } from "./time.js"; import { TalerErrorDetail } from "./wallet-types.js"; @@ -71,6 +72,8 @@ export interface HttpRequestOptions { * Same semantics as WHATWG fetch. */ redirect?: "follow" | "error" | "manual"; + + //observabilityContext?: ObservabilityContext; } /** diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts index d84d3706d..f4dbef8b6 100644 --- a/packages/taler-util/src/notifications.ts +++ b/packages/taler-util/src/notifications.ts @@ -15,16 +15,15 @@ */ /** - * Type and schema definitions for notifications from the wallet to clients - * of the wallet. + * @fileoverview Type and schema definitions for notifications from the + * wallet to clients of the wallet. */ /** * Imports. */ -import { WithdrawalOperationStatus } from "./index.node.js"; import { TransactionState } from "./transactions-types.js"; -import { ExchangeEntryState, TalerErrorDetail } from "./wallet-types.js"; +import { ExchangeEntryState } from "./wallet-types.js"; export enum NotificationType { BalanceChange = "balance-change", @@ -33,6 +32,10 @@ export enum NotificationType { TransactionStateTransition = "transaction-state-transition", ExchangeStateTransition = "exchange-state-transition", WithdrawalOperationTransition = "withdrawal-state-transition", + TaskProgress = "task-progress", + RequestProgress = "request-progress", + RequestOnTaskDependency = "request-on-task-dependency", + TaskOnTaskDependency = "task-on-task-dependency", } export interface ErrorInfoSummary { @@ -97,26 +100,58 @@ export interface BalanceChangeNotification { hintTransactionId: string; } -export interface BackupOperationErrorNotification { - type: NotificationType.BackupOperationError; - error: TalerErrorDetail; +export interface TaskProgressNotification { + type: NotificationType.TaskProgress; + taskId: string; } -export interface PendingOperationProcessedNotification { - type: NotificationType.PendingOperationProcessed; - id: string; - taskResultType: string; +export interface RequestProgressNotification { + type: NotificationType.RequestProgress; + requestId: string; } -export interface WithdrawalOperationTransitionNotification { - type: NotificationType.WithdrawalOperationTransition; - operationId: string; - state: WithdrawalOperationStatus; + +export interface RequestOnTaskDependencyNotification { + type: NotificationType.RequestOnTaskDependency; + parentTaskId: string; + childTaskId: string; +} + +export interface TaskOnTaskDependencyNotification { + type: NotificationType.TaskOnTaskDependency; + parentRequestId: string; + childTaskId: string; } +export type ObservabilityEvent = + | { + type: "start-http-fetch"; + url: string; + } + | { + type: "finish-http-fetch"; + url: string; + status: number; + } + | { + type: "start-db-query"; + name: string; + location: string; + } + | { + type: "finish-db-query"; + name: string; + location: string; + } + | { + type: "task-processed"; + taskResultType: string; + }; + export type WalletNotification = | BalanceChangeNotification - | BackupOperationErrorNotification | ExchangeStateTransitionNotification - | PendingOperationProcessedNotification - | WithdrawalOperationTransitionNotification - | TransactionStateTransitionNotification; + | TransactionStateTransitionNotification + | TaskProgressNotification + | RequestProgressNotification + | RequestOnTaskDependencyNotification + | TaskOnTaskDependencyNotification; diff --git a/packages/taler-util/src/observability.ts b/packages/taler-util/src/observability.ts new file mode 100644 index 000000000..fce265040 --- /dev/null +++ b/packages/taler-util/src/observability.ts @@ -0,0 +1,25 @@ +/* + This file is part of GNU Taler + (C) 2019-2024 Taler Systems S.A. + + 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. + + 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. + + 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 { ObservabilityEvent } from "./index.js"; + +/** + * Observability sink can be passed into various operations (HTTP requests, DB access) + * to do structured logging within a particular context (task, request, ...). + */ +export interface ObservabilityContext { + observe(evt: ObservabilityEvent): void; +} diff --git a/packages/taler-util/src/taler-types.ts b/packages/taler-util/src/taler-types.ts index fe8f47e30..b5932aba6 100644 --- a/packages/taler-util/src/taler-types.ts +++ b/packages/taler-util/src/taler-types.ts @@ -58,7 +58,7 @@ import { /** * Denomination as found in the /keys response from the exchange. */ -export class ExchangeDenomination { +export interface ExchangeDenomination { /** * Value of one coin of the denomination. */ @@ -121,7 +121,7 @@ export class ExchangeDenomination { /** * Signature by the auditor that a particular denomination key is audited. */ -export class AuditorDenomSig { +export interface AuditorDenomSig { /** * Denomination public key's hash. */ @@ -136,7 +136,7 @@ export class AuditorDenomSig { /** * Auditor information as given by the exchange in /keys. */ -export class ExchangeAuditor { +export interface ExchangeAuditor { /** * Auditor's public key. */ @@ -702,7 +702,7 @@ export interface MerchantTipResponseV2 { * Element of the payback list that the * exchange gives us in /keys. */ -export class Recoup { +export interface Recoup { /** * The hash of the denomination public key for which the payback is offered. */ @@ -712,7 +712,7 @@ export class Recoup { /** * Structure of one exchange signing key in the /keys response. */ -export class ExchangeSignKeyJson { +export interface ExchangeSignKeyJson { stamp_start: TalerProtocolTimestamp; stamp_expire: TalerProtocolTimestamp; stamp_end: TalerProtocolTimestamp; @@ -723,7 +723,7 @@ export class ExchangeSignKeyJson { /** * Structure that the exchange gives us in /keys. */ -export class ExchangeKeysJson { +export interface ExchangeKeysJson { /** * Canonical, public base URL of the exchange. */ @@ -917,7 +917,7 @@ export interface GlobalFees { /** * Wire fees as announced by the exchange. */ -export class WireFeesJson { +export interface WireFeesJson { /** * Cost of a wire transfer. */ @@ -947,7 +947,7 @@ export class WireFeesJson { /** * Proposal returned from the contract URL. */ -export class Proposal { +export interface Proposal { /** * Contract terms for the propoal. * Raw, un-decoded JSON object. @@ -964,7 +964,7 @@ export class Proposal { /** * Response from the internal merchant API. */ -export class CheckPaymentResponse { +export interface CheckPaymentResponse { order_status: string; refunded: boolean | undefined; refunded_amount: string | undefined; @@ -976,7 +976,7 @@ export class CheckPaymentResponse { /** * Response from the bank. */ -export class WithdrawOperationStatusResponse { +export interface WithdrawOperationStatusResponse { status: "selected" | "aborted" | "confirmed" | "pending"; selection_done: boolean; @@ -996,19 +996,6 @@ export class WithdrawOperationStatusResponse { wire_types: string[]; } -/** - * Response from the merchant. - */ -export class RewardPickupGetResponse { - reward_amount: string; - - exchange_url: string; - - next_url?: string; - - expiration: TalerProtocolTimestamp; -} - export enum DenomKeyType { Rsa = "RSA", ClauseSchnorr = "CS", @@ -1050,11 +1037,11 @@ export const codecForBlindedDenominationSignature = () => .alternative(DenomKeyType.Rsa, codecForRsaBlindedDenominationSignature()) .build("BlindedDenominationSignature"); -export class ExchangeWithdrawResponse { +export interface ExchangeWithdrawResponse { ev_sig: BlindedDenominationSignature; } -export class ExchangeWithdrawBatchResponse { +export interface ExchangeWithdrawBatchResponse { ev_sigs: ExchangeWithdrawResponse[]; } @@ -1594,15 +1581,6 @@ export const codecForWithdrawOperationStatusResponse = .property("wire_types", codecForList(codecForString())) .build("WithdrawOperationStatusResponse"); -export const codecForRewardPickupGetResponse = - (): Codec<RewardPickupGetResponse> => - buildCodecForObject<RewardPickupGetResponse>() - .property("reward_amount", codecForString()) - .property("exchange_url", codecForString()) - .property("next_url", codecOptional(codecForString())) - .property("expiration", codecForTimestamp) - .build("TipPickupGetResponse"); - export const codecForRecoupConfirmation = (): Codec<RecoupConfirmation> => buildCodecForObject<RecoupConfirmation>() .property("reserve_pub", codecOptional(codecForString())) |