Skip to content
LogoLogo

Discovery types

Typed operations and payment offers

Describes the public types returned by listOperations.

Usage

example.ts
import type { , ,  } from 'mppx/discovery'
 
const :  = 'post'
const :  = { : '2000', : 'charge', : 'tempo' }
const :  = {
  ,
  : [],
  : '/v1/forecast',
  : { : { : { : 'string' } }, : 'object' },
  : 'Forecast',
}
 
.(.[0]?.)
2000

Import these types directly from mppx/discovery; they have no runtime validation of their own.

Operation

// Shape only; OperationMethod and PaymentOffer are described below.
type Operation = {
  method: OperationMethod
  offers: PaymentOffer[]
  path: string
  requestSchema: Record<string, unknown> | boolean | undefined
  summary: string | undefined
}
FieldTypeDescription
methodOperationMethodLowercase HTTP method
offersPaymentOffer[]Ordered payment offers; empty without x-payment-info
pathstringPath relative to the document's server
requestSchemaRecord<string, unknown> | boolean | undefinedJSON request schema, when available; nested references still point into the source document
summarystring | undefinedOpenAPI operation summary, when present

requestSchema and summary are required properties whose values can be undefined. See listOperations for resolution and extraction rules.

OperationMethod

type OperationMethod =
  | 'delete'
  | 'get'
  | 'head'
  | 'options'
  | 'patch'
  | 'post'
  | 'put'
  | 'trace'

The HTTP methods supported in OpenAPI path items.

PaymentOffer

One offer from x-payment-info.offers, also used by the normalized PaymentInfo output.

type PaymentOffer = {
  amount?: string | null | undefined
  currency?: string | undefined
  description?: string | undefined
  intent?: string | undefined
  method?: string | undefined
  [key: string]: unknown
}
FieldTypeDescription
amount (optional)string | nullBase-unit amount; a non-negative integer string without leading zeros except "0", or null
currency (optional)stringCurrency code or token address
description (optional)stringHuman-readable payment description
intent (optional)stringPayment intent, such as charge or session
method (optional)stringPayment method identifier, such as tempo or stripe

All fields are optional because discovery is advisory. Unknown offer fields remain available as unknown. Don't infer a zero price from a missing or null amount; use the runtime 402 Challenge for payment terms.