From d23d305b4139ec122a6bae4fcf578ec3a3c0eaf5 Mon Sep 17 00:00:00 2001 From: Patrick Bennett Date: Fri, 28 Aug 2026 00:35:13 -0400 Subject: [PATCH] refactor(api): regenerate the OpenAPI client on openapi-ts 0.99 The generator was bumped to 0.99 with #26 but its output was left at 0.64, so this is the regeneration that bump deferred. openapi-ts no longer consumes a separate client package: it emits its own fetch runtime into src/api/client and src/api/core. Nothing imports @hey-api/client-fetch any more, so it is dropped from dependencies and from the rollup externals. The published package now has one runtime dependency, @algorandfoundation/algokit-utils, plus the algosdk peer. Operation names now track the spec's operationIds verbatim - nfd_getLookup rather than nfdGetLookup. Only src/api-client.ts imports them and nothing generated is re-exported from src/index.ts, so the renames are internal. The public type surface is unchanged. src/types.ts pulls four types out of the generated output - NfdRecord, NfdSearchV2Response, VerifyConfirmResponseBody and VerifyRequestResponseBody - and all four are identical once doc comments are stripped. 0.99 emits the shared schema's description in place of the property's, which changes hover text and nothing else. Three supporting fixes, each of which blocked the regeneration: - openapi3.yaml moved out of src/api to sit beside openapi-ts.config.ts. 0.99 cleans its output directory before every run, so the spec was deleted by the generator that reads it, and generate:openapi failed on the second run with "Input file not found". It is gitignored, matching the fact that it is fetched from the private nfd-backend repo and was never committed. - The eslint and prettier ignores matched src/api/*.gen.ts, which no longer covers client/ and core/. The eslint post-processor failed the generate step on explicit-function-return-type in the emitted runtime, and the package-level prettier ignore silenced openapi-ts's own formatting pass, so the first successful run landed unformatted. eslint now skips src/api entirely and the generator formats its own output. - output.format and output.lint are deprecated in favour of postProcess. eslint is deliberately not in the list. Verified against the live API rather than the mocks, since the HTTP client underneath changed: search, resolve, and reverse lookup all return real data, including the repeated-address query serialisation and the 404 path that reverseLookup swallows per chunk. pnpm run ci passes: 246 tests, SDK build, all ten example builds. --- .gitignore | 5 +- .prettierignore | 3 + CLAUDE.md | 8 +- packages/sdk/.prettierignore | 8 +- packages/sdk/eslint.config.js | 7 +- packages/sdk/openapi-ts.config.ts | 7 +- packages/sdk/package.json | 3 +- packages/sdk/scripts/fetch-openapi.ts | 4 +- packages/sdk/src/api-client.ts | 24 +- packages/sdk/src/api/client.gen.ts | 21 +- packages/sdk/src/api/client/client.gen.ts | 299 ++++ packages/sdk/src/api/client/index.ts | 27 + packages/sdk/src/api/client/types.gen.ts | 238 ++++ packages/sdk/src/api/client/utils.gen.ts | 332 +++++ packages/sdk/src/api/core/auth.gen.ts | 48 + .../sdk/src/api/core/bodySerializer.gen.ts | 96 ++ packages/sdk/src/api/core/params.gen.ts | 186 +++ .../sdk/src/api/core/pathSerializer.gen.ts | 186 +++ .../src/api/core/queryKeySerializer.gen.ts | 134 ++ .../sdk/src/api/core/serverSentEvents.gen.ts | 265 ++++ packages/sdk/src/api/core/types.gen.ts | 126 ++ packages/sdk/src/api/core/utils.gen.ts | 146 ++ packages/sdk/src/api/index.ts | 385 +++++- packages/sdk/src/api/sdk.gen.ts | 1053 ++++++++------- packages/sdk/src/api/types.gen.ts | 1203 +++++++++++++++-- packages/sdk/vite.config.ts | 6 +- pnpm-lock.yaml | 9 - 27 files changed, 4116 insertions(+), 713 deletions(-) create mode 100644 packages/sdk/src/api/client/client.gen.ts create mode 100644 packages/sdk/src/api/client/index.ts create mode 100644 packages/sdk/src/api/client/types.gen.ts create mode 100644 packages/sdk/src/api/client/utils.gen.ts create mode 100644 packages/sdk/src/api/core/auth.gen.ts create mode 100644 packages/sdk/src/api/core/bodySerializer.gen.ts create mode 100644 packages/sdk/src/api/core/params.gen.ts create mode 100644 packages/sdk/src/api/core/pathSerializer.gen.ts create mode 100644 packages/sdk/src/api/core/queryKeySerializer.gen.ts create mode 100644 packages/sdk/src/api/core/serverSentEvents.gen.ts create mode 100644 packages/sdk/src/api/core/types.gen.ts create mode 100644 packages/sdk/src/api/core/utils.gen.ts diff --git a/.gitignore b/.gitignore index 8259a15..5fe2938 100644 --- a/.gitignore +++ b/.gitignore @@ -34,5 +34,8 @@ coverage/ Thumbs.db # Include spec files -!src/openapi3.yaml !src/contracts/*.arc56.json + +# Fetched by `pnpm fetch:openapi` from the private nfd-backend repo, so it is +# not reproducible from this repo alone and is not committed. +packages/sdk/openapi3.yaml diff --git a/.prettierignore b/.prettierignore index 275f664..bf8365d 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,6 +10,9 @@ build # Generated files pnpm-lock.yaml **/openapi3.yaml +# The whole directory: openapi-ts emits its own fetch runtime into +# src/api/client and src/api/core, and not every file there ends in .gen.ts. +packages/sdk/src/api/ **/*.gen.ts **/*.arc56.json **/contracts/*Client.ts diff --git a/CLAUDE.md b/CLAUDE.md index 138c6f4..a25132b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,13 +46,19 @@ pnpm --filter @txnlab/nfd-sdk exec vitest run tests/utils/nfd.test.ts The SDK has auto-generated code from two sources: -1. **OpenAPI client** (`src/api/*.gen.ts`) — generated from `src/api/openapi3.yaml` via `@hey-api/client-fetch` +1. **OpenAPI client** (all of `src/api/`) — generated by `@hey-api/openapi-ts` from `packages/sdk/openapi3.yaml` 2. **Algorand contract clients** (`src/contracts/NFD*Client.ts`) — generated from ARC-56 JSON specs in `src/contracts/minimal/` Regenerate all: `pnpm --filter @txnlab/nfd-sdk generate` **Do not hand-edit generated files.** The contract client files (`NFDInstanceClient.ts`, `NFDRegistryClient.ts`) are excluded from tsconfig compilation and are very large (~150KB each). +Three things about the OpenAPI half are easy to get wrong: + +- **The whole of `src/api/` is generated, not just `*.gen.ts`.** openapi-ts vendors its own fetch runtime into `src/api/client/` and `src/api/core/`, so the SDK has no `@hey-api/client-fetch` dependency any more. `eslint.config.js` and the root `.prettierignore` exclude the directory; a glob that only matches `src/api/*.gen.ts` misses two thirds of the output. +- **`openapi3.yaml` lives beside `openapi-ts.config.ts`, not inside `src/api/`.** openapi-ts cleans its output directory before every run, so a spec kept in there is deleted by the generator that reads it. It is fetched by `pnpm fetch:openapi` from the private `TxnLab/nfd-backend` repo (needs `GITHUB_TOKEN`), and is gitignored — regenerating is not reproducible from this repo alone. +- **Operation names track the spec's `operationId`s verbatim** (`nfd_getLookup`, not `nfdGetLookup`). Only `src/api-client.ts` imports them; nothing generated is re-exported from `src/index.ts`, so renames there are internal. + ## Architecture ### Client & Module Pattern diff --git a/packages/sdk/.prettierignore b/packages/sdk/.prettierignore index 11354e9..3d79e18 100644 --- a/packages/sdk/.prettierignore +++ b/packages/sdk/.prettierignore @@ -4,7 +4,11 @@ CHANGELOG.md # directory, so `pnpm format` (which runs in this package) never sees the root # .prettierignore — without these it rewrites the generated contract clients # that `pnpm format:check` correctly skips. -src/api/openapi3.yaml -src/api/*.gen.ts +openapi3.yaml src/contracts/**/*.arc56.json src/contracts/*Client.ts + +# src/api/**.gen.ts is deliberately NOT listed. openapi-ts formats its own +# output by running prettier from this directory, so an ignore entry here +# silences that step and the client lands unformatted. The root +# .prettierignore still excludes it from `pnpm format:check`. diff --git a/packages/sdk/eslint.config.js b/packages/sdk/eslint.config.js index 675bd70..a171bf1 100644 --- a/packages/sdk/eslint.config.js +++ b/packages/sdk/eslint.config.js @@ -3,10 +3,15 @@ import baseConfig from '../../eslint.config.js' export default tseslint.config( ...baseConfig, + { + // Generated OpenAPI client. openapi-ts >= 0.7x emits its own fetch runtime + // into src/api/client and src/api/core, so the old src/api/*.gen.ts glob no + // longer covers the output. + ignores: ['src/api/**'], + }, { // Source files files: ['src/**/*.ts'], - ignores: ['src/api/*.gen.ts'], languageOptions: { parserOptions: { project: './tsconfig.json', diff --git a/packages/sdk/openapi-ts.config.ts b/packages/sdk/openapi-ts.config.ts index ada5656..d0babb2 100644 --- a/packages/sdk/openapi-ts.config.ts +++ b/packages/sdk/openapi-ts.config.ts @@ -1,11 +1,12 @@ import { defineConfig } from '@hey-api/openapi-ts' export default defineConfig({ - input: './src/api/openapi3.yaml', + input: './openapi3.yaml', output: { - format: 'prettier', - lint: 'eslint', path: './src/api', + // eslint is not in the list: the generated client is excluded from linting + // (see eslint.config.js), so running it here only fails the generate step. + postProcess: ['prettier'], }, plugins: ['@hey-api/client-fetch'], }) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 127f12a..9faaa8c 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -77,8 +77,7 @@ "generate": "pnpm fetch:specs && pnpm generate:clients && pnpm generate:openapi" }, "dependencies": { - "@algorandfoundation/algokit-utils": "^8.2.2", - "@hey-api/client-fetch": "^0.8.4" + "@algorandfoundation/algokit-utils": "^8.2.2" }, "peerDependencies": { "algosdk": "^3.6.0" diff --git a/packages/sdk/scripts/fetch-openapi.ts b/packages/sdk/scripts/fetch-openapi.ts index 7db2cda..431699f 100644 --- a/packages/sdk/scripts/fetch-openapi.ts +++ b/packages/sdk/scripts/fetch-openapi.ts @@ -15,7 +15,9 @@ config({ path: packageEnv }) const GITHUB_TOKEN = process.env.GITHUB_TOKEN const SPEC_URL = 'https://raw.githubusercontent.com/TxnLab/nfd-backend/main/goasvcs/pubapi/gen/http/openapi3.yaml' -const OUTPUT_PATH = resolve(__dirname, '../src/api/openapi3.yaml') +// Deliberately outside src/api: openapi-ts cleans its output directory before +// every run, so a spec kept in there is deleted by the generator it feeds. +const OUTPUT_PATH = resolve(__dirname, '../openapi3.yaml') async function fetchOpenApiSpec() { if (!GITHUB_TOKEN) { diff --git a/packages/sdk/src/api-client.ts b/packages/sdk/src/api-client.ts index d7c19e2..fe52596 100644 --- a/packages/sdk/src/api-client.ts +++ b/packages/sdk/src/api-client.ts @@ -1,11 +1,11 @@ import { client } from './api/client.gen' import { - nfdGetLookup, - nfdGetNfd, - nfdSearchV2, - nfdSuggest, - nfdVerifyConfirm, - nfdVerifyRequest, + nfd_getLookup, + nfd_getNfd, + nfd_searchV2, + nfd_suggest, + nfd_verifyConfirm, + nfd_verifyRequest, } from './api/sdk.gen' import { NfdApiBaseUrl, NfdRegistryId } from './constants' import { chunkArray } from './utils/internal/array' @@ -93,7 +93,7 @@ export class NfdApiClient { // Add cache parameter if needed const params = this._getCacheParam(options.nocache) - const response = await nfdGetNfd({ + const response = await nfd_getNfd({ client: this._client, query: { view: options.view, @@ -138,7 +138,7 @@ export class NfdApiClient { // Make parallel requests for each chunk const responses = await Promise.all( addressChunks.map((chunk) => - nfdGetLookup({ + nfd_getLookup({ client: this._client, query: { address: chunk, @@ -184,7 +184,7 @@ export class NfdApiClient { // Add cache parameter if needed const params = this._getCacheParam(options.nocache) - const response = await nfdSearchV2({ + const response = await nfd_searchV2({ client: this._client, query: { name: options.name, @@ -231,7 +231,7 @@ export class NfdApiClient { * @returns Array of suggested NFD records */ public async suggest(name: string, options: SuggestOptions): Promise { - const response = await nfdSuggest({ + const response = await nfd_suggest({ client: this._client, path: { name }, query: { @@ -257,7 +257,7 @@ export class NfdApiClient { sender: string, field: VerifyField, ): Promise { - const response = await nfdVerifyRequest({ + const response = await nfd_verifyRequest({ client: this._client, body: { name, @@ -280,7 +280,7 @@ export class NfdApiClient { id: string, challenge?: string, ): Promise { - const response = await nfdVerifyConfirm({ + const response = await nfd_verifyConfirm({ client: this._client, path: { id }, body: { diff --git a/packages/sdk/src/api/client.gen.ts b/packages/sdk/src/api/client.gen.ts index d0c46f3..4c476cc 100644 --- a/packages/sdk/src/api/client.gen.ts +++ b/packages/sdk/src/api/client.gen.ts @@ -1,13 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts import { + type Client, + type ClientOptions, type Config, - type ClientOptions as DefaultClientOptions, createClient, createConfig, -} from '@hey-api/client-fetch' - -import type { ClientOptions } from './types.gen' +} from './client' +import type { ClientOptions as ClientOptions2 } from './types.gen' /** * The `createClientConfig()` function will be called on client initialization @@ -17,13 +17,10 @@ import type { ClientOptions } from './types.gen' * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = - ( - override?: Config, - ) => Config & T> +export type CreateClientConfig = ( + override?: Config, +) => Config & T> -export const client = createClient( - createConfig({ - baseUrl: 'https://api.nf.domains', - }), +export const client: Client = createClient( + createConfig({ baseUrl: 'https://api.nf.domains' }), ) diff --git a/packages/sdk/src/api/client/client.gen.ts b/packages/sdk/src/api/client/client.gen.ts new file mode 100644 index 0000000..05d14df --- /dev/null +++ b/packages/sdk/src/api/client/client.gen.ts @@ -0,0 +1,299 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen' +import type { HttpMethod } from '../core/types.gen' +import { getValidRequestBody } from '../core/utils.gen' +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen' +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen' + +type ReqInit = Omit & { + body?: any + headers: ReturnType +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config) + + const getConfig = (): Config => ({ ..._config }) + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config) + return getConfig() + } + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >() + + const beforeRequest = async < + TData = unknown, + TResponseStyle extends 'data' | 'fields' = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined as string | undefined, + } + + if (opts.security) { + await setAuthParams(opts) + } + + if (opts.requestValidator) { + await opts.requestValidator(opts) + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type') + } + + const resolvedOpts = opts as typeof opts & + ResolvedRequestOptions + const url = buildUrl(resolvedOpts) + + return { opts: resolvedOpts, url } + } + + const request: Client['request'] = async (options) => { + const throwOnError = options.throwOnError ?? _config.throwOnError + const responseStyle = options.responseStyle ?? _config.responseStyle + + let request: Request | undefined + let response: Response | undefined + + try { + const { opts, url } = await beforeRequest(options) + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + } + + request = new Request(url, requestInit) + + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts) + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch! + + response = await _fetch(request) + + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts) + } + } + + const result = { + request, + response, + } + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json' + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs]() + break + case 'formData': + emptyData = new FormData() + break + case 'stream': + emptyData = response.body + break + case 'json': + default: + emptyData = {} + break + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + } + } + + let data: any + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'text': + data = await response[parseAs]() + break + case 'json': { + // Some servers return 200 with no Content-Length and empty body. + // response.json() would throw; read as text and parse if non-empty. + const text = await response.text() + data = text ? JSON.parse(text) : {} + break + } + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + } + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data) + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data) + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + } + } + + const textError = await response.text() + let jsonError: unknown + + try { + jsonError = JSON.parse(textError) + } catch { + // noop + } + + throw jsonError ?? textError + } catch (error) { + let finalError = error + + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = await fn( + finalError, + response, + request, + options as ResolvedRequestOptions, + ) + } + } + + finalError = finalError || {} + + if (throwOnError) { + throw finalError + } + + // TODO: we probably want to return error and improve types + return responseStyle === 'data' + ? undefined + : { + error: finalError, + request, + response, + } + } + } + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }) + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options) + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + method, + onRequest: async (url, init) => { + let request = new Request(url, init) + for (const fn of interceptors.request.fns) { + if (fn) { + request = await fn(request, opts) + } + } + return request + }, + serializedBody: getValidRequestBody(opts) as + BodyInit | null | undefined, + url, + }) + } + + const _buildUrl: Client['buildUrl'] = (options) => + buildUrl({ ..._config, ...options }) + + return { + buildUrl: _buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client +} diff --git a/packages/sdk/src/api/client/index.ts b/packages/sdk/src/api/client/index.ts new file mode 100644 index 0000000..1d308e6 --- /dev/null +++ b/packages/sdk/src/api/client/index.ts @@ -0,0 +1,27 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen' +export type { QuerySerializerOptions } from '../core/bodySerializer.gen' +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen' +export { buildClientParams } from '../core/params.gen' +export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen' +export type { ServerSentEventsResult } from '../core/serverSentEvents.gen' +export type { ClientMeta } from '../core/types.gen' +export { createClient } from './client.gen' +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen' +export { createConfig, mergeHeaders } from './utils.gen' diff --git a/packages/sdk/src/api/client/types.gen.ts b/packages/sdk/src/api/client/types.gen.ts new file mode 100644 index 0000000..ade6498 --- /dev/null +++ b/packages/sdk/src/api/client/types.gen.ts @@ -0,0 +1,238 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen' +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen' +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen' +import type { Middleware } from './utils.gen' + +export type ResponseStyle = 'data' | 'fields' + +export interface Config + extends Omit, CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl'] + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never + /** + * Return the response data parsed in a specified format. By default, `auto` + * will infer the appropriate method from the `Content-Type` response header. + * You can override this behavior with any of the {@link Body} methods. + * Select `stream` if you don't want to parse response data at all. + * + * @default 'auto' + */ + parseAs?: + 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text' + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError'] +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> + extends + Config<{ + responseStyle: TResponseStyle + throwOnError: ThrowOnError + }>, + Pick< + ServerSentEventsOptions, + | 'onRequest' + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown + path?: Record + query?: Record + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray + url: Url +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + headers: Headers + serializedBody?: string +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData + request: Request + response: Response + } + > + : Promise< + TResponseStyle extends 'data' + ? | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData + error: undefined + } + | { + data: undefined + error: TError extends Record + ? TError[keyof TError] + : TError + } + ) & { + /** request may be undefined, because error may be from building the request object itself */ + request?: Request + /** response may be undefined, because error may be from building the request object itself or from a network error */ + response?: Response + } + > + +export interface ClientOptions { + baseUrl?: string + responseStyle?: ResponseStyle + throwOnError?: boolean +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult + +type SseFn = < + TData = unknown, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise> + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult + +type BuildUrlFn = < + TData extends { + body?: unknown + path?: Record + query?: Record + url: string + }, +>( + options: TData & Options, +) => string + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware +} + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T> + +export interface TDataShape { + body?: unknown + headers?: unknown + path?: unknown + query?: unknown + url: string +} + +type OmitKeys = Pick> + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + ([TData] extends [never] ? unknown : Omit) diff --git a/packages/sdk/src/api/client/utils.gen.ts b/packages/sdk/src/api/client/utils.gen.ts new file mode 100644 index 0000000..478ec6d --- /dev/null +++ b/packages/sdk/src/api/client/utils.gen.ts @@ -0,0 +1,332 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen' +import type { QuerySerializerOptions } from '../core/bodySerializer.gen' +import { jsonBodySerializer } from '../core/bodySerializer.gen' +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen' +import { getUrl } from '../core/utils.gen' +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen' + +export const createQuerySerializer = ({ + parameters = {}, + ...args +}: QuerySerializerOptions = {}): ((queryParams: T) => string) => { + const querySerializer = (queryParams: T): string => { + const search: string[] = [] + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name] + + if (value === undefined || value === null) { + continue + } + + const options = parameters[name] || args + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved: options.allowReserved, + explode: true, + name, + style: 'form', + value, + ...options.array, + }) + if (serializedArray) search.push(serializedArray) + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved: options.allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...options.object, + }) + if (serializedObject) search.push(serializedObject) + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved: options.allowReserved, + name, + value: value as string, + }) + if (serializedPrimitive) search.push(serializedPrimitive) + } + } + } + return search.join('&') + } + return querySerializer +} + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream' + } + + const cleanContent = contentType.split(';')[0]?.trim() + + if (!cleanContent) { + return + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json' + } + + if (cleanContent === 'multipart/form-data') { + return 'formData' + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob' + } + + if (cleanContent.startsWith('text/')) { + return 'text' + } + + return +} + +const checkForExistence = ( + options: Pick & { + headers: Headers + }, + name?: string, +): boolean => { + if (!name) { + return false + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true + } + return false +} + +export async function setAuthParams( + options: Pick & { + headers: Headers + }, +): Promise { + for (const auth of options.security ?? []) { + if (checkForExistence(options, auth.name)) { + continue + } + + const token = await getAuthToken(auth, options.auth) + + if (!token) { + continue + } + + const name = auth.name ?? 'Authorization' + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {} + } + options.query[name] = token + break + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`) + break + case 'header': + default: + options.headers.set(name, token) + break + } + } +} + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }) + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b } + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1) + } + config.headers = mergeHeaders(a.headers, b.headers) + return config +} + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = [] + headers.forEach((value, key) => { + entries.push([key, value]) + }) + return entries +} + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers() + for (const header of headers) { + if (!header) { + continue + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header) + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key) + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string) + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e., their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ) + } + } + } + return mergedHeaders +} + +type ErrInterceptor = ( + error: Err, + /** response may be undefined due to a network error where no response object is produced */ + response: Res | undefined, + /** request may be undefined, because error may be from building the request object itself */ + request: Req | undefined, + options: Options, +) => Err | Promise + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise + +class Interceptors { + fns: Array = [] + + clear(): void { + this.fns = [] + } + + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id) + if (this.fns[index]) { + this.fns[index] = null + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id) + return Boolean(this.fns[index]) + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1 + } + return this.fns.indexOf(id) + } + + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id) + if (this.fns[index]) { + this.fns[index] = fn + return id + } + return false + } + + use(fn: Interceptor): number { + this.fns.push(fn) + return this.fns.length - 1 + } +} + +export interface Middleware { + error: Interceptors> + request: Interceptors> + response: Interceptors> +} + +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}) + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}) + +const defaultHeaders = { + 'Content-Type': 'application/json', +} + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}) diff --git a/packages/sdk/src/api/core/auth.gen.ts b/packages/sdk/src/api/core/auth.gen.ts new file mode 100644 index 0000000..f7d8e91 --- /dev/null +++ b/packages/sdk/src/api/core/auth.gen.ts @@ -0,0 +1,48 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie' + /** + * A unique identifier for the security scheme. + * + * Defined only when there are multiple security schemes whose `Auth` + * shape would otherwise be identical. + */ + key?: string + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string + scheme?: 'basic' | 'bearer' + type: 'apiKey' | 'http' +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = typeof callback === 'function' ? await callback(auth) : callback + + if (!token) { + return + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}` + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}` + } + + return token +} diff --git a/packages/sdk/src/api/core/bodySerializer.gen.ts b/packages/sdk/src/api/core/bodySerializer.gen.ts new file mode 100644 index 0000000..94bc879 --- /dev/null +++ b/packages/sdk/src/api/core/bodySerializer.gen.ts @@ -0,0 +1,96 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen' + +export type QuerySerializer = (query: Record) => string + +export type BodySerializer = (body: unknown) => unknown + +type QuerySerializerOptionsObject = { + allowReserved?: boolean + array?: Partial> + object?: Partial> +} + +export type QuerySerializerOptions = QuerySerializerOptionsObject & { + /** + * Per-parameter serialization overrides. When provided, these settings + * override the global array/object settings for specific parameter names. + */ + parameters?: Record +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value) + } else if (value instanceof Date) { + data.append(key, value.toISOString()) + } else { + data.append(key, JSON.stringify(value)) + } +} + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value) + } else { + data.append(key, JSON.stringify(value)) + } +} + +export const formDataBodySerializer = { + bodySerializer: (body: unknown): FormData => { + const data = new FormData() + + Object.entries(body as Record).forEach(([key, value]) => { + if (value === undefined || value === null) { + return + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)) + } else { + serializeFormDataPair(data, key, value) + } + }) + + return data + }, +} + +export const jsonBodySerializer = { + bodySerializer: (body: unknown): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +} + +export const urlSearchParamsBodySerializer = { + bodySerializer: (body: unknown): string => { + const data = new URLSearchParams() + + Object.entries(body as Record).forEach(([key, value]) => { + if (value === undefined || value === null) { + return + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)) + } else { + serializeUrlSearchParamsPair(data, key, value) + } + }) + + return data.toString() + }, +} diff --git a/packages/sdk/src/api/core/params.gen.ts b/packages/sdk/src/api/core/params.gen.ts new file mode 100644 index 0000000..f53c97f --- /dev/null +++ b/packages/sdk/src/api/core/params.gen.ts @@ -0,0 +1,186 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query' + +export type Field = + | { + in: Exclude + /** + * Field name. This is the name we want the user to see and use. + */ + key: string + /** + * Field mapped name. This is the name we want to use in the request. + * If omitted, we use the same value as `key`. + */ + map?: string + } + | { + in: Extract + /** + * Key isn't required for bodies. + */ + key?: string + map?: string + } + | { + /** + * Field name. This is the name we want the user to see and use. + */ + key: string + /** + * Field mapped name. This is the name we want to use in the request. + * If `in` is omitted, `map` aliases `key` to the transport layer. + */ + map: Slot + } + +export interface Fields { + allowExtra?: Partial> + args?: ReadonlyArray +} + +export type FieldsConfig = ReadonlyArray + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +} +const extraPrefixes = Object.entries(extraPrefixesMap) + +type KeyMap = Map< + string, + | { + in: Slot + map?: string + } + | { + in?: never + map: Slot + } +> + +function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap { + if (!map) { + map = new Map() + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }) + } + } else if ('key' in config) { + map.set(config.key, { + map: config.map, + }) + } else if (config.args) { + buildKeyMap(config.args, map) + } + } + + return map +} + +interface Params { + body?: unknown + headers: Record + path: Record + query: Record +} + +function stripEmptySlots(params: Params): void { + for (const [slot, value] of Object.entries(params)) { + if (slot === 'body') continue + if ( + value && + typeof value === 'object' && + !Array.isArray(value) && + !Object.keys(value).length + ) { + delete params[slot as Slot] + } + } +} + +export function buildClientParams( + args: ReadonlyArray, + fields: FieldsConfig, +): Params { + const params: Params = { + headers: Object.create(null), + path: Object.create(null), + query: Object.create(null), + } + + const map = buildKeyMap(fields) + + function writeSlot(slot: Slot, key: string, value: unknown): void { + let record = params[slot] as Record | undefined + if (record === undefined) { + record = Object.create(null) as Record + params[slot] = record + } + record[key] = value + } + + let config: FieldsConfig[number] | undefined + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index] + } + + if (!config) { + continue + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)! + const name = field.map || config.key + if (field.in) { + writeSlot(field.in, name, arg) + } + } else { + params.body = arg + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key) + + if (field) { + if (field.in) { + const name = field.map || key + writeSlot(field.in, name, value) + } else { + params[field.map] = value + } + } else { + const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix)) + + if (extra) { + const [prefix, slot] = extra + writeSlot(slot, key.slice(prefix.length), value) + } else if ('allowExtra' in config && config.allowExtra) { + for (const [slot, allowed] of Object.entries(config.allowExtra)) { + if (allowed) { + writeSlot(slot as Slot, key, value) + break + } + } + } + } + } + } + } + + stripEmptySlots(params) + + return params +} diff --git a/packages/sdk/src/api/core/pathSerializer.gen.ts b/packages/sdk/src/api/core/pathSerializer.gen.ts new file mode 100644 index 0000000..1adcdcf --- /dev/null +++ b/packages/sdk/src/api/core/pathSerializer.gen.ts @@ -0,0 +1,186 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean + name: string +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean + style: T +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited' +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle +type MatrixStyle = 'label' | 'matrix' | 'simple' +export type ObjectStyle = 'form' | 'deepObject' +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string +} + +export const separatorArrayExplode = ( + style: ArraySeparatorStyle, +): '.' | ';' | ',' | '&' => { + switch (style) { + case 'label': + return '.' + case 'matrix': + return ';' + case 'simple': + return ',' + default: + return '&' + } +} + +export const separatorArrayNoExplode = ( + style: ArraySeparatorStyle, +): ',' | '|' | '%20' => { + switch (style) { + case 'form': + return ',' + case 'pipeDelimited': + return '|' + case 'spaceDelimited': + return '%20' + default: + return ',' + } +} + +export const separatorObjectExplode = ( + style: ObjectSeparatorStyle, +): '.' | ';' | ',' | '&' => { + switch (style) { + case 'label': + return '.' + case 'matrix': + return ';' + case 'simple': + return ',' + default: + return '&' + } +} + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[] +}): string => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)) + switch (style) { + case 'label': + return `.${joinedValues}` + case 'matrix': + return `;${name}=${joinedValues}` + case 'simple': + return joinedValues + default: + return `${name}=${joinedValues}` + } + } + + const separator = separatorArrayExplode(style) + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string) + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }) + }) + .join(separator) + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues +} + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam): string => { + if (value === undefined || value === null) { + return '' + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ) + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}` +} + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date + valueOnly?: boolean +}): string => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}` + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = [] + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ] + }) + const joinedValues = values.join(',') + switch (style) { + case 'form': + return `${name}=${joinedValues}` + case 'label': + return `.${joinedValues}` + case 'matrix': + return `;${name}=${joinedValues}` + default: + return joinedValues + } + } + + const separator = separatorObjectExplode(style) + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator) + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues +} diff --git a/packages/sdk/src/api/core/queryKeySerializer.gen.ts b/packages/sdk/src/api/core/queryKeySerializer.gen.ts new file mode 100644 index 0000000..c8b7860 --- /dev/null +++ b/packages/sdk/src/api/core/queryKeySerializer.gen.ts @@ -0,0 +1,134 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * JSON-friendly union that mirrors what Pinia Colada can hash. + */ +export type JsonValue = + null | string | number | boolean | JsonValue[] | { [key: string]: JsonValue } + +/** + * Replacer that converts non-JSON values (bigint, Date, etc.) to safe substitutes. + */ +export const queryKeyJsonReplacer = ( + _key: string, + value: unknown, +): unknown | undefined => { + if ( + value === undefined || + typeof value === 'function' || + typeof value === 'symbol' + ) { + return undefined + } + if (typeof value === 'bigint') { + return value.toString() + } + if (value instanceof Date) { + return value.toISOString() + } + return value +} + +/** + * Safely stringifies a value and parses it back into a JsonValue. + */ +export const stringifyToJsonValue = (input: unknown): JsonValue | undefined => { + try { + const json = JSON.stringify(input, queryKeyJsonReplacer) + if (json === undefined) { + return undefined + } + return JSON.parse(json) as JsonValue + } catch { + return undefined + } +} + +/** + * Detects plain objects (including objects with a null prototype). + */ +const isPlainObject = (value: unknown): value is Record => { + if (value === null || typeof value !== 'object') { + return false + } + const prototype = Object.getPrototypeOf(value as object) + return prototype === Object.prototype || prototype === null +} + +/** + * Turns URLSearchParams into a sorted JSON object for deterministic keys. + */ +const serializeSearchParams = (params: URLSearchParams): JsonValue => { + const entries = Array.from(params.entries()).sort(([a], [b]) => + a.localeCompare(b), + ) + const result: Record = {} + + for (const [key, value] of entries) { + const existing = result[key] + if (existing === undefined) { + result[key] = value + continue + } + + if (Array.isArray(existing)) { + ;(existing as string[]).push(value) + } else { + result[key] = [existing, value] + } + } + + return result +} + +/** + * Normalizes any accepted value into a JSON-friendly shape for query keys. + */ +export const serializeQueryKeyValue = ( + value: unknown, +): JsonValue | undefined => { + if (value === null) { + return null + } + + if ( + typeof value === 'string' || + typeof value === 'number' || + typeof value === 'boolean' + ) { + return value + } + + if ( + value === undefined || + typeof value === 'function' || + typeof value === 'symbol' + ) { + return undefined + } + + if (typeof value === 'bigint') { + return value.toString() + } + + if (value instanceof Date) { + return value.toISOString() + } + + if (Array.isArray(value)) { + return stringifyToJsonValue(value) + } + + if ( + typeof URLSearchParams !== 'undefined' && + value instanceof URLSearchParams + ) { + return serializeSearchParams(value) + } + + if (isPlainObject(value)) { + return stringifyToJsonValue(value) + } + + return undefined +} diff --git a/packages/sdk/src/api/core/serverSentEvents.gen.ts b/packages/sdk/src/api/core/serverSentEvents.gen.ts new file mode 100644 index 0000000..3cbe75e --- /dev/null +++ b/packages/sdk/src/api/core/serverSentEvents.gen.ts @@ -0,0 +1,265 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen' + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void + serializedBody?: RequestInit['body'] + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise + url: string + } + +export interface StreamEvent { + data: TData + event?: string + id?: string + retry?: number +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + > +} + +export function createSseClient({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult { + let lastEventId: string | undefined + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))) + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000 + let attempt = 0 + const signal = options.signal ?? new AbortController().signal + + while (true) { + if (signal.aborted) break + + attempt++ + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined) + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId) + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + } + let request = new Request(url, requestInit) + if (onRequest) { + request = await onRequest(url, requestInit) + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch + const response = await _fetch(request) + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ) + + if (!response.body) throw new Error('No body in SSE response') + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader() + + let buffer = '' + + const abortHandler = () => { + try { + reader.cancel() + } catch { + // noop + } + } + + signal.addEventListener('abort', abortHandler) + + try { + while (true) { + const { done, value } = await reader.read() + if (done) break + buffer += value + buffer = buffer.replace(/\r\n?/g, '\n') // normalize line endings + + const chunks = buffer.split('\n\n') + buffer = chunks.pop() ?? '' + + for (const chunk of chunks) { + const lines = chunk.split('\n') + const dataLines: Array = [] + let eventName: string | undefined + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')) + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, '') + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, '') + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ) + if (!Number.isNaN(parsed)) { + retryDelay = parsed + } + } + } + + let data: unknown + let parsedJson = false + + if (dataLines.length) { + const rawData = dataLines.join('\n') + try { + data = JSON.parse(rawData) + parsedJson = true + } catch { + data = rawData + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data) + } + + if (responseTransformer) { + data = await responseTransformer(data) + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }) + + if (dataLines.length) { + yield data as any + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler) + reader.releaseLock() + } + + break // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error) + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ) + await sleep(backoff) + } + } + } + + const stream = createStream() + + return { stream } +} diff --git a/packages/sdk/src/api/core/types.gen.ts b/packages/sdk/src/api/core/types.gen.ts new file mode 100644 index 0000000..d5de09e --- /dev/null +++ b/packages/sdk/src/api/core/types.gen.ts @@ -0,0 +1,126 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen' +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen' + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace' + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn + getConfig: () => Config + request: RequestFn + setConfig: (config: Config) => Config +} & { + [K in HttpMethod]: MethodFn +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }) + +export interface Config { + /** + * Auth token or a function returning auth token. The resolved value will be + * added to the request payload as defined by its `security` array. + */ + auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + > + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions + /** + * A function validating request data. This is useful if you want to ensure + * the request conforms to the desired shape, so it can be safely sent to + * the server. + */ + requestValidator?: (data: unknown) => Promise + /** + * A function transforming response data before it's returned. This is useful + * for post-processing data, e.g., converting ISO strings into Date objects. + */ + responseTransformer?: (data: unknown) => Promise + /** + * A function validating response data. This is useful if you want to ensure + * the response conforms to the desired shape, so it can be safely passed to + * the transformers and returned to the user. + */ + responseValidator?: (data: unknown) => Promise +} + +/** + * Arbitrary metadata passed through the `meta` request option. + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface ClientMeta {} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false + +export type OmitNever> = { + [ + K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K + ]: T[K] +} diff --git a/packages/sdk/src/api/core/utils.gen.ts b/packages/sdk/src/api/core/utils.gen.ts new file mode 100644 index 0000000..42f8c1b --- /dev/null +++ b/packages/sdk/src/api/core/utils.gen.ts @@ -0,0 +1,146 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen' +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen' + +export interface PathSerializer { + path: Record + url: string +} + +export const PATH_PARAM_RE: RegExp = /\{[^{}]+\}/g + +export const defaultPathSerializer = ({ + path, + url: _url, +}: PathSerializer): string => { + let url = _url + const matches = _url.match(PATH_PARAM_RE) + if (matches) { + for (const match of matches) { + let explode = false + let name = match.substring(1, match.length - 1) + let style: ArraySeparatorStyle = 'simple' + + if (name.endsWith('*')) { + explode = true + name = name.substring(0, name.length - 1) + } + + if (name.startsWith('.')) { + name = name.substring(1) + style = 'label' + } else if (name.startsWith(';')) { + name = name.substring(1) + style = 'matrix' + } + + const value = path[name] + + if (value === undefined || value === null) { + continue + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ) + continue + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ) + continue + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ) + continue + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ) + url = url.replace(match, replaceValue) + } + } + return url +} + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string + path?: Record + query?: Record + querySerializer: QuerySerializer + url: string +}): string => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}` + let url = (baseUrl ?? '') + pathUrl + if (path) { + url = defaultPathSerializer({ path, url }) + } + let search = query ? querySerializer(query) : '' + if (search.startsWith('?')) { + search = search.substring(1) + } + if (search) { + url += `?${search}` + } + return url +} + +export function getValidRequestBody(options: { + body?: unknown + bodySerializer?: BodySerializer | null + serializedBody?: unknown +}): unknown { + const hasBody = options.body !== undefined + const isSerializedBody = hasBody && options.bodySerializer + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== '' + + return hasSerializedBody ? options.serializedBody : null + } + + // not all clients implement a serializedBody property (i.e., client-axios) + return options.body !== '' ? options.body : null + } + + // plain/text body + if (hasBody) { + return options.body + } + + // no body was provided + return undefined +} diff --git a/packages/sdk/src/api/index.ts b/packages/sdk/src/api/index.ts index 16b44b6..9d57a22 100644 --- a/packages/sdk/src/api/index.ts +++ b/packages/sdk/src/api/index.ts @@ -1,3 +1,384 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen' -export * from './sdk.gen' + +export { + info_InfoOpenapi3Yaml, + info_version, + nfd_activity, + nfd_analytics, + nfd_badges, + nfd_blueskyLeaders, + nfd_browse, + nfd_consensusLeaders, + nfd_consensusMetrics, + nfd_contractLock, + nfd_contractUpgrade, + nfd_ContractUpgradeV3, + nfd_donationLeadersV2, + nfd_donationListV2, + nfd_donations, + nfd_getLookup, + nfd_getNameSig, + nfd_getNfd, + nfd_getNfdsForAddressesV2, + nfd_getQuote, + nfd_getRevAddressSig, + nfd_isValidAsa, + nfd_isValidNfd, + nfd_linkAddress, + nfd_mint, + nfd_offer, + nfd_postOfferToOwner, + nfd_purchase, + nfd_renew, + nfd_rescindOffer, + nfd_searchV2, + nfd_segmentLeaders, + nfd_segmentLock, + nfd_sendFromVault, + nfd_sendToVault, + nfd_setPrimaryAddress, + nfd_setPrimaryNfd, + nfd_suggest, + nfd_totals, + nfd_twitterLeaders, + nfd_unlinkAddress, + nfd_updateAll, + nfd_updateImage, + nfd_updatePartial, + nfd_vaultOptInLock, + nfd_verifyConfirm, + nfd_verifyRequest, + type Options, +} from './sdk.gen' +export type { + Asset, + AssetAmounts, + AssetRecords, + Attachment, + BlueskyRecord, + BlueskyRecords, + ClientOptions, + ConsensusMetricsData, + ConsensusRecord, + ConsensusRecords, + ContractLockRequestBody, + ControlEvent, + ControlNotification, + ConversationDetails, + ConversationEvent, + ConversationNotification, + ConversationState, + ConversationTypingEvent, + Dm, + DmConversation, + DmConversations, + DmDataResp, + DmWithState, + Donation, + DonationAccount, + DonationRecords, + Error, + ErrorResponse, + GetQuoteResponseBody, + InfoInfoOpenapi3YamlData, + InfoInfoOpenapi3YamlResponses, + InfoVersionData, + InfoVersionResponse, + InfoVersionResponses, + IsValidAsaResponseBody, + IsValidNfdResponseBody, + LinkAddressRequestBody, + MintRequestBody, + Nfd, + NfdActivity, + NfdActivityData, + NfdActivityError, + NfdActivityErrors, + NfdActivityRecords, + NfdActivityResponse, + NfdActivityResponses, + NfdAnalyticEvent, + NfdAnalyticRecord, + NfdAnalyticRecords, + NfdAnalyticRecords2, + NfdAnalyticsData, + NfdAnalyticsError, + NfdAnalyticsErrors, + NfdAnalyticsResponse, + NfdAnalyticsResponses, + NfdAuction, + NfdAuctionAndPrice, + NfdBadges, + NfdBadgesData, + NfdBadgesError, + NfdBadgesErrors, + NfdBadgesResponse, + NfdBadgesResponses, + NfdBlueskyLeadersData, + NfdBlueskyLeadersError, + NfdBlueskyLeadersErrors, + NfdBlueskyLeadersResponse, + NfdBlueskyLeadersResponses, + NfdBrowseData, + NfdBrowseError, + NfdBrowseErrors, + NfdBrowseResponse, + NfdBrowseResponses, + NfdConsensusLeadersData, + NfdConsensusLeadersError, + NfdConsensusLeadersErrors, + NfdConsensusLeadersResponse, + NfdConsensusLeadersResponses, + NfdConsensusMetricsData, + NfdConsensusMetricsError, + NfdConsensusMetricsErrors, + NfdConsensusMetricsResponse, + NfdConsensusMetricsResponses, + NfdContractLockData, + NfdContractLockError, + NfdContractLockErrors, + NfdContractLockResponse, + NfdContractLockResponses, + NfdContractUpgradeData, + NfdContractUpgradeError, + NfdContractUpgradeErrors, + NfdContractUpgradeResponse, + NfdContractUpgradeResponses, + NfdContractUpgradeV3Data, + NfdContractUpgradeV3Error, + NfdContractUpgradeV3Errors, + NfdContractUpgradeV3Response, + NfdContractUpgradeV3Responses, + NfdDonationLeadersV2Data, + NfdDonationLeadersV2Error, + NfdDonationLeadersV2Errors, + NfdDonationLeadersV2Response, + NfdDonationLeadersV2Responses, + NfdDonationListV2Data, + NfdDonationListV2Error, + NfdDonationListV2Errors, + NfdDonationListV2Response, + NfdDonationListV2Responses, + NfdDonationsData, + NfdDonationsError, + NfdDonationsErrors, + NfdDonationsResponse, + NfdDonationsResponses, + NfdGetLookupData, + NfdGetLookupError, + NfdGetLookupErrors, + NfdGetLookupResponse, + NfdGetLookupResponses, + NfdGetNameSigData, + NfdGetNameSigError, + NfdGetNameSigErrors, + NfdGetNameSigResponse, + NfdGetNameSigResponses, + NfdGetNfdData, + NfdGetNfdError, + NfdGetNfdErrors, + NfdGetNfdResponse, + NfdGetNfdResponses, + NfdGetNfdsForAddressesV2Data, + NfdGetNfdsForAddressesV2Error, + NfdGetNfdsForAddressesV2Errors, + NfdGetNfdsForAddressesV2Response, + NfdGetNfdsForAddressesV2Responses, + NfdGetQuoteData, + NfdGetQuoteError, + NfdGetQuoteErrors, + NfdGetQuoteResponse, + NfdGetQuoteResponses, + NfdGetRevAddressSigData, + NfdGetRevAddressSigError, + NfdGetRevAddressSigErrors, + NfdGetRevAddressSigResponse, + NfdGetRevAddressSigResponses, + NfdIsValidAsaData, + NfdIsValidAsaError, + NfdIsValidAsaErrors, + NfdIsValidAsaResponse, + NfdIsValidAsaResponses, + NfdIsValidNfdData, + NfdIsValidNfdError, + NfdIsValidNfdErrors, + NfdIsValidNfdResponse, + NfdIsValidNfdResponses, + NfdLinkAddressData, + NfdLinkAddressError, + NfdLinkAddressErrors, + NfdLinkAddressResponse, + NfdLinkAddressResponses, + NfdLookupRecords, + NfdMarketInfo, + NfdMintData, + NfdMintError, + NfdMintErrors, + NfdMintResponse, + NfdMintResponses, + NfdOfferData, + NfdOfferError, + NfdOfferErrors, + NfdOfferResponse, + NfdOfferResponses, + NfdPostOfferToOwnerData, + NfdPostOfferToOwnerError, + NfdPostOfferToOwnerErrors, + NfdPostOfferToOwnerResponse, + NfdPostOfferToOwnerResponses, + NfdProperties, + NfdPurchaseData, + NfdPurchaseError, + NfdPurchaseErrors, + NfdPurchaseResponse, + NfdPurchaseResponses, + NfdRecord, + NfdRecordCollection, + NfdRecordinaddress, + NfdRecordinaddressCollection, + NfdRecordResponseFull, + NfdRecordResponseFullCollection, + NfdRecords, + NfdRenewData, + NfdRenewError, + NfdRenewErrors, + NfdRenewResponse, + NfdRenewResponses, + NfdRescindOfferData, + NfdRescindOfferError, + NfdRescindOfferErrors, + NfdRescindOfferResponse, + NfdRescindOfferResponses, + NfdSearchV2Data, + NfdSearchV2Error, + NfdSearchV2Errors, + NfdSearchV2Response, + NfdSearchV2Responses, + NfdSegmentLeadersData, + NfdSegmentLeadersError, + NfdSegmentLeadersErrors, + NfdSegmentLeadersResponse, + NfdSegmentLeadersResponses, + NfdSegmentLockData, + NfdSegmentLockError, + NfdSegmentLockErrors, + NfdSegmentLockResponse, + NfdSegmentLockResponses, + NfdSendFromVaultData, + NfdSendFromVaultError, + NfdSendFromVaultErrors, + NfdSendFromVaultResponse, + NfdSendFromVaultResponses, + NfdSendToVaultData, + NfdSendToVaultError, + NfdSendToVaultErrors, + NfdSendToVaultResponse, + NfdSendToVaultResponses, + NfdSetPrimaryAddressData, + NfdSetPrimaryAddressError, + NfdSetPrimaryAddressErrors, + NfdSetPrimaryAddressResponse, + NfdSetPrimaryAddressResponses, + NfdSetPrimaryNfdData, + NfdSetPrimaryNfdError, + NfdSetPrimaryNfdErrors, + NfdSetPrimaryNfdResponse, + NfdSetPrimaryNfdResponses, + NfdSuggestData, + NfdSuggestError, + NfdSuggestErrors, + NfdSuggestResponse, + NfdSuggestResponses, + NfdTotalsData, + NfdTotalsError, + NfdTotalsErrors, + NfdTotalsResponse, + NfdTotalsResponses, + NfdTwitterLeadersData, + NfdTwitterLeadersError, + NfdTwitterLeadersErrors, + NfdTwitterLeadersResponse, + NfdTwitterLeadersResponses, + NfdUnlinkAddressData, + NfdUnlinkAddressError, + NfdUnlinkAddressErrors, + NfdUnlinkAddressResponse, + NfdUnlinkAddressResponses, + NfdUpdateAllData, + NfdUpdateAllError, + NfdUpdateAllErrors, + NfdUpdateAllResponse, + NfdUpdateAllResponses, + NfdUpdateImageData, + NfdUpdateImageError, + NfdUpdateImageErrors, + NfdUpdateImageResponse, + NfdUpdateImageResponses, + NfdUpdatePartialData, + NfdUpdatePartialError, + NfdUpdatePartialErrors, + NfdUpdatePartialResponse, + NfdUpdatePartialResponses, + NfdV2AddressRecords, + NfdV2SearchRecords, + NfdVaultOptInLockData, + NfdVaultOptInLockError, + NfdVaultOptInLockErrors, + NfdVaultOptInLockResponse, + NfdVaultOptInLockResponses, + NfdVerifyConfirmData, + NfdVerifyConfirmError, + NfdVerifyConfirmErrors, + NfdVerifyConfirmResponse, + NfdVerifyConfirmResponses, + NfdVerifyRequestData, + NfdVerifyRequestError, + NfdVerifyRequestErrors, + NfdVerifyRequestResponse, + NfdVerifyRequestResponses, + Nft, + NftRecords, + OfferRequestBody, + Pagination, + Participant, + PostDmEvent, + PostOfferToOwnerRequestBody, + PostReactionEvent, + PostRoomPostEvent, + PurchaseRequestBody, + RateLimited, + Reaction, + ReactionDataResp, + RenewRequestBody, + RescindOfferRequestBody, + RoomConversation, + RoomConversations, + RoomParticipants, + RoomPost, + RoomPostDataResp, + RoomPostWithState, + SegmentLockRequestBody, + SendFromVaultRequestBody, + SendToVaultRequestBody, + SetPrimaryAddressRequestBody, + StreamingCmdAck, + StreamingDataResponse, + StreamingDataRoomPostResponse, + StreamingDmEvent, + StreamingDmEventResponse, + StreamingRoomPostCmdAck, + StreamingRoomPostEvent, + StreamingRoomPostEventResponse, + TotalsOkResponseBody, + TwitterRecord, + TwitterRecords, + UnlinkAddressRequestBody, + UpdatePartialRequestBody, + UserActiveNfd, + VerifyConfirmRequestBody, + VerifyConfirmResponseBody, + VerifyRequest, + VerifyRequestRequestBody, + VerifyRequestResponseBody, + VersionResponseBody, +} from './types.gen' diff --git a/packages/sdk/src/api/sdk.gen.ts b/packages/sdk/src/api/sdk.gen.ts index 5e5ea3d..bd8d06c 100644 --- a/packages/sdk/src/api/sdk.gen.ts +++ b/packages/sdk/src/api/sdk.gen.ts @@ -1,157 +1,160 @@ // This file is auto-generated by @hey-api/openapi-ts -import { client as _heyApiClient } from './client.gen' - +import type { + Client, + ClientMeta, + Options as Options2, + RequestResult, + TDataShape, +} from './client' +import { client } from './client.gen' import type { InfoInfoOpenapi3YamlData, + InfoInfoOpenapi3YamlResponses, InfoVersionData, - InfoVersionResponse, - NfdGetNfdData, - NfdGetNfdResponse, - NfdGetNfdError, + InfoVersionResponses, NfdActivityData, - NfdActivityResponse, - NfdActivityError, + NfdActivityErrors, + NfdActivityResponses, NfdAnalyticsData, - NfdAnalyticsResponse, - NfdAnalyticsError, + NfdAnalyticsErrors, + NfdAnalyticsResponses, NfdBadgesData, - NfdBadgesResponse, - NfdBadgesError, + NfdBadgesErrors, + NfdBadgesResponses, NfdBlueskyLeadersData, - NfdBlueskyLeadersResponse, - NfdBlueskyLeadersError, + NfdBlueskyLeadersErrors, + NfdBlueskyLeadersResponses, NfdBrowseData, - NfdBrowseResponse, - NfdBrowseError, + NfdBrowseErrors, + NfdBrowseResponses, NfdConsensusLeadersData, - NfdConsensusLeadersResponse, - NfdConsensusLeadersError, + NfdConsensusLeadersErrors, + NfdConsensusLeadersResponses, NfdConsensusMetricsData, - NfdConsensusMetricsResponse, - NfdConsensusMetricsError, + NfdConsensusMetricsErrors, + NfdConsensusMetricsResponses, NfdContractLockData, - NfdContractLockResponse, - NfdContractLockError, + NfdContractLockErrors, + NfdContractLockResponses, NfdContractUpgradeData, - NfdContractUpgradeResponse, - NfdContractUpgradeError, + NfdContractUpgradeErrors, + NfdContractUpgradeResponses, + NfdContractUpgradeV3Data, + NfdContractUpgradeV3Errors, + NfdContractUpgradeV3Responses, + NfdDonationLeadersV2Data, + NfdDonationLeadersV2Errors, + NfdDonationLeadersV2Responses, + NfdDonationListV2Data, + NfdDonationListV2Errors, + NfdDonationListV2Responses, NfdDonationsData, - NfdDonationsResponse, - NfdDonationsError, + NfdDonationsErrors, + NfdDonationsResponses, + NfdGetLookupData, + NfdGetLookupErrors, + NfdGetLookupResponses, + NfdGetNameSigData, + NfdGetNameSigErrors, + NfdGetNameSigResponses, + NfdGetNfdData, + NfdGetNfdErrors, + NfdGetNfdResponses, + NfdGetNfdsForAddressesV2Data, + NfdGetNfdsForAddressesV2Errors, + NfdGetNfdsForAddressesV2Responses, NfdGetQuoteData, - NfdGetQuoteResponse, - NfdGetQuoteError, - NfdIsValidNfdData, - NfdIsValidNfdResponse, - NfdIsValidNfdError, + NfdGetQuoteErrors, + NfdGetQuoteResponses, + NfdGetRevAddressSigData, + NfdGetRevAddressSigErrors, + NfdGetRevAddressSigResponses, NfdIsValidAsaData, - NfdIsValidAsaResponse, - NfdIsValidAsaError, + NfdIsValidAsaErrors, + NfdIsValidAsaResponses, + NfdIsValidNfdData, + NfdIsValidNfdErrors, + NfdIsValidNfdResponses, NfdLinkAddressData, - NfdLinkAddressResponse, - NfdLinkAddressError, - NfdUnlinkAddressData, - NfdUnlinkAddressResponse, - NfdUnlinkAddressError, - NfdSetPrimaryAddressData, - NfdSetPrimaryAddressResponse, - NfdSetPrimaryAddressError, - NfdSetPrimaryNfdData, - NfdSetPrimaryNfdResponse, - NfdSetPrimaryNfdError, - NfdGetLookupData, - NfdGetLookupResponse, - NfdGetLookupError, + NfdLinkAddressErrors, + NfdLinkAddressResponses, NfdMintData, - NfdMintResponse, - NfdMintError, - NfdGetNameSigData, - NfdGetNameSigResponse, - NfdGetNameSigError, + NfdMintErrors, + NfdMintResponses, NfdOfferData, - NfdOfferResponse, - NfdOfferError, + NfdOfferErrors, + NfdOfferResponses, NfdPostOfferToOwnerData, - NfdPostOfferToOwnerResponse, - NfdPostOfferToOwnerError, + NfdPostOfferToOwnerErrors, + NfdPostOfferToOwnerResponses, NfdPurchaseData, - NfdPurchaseResponse, - NfdPurchaseError, + NfdPurchaseErrors, + NfdPurchaseResponses, NfdRenewData, - NfdRenewResponse, - NfdRenewError, + NfdRenewErrors, + NfdRenewResponses, NfdRescindOfferData, - NfdRescindOfferResponse, - NfdRescindOfferError, - NfdGetRevAddressSigData, - NfdGetRevAddressSigResponse, - NfdGetRevAddressSigError, + NfdRescindOfferErrors, + NfdRescindOfferResponses, + NfdSearchV2Data, + NfdSearchV2Errors, + NfdSearchV2Responses, NfdSegmentLeadersData, - NfdSegmentLeadersResponse, - NfdSegmentLeadersError, + NfdSegmentLeadersErrors, + NfdSegmentLeadersResponses, NfdSegmentLockData, - NfdSegmentLockResponse, - NfdSegmentLockError, + NfdSegmentLockErrors, + NfdSegmentLockResponses, + NfdSendFromVaultData, + NfdSendFromVaultErrors, + NfdSendFromVaultResponses, + NfdSendToVaultData, + NfdSendToVaultErrors, + NfdSendToVaultResponses, + NfdSetPrimaryAddressData, + NfdSetPrimaryAddressErrors, + NfdSetPrimaryAddressResponses, + NfdSetPrimaryNfdData, + NfdSetPrimaryNfdErrors, + NfdSetPrimaryNfdResponses, NfdSuggestData, - NfdSuggestResponse, - NfdSuggestError, + NfdSuggestErrors, + NfdSuggestResponses, NfdTotalsData, - NfdTotalsResponse, - NfdTotalsError, + NfdTotalsErrors, + NfdTotalsResponses, NfdTwitterLeadersData, - NfdTwitterLeadersResponse, - NfdTwitterLeadersError, - NfdUpdatePartialData, - NfdUpdatePartialResponse, - NfdUpdatePartialError, + NfdTwitterLeadersErrors, + NfdTwitterLeadersResponses, + NfdUnlinkAddressData, + NfdUnlinkAddressErrors, + NfdUnlinkAddressResponses, NfdUpdateAllData, - NfdUpdateAllResponse, - NfdUpdateAllError, + NfdUpdateAllErrors, + NfdUpdateAllResponses, NfdUpdateImageData, - NfdUpdateImageResponse, - NfdUpdateImageError, - NfdGetNfdsForAddressesV2Data, - NfdGetNfdsForAddressesV2Response, - NfdGetNfdsForAddressesV2Error, - NfdDonationLeadersV2Data, - NfdDonationLeadersV2Response, - NfdDonationLeadersV2Error, - NfdDonationListV2Data, - NfdDonationListV2Response, - NfdDonationListV2Error, - NfdSearchV2Data, - NfdSearchV2Response, - NfdSearchV2Error, - NfdContractUpgradeV3Data, - NfdContractUpgradeV3Response, - NfdContractUpgradeV3Error, + NfdUpdateImageErrors, + NfdUpdateImageResponses, + NfdUpdatePartialData, + NfdUpdatePartialErrors, + NfdUpdatePartialResponses, NfdVaultOptInLockData, - NfdVaultOptInLockResponse, - NfdVaultOptInLockError, - NfdSendFromVaultData, - NfdSendFromVaultResponse, - NfdSendFromVaultError, - NfdSendToVaultData, - NfdSendToVaultResponse, - NfdSendToVaultError, + NfdVaultOptInLockErrors, + NfdVaultOptInLockResponses, NfdVerifyConfirmData, - NfdVerifyConfirmResponse, - NfdVerifyConfirmError, + NfdVerifyConfirmErrors, + NfdVerifyConfirmResponses, NfdVerifyRequestData, - NfdVerifyRequestResponse, - NfdVerifyRequestError, + NfdVerifyRequestErrors, + NfdVerifyRequestResponses, } from './types.gen' -import type { - Options as ClientOptions, - TDataShape, - Client, -} from '@hey-api/client-fetch' export type Options< TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, -> = ClientOptions & { + TResponse = unknown, +> = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -162,885 +165,895 @@ export type Options< * You can pass arbitrary values through the `meta` object. This can be * used to access values that aren't defined as part of the SDK function. */ - meta?: Record + meta?: keyof ClientMeta extends never ? Record : ClientMeta } /** * Download ./pubfiles/openapi3.yaml + * * YAML document containing the API swagger definition */ -export const infoInfoOpenapi3Yaml = ( +export const info_InfoOpenapi3Yaml = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get( - { - url: '/info/openapi3.yaml', - ...options, - }, - ) -} +): RequestResult => + (options?.client ?? client).get< + InfoInfoOpenapi3YamlResponses, + unknown, + ThrowOnError + >({ url: '/info/openapi3.yaml', ...options }) /** * version info + * * Returns version information for the service */ -export const infoVersion = ( +export const info_version = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - InfoVersionResponse, - unknown, - ThrowOnError - >({ +): RequestResult => + (options?.client ?? client).get({ url: '/info/version', ...options, }) -} /** * Get a specific NFD by name or by its application ID + * * Get a specific NFD by name or by its application ID */ -export const nfdGetNfd = ( +export const nfd_getNfd = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdGetNfdResponse, - NfdGetNfdError, +): RequestResult => + (options.client ?? client).get< + NfdGetNfdResponses, + NfdGetNfdErrors, ThrowOnError - >({ - url: '/nfd/{nameOrID}', - ...options, - }) -} + >({ url: '/nfd/{nameOrID}', ...options }) /** * Fetch change activity for an NFD + * * Fetch change activity for an NFD, specifically general 'block-level' deltas for an NFD */ -export const nfdActivity = ( +export const nfd_activity = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdActivityResponse, - NfdActivityError, +): RequestResult => + (options.client ?? client).get< + NfdActivityResponses, + NfdActivityErrors, ThrowOnError - >({ - url: '/nfd/activity', - ...options, - }) -} + >({ url: '/nfd/activity', ...options }) /** * Fetch NFD analytics via various filters + * * Fetch NFD analytics via various filters */ -export const nfdAnalytics = ( +export const nfd_analytics = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdAnalyticsResponse, - NfdAnalyticsError, +): RequestResult => + (options?.client ?? client).get< + NfdAnalyticsResponses, + NfdAnalyticsErrors, ThrowOnError - >({ - url: '/nfd/analytics', - ...options, - }) -} + >({ url: '/nfd/analytics', ...options }) /** * Fetch badge information (donations/etc) for an NFD + * * Fetch badge information (ie: donations) for an NFD */ -export const nfdBadges = ( +export const nfd_badges = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdBadgesResponse, - NfdBadgesError, +): RequestResult => + (options.client ?? client).get< + NfdBadgesResponses, + NfdBadgesErrors, ThrowOnError - >({ - url: '/nfd/badges/{name}', - ...options, - }) -} + >({ url: '/nfd/badges/{name}', ...options }) /** * blueskyLeaders nfd + * * Get top bluesky influencers */ -export const nfdBlueskyLeaders = ( +export const nfd_blueskyLeaders = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdBlueskyLeadersResponse, - NfdBlueskyLeadersError, +): RequestResult< + NfdBlueskyLeadersResponses, + NfdBlueskyLeadersErrors, + ThrowOnError +> => + (options?.client ?? client).get< + NfdBlueskyLeadersResponses, + NfdBlueskyLeadersErrors, ThrowOnError - >({ - url: '/nfd/bluesky/leaders', - ...options, - }) -} + >({ url: '/nfd/bluesky/leaders', ...options }) /** * Browse NFDs via various filters */ -export const nfdBrowse = ( +export const nfd_browse = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdBrowseResponse, - NfdBrowseError, +): RequestResult => + (options?.client ?? client).get< + NfdBrowseResponses, + NfdBrowseErrors, ThrowOnError - >({ - url: '/nfd/browse', - ...options, - }) -} + >({ url: '/nfd/browse', ...options }) /** * consensusLeaders nfd + * * Get top consensus leaders */ -export const nfdConsensusLeaders = ( +export const nfd_consensusLeaders = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdConsensusLeadersResponse, - NfdConsensusLeadersError, +): RequestResult< + NfdConsensusLeadersResponses, + NfdConsensusLeadersErrors, + ThrowOnError +> => + (options?.client ?? client).get< + NfdConsensusLeadersResponses, + NfdConsensusLeadersErrors, ThrowOnError - >({ - url: '/nfd/consensus/leaders', - ...options, - }) -} + >({ url: '/nfd/consensus/leaders', ...options }) /** * consensusMetrics nfd + * * Get general metrics about Algorand consensus */ -export const nfdConsensusMetrics = ( +export const nfd_consensusMetrics = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdConsensusMetricsResponse, - NfdConsensusMetricsError, +): RequestResult< + NfdConsensusMetricsResponses, + NfdConsensusMetricsErrors, + ThrowOnError +> => + (options?.client ?? client).get< + NfdConsensusMetricsResponses, + NfdConsensusMetricsErrors, ThrowOnError - >({ - url: '/nfd/consensus/metrics', - ...options, - }) -} + >({ url: '/nfd/consensus/metrics', ...options }) /** * contractLock nfd + * * Lock/Unlock an NFD contract - if locked, the contract can never being modified until unlocked again by the owner. */ -export const nfdContractLock = ( +export const nfd_contractLock = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdContractLockResponse, - NfdContractLockError, +): RequestResult< + NfdContractLockResponses, + NfdContractLockErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdContractLockResponses, + NfdContractLockErrors, ThrowOnError >({ url: '/nfd/contract/lock/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * contractUpgrade nfd + * * Request upgrade of a pre 2.11 NFD to 2.11 (going no further) */ -export const nfdContractUpgrade = ( +export const nfd_contractUpgrade = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdContractUpgradeResponse, - NfdContractUpgradeError, +): RequestResult< + NfdContractUpgradeResponses, + NfdContractUpgradeErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdContractUpgradeResponses, + NfdContractUpgradeErrors, ThrowOnError >({ url: '/nfd/contract/upgrade/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * donations nfd + * * Fetch donation activity for an NFD, totalling amounts sent 'to' designated donation accounts */ -export const nfdDonations = ( +export const nfd_donations = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdDonationsResponse, - NfdDonationsError, +): RequestResult => + (options.client ?? client).get< + NfdDonationsResponses, + NfdDonationsErrors, ThrowOnError - >({ - url: '/nfd/donations/{name}', - ...options, - }) -} + >({ url: '/nfd/donations/{name}', ...options }) /** * getQuote nfd + * * get price / carry cost to mint or rewnew an NFD (if existing) */ -export const nfdGetQuote = ( +export const nfd_getQuote = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdGetQuoteResponse, - NfdGetQuoteError, +): RequestResult => + (options.client ?? client).get< + NfdGetQuoteResponses, + NfdGetQuoteErrors, ThrowOnError - >({ - url: '/nfd/getQuote/{name}', - ...options, - }) -} + >({ url: '/nfd/getQuote/{name}', ...options }) /** * isValidNFD nfd + * * Determines if specified NFD Application ID is authentic */ -export const nfdIsValidNfd = ( +export const nfd_isValidNfd = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdIsValidNfdResponse, - NfdIsValidNfdError, +): RequestResult => + (options.client ?? client).get< + NfdIsValidNfdResponses, + NfdIsValidNfdErrors, ThrowOnError - >({ - url: '/nfd/isValid/{appID}', - ...options, - }) -} + >({ url: '/nfd/isValid/{appID}', ...options }) /** * isValidASA nfd + * * Determines if specified NFD NFT ASA ID is authentic NFD */ -export const nfdIsValidAsa = ( +export const nfd_isValidAsa = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdIsValidAsaResponse, - NfdIsValidAsaError, +): RequestResult => + (options.client ?? client).get< + NfdIsValidAsaResponses, + NfdIsValidAsaErrors, ThrowOnError - >({ - url: '/nfd/isValidASA/{asaID}', - ...options, - }) -} + >({ url: '/nfd/isValidASA/{asaID}', ...options }) /** * linkAddress nfd + * * Link one or more addresses to an NFD, adding to the reverse-address lookups as well as to this NFD. Sender must be owner, and each added address must be able to be signed for. */ -export const nfdLinkAddress = ( +export const nfd_linkAddress = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdLinkAddressResponse, - NfdLinkAddressError, +): RequestResult => + (options.client ?? client).post< + NfdLinkAddressResponses, + NfdLinkAddressErrors, ThrowOnError >({ url: '/nfd/links/addAddress/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * unlinkAddress nfd + * * UnLink one or more addresses to an NFD, adding to the reverse-address lookups as well as to this NFD. Sender must be owner, and each added address must be able to be signed for. */ -export const nfdUnlinkAddress = ( +export const nfd_unlinkAddress = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdUnlinkAddressResponse, - NfdUnlinkAddressError, +): RequestResult< + NfdUnlinkAddressResponses, + NfdUnlinkAddressErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdUnlinkAddressResponses, + NfdUnlinkAddressErrors, ThrowOnError >({ url: '/nfd/links/removeAddress/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * setPrimaryAddress nfd + * * Set which of the currently verified addresses should be the first in the list (swapping positions as necessary) */ -export const nfdSetPrimaryAddress = ( +export const nfd_setPrimaryAddress = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdSetPrimaryAddressResponse, - NfdSetPrimaryAddressError, +): RequestResult< + NfdSetPrimaryAddressResponses, + NfdSetPrimaryAddressErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdSetPrimaryAddressResponses, + NfdSetPrimaryAddressErrors, ThrowOnError >({ url: '/nfd/links/setPrimaryAddress/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * setPrimaryNFD nfd + * * Set the specified NFD as the primary NFD to return for the specified address via its reverse lookup */ -export const nfdSetPrimaryNfd = ( +export const nfd_setPrimaryNfd = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdSetPrimaryNfdResponse, - NfdSetPrimaryNfdError, +): RequestResult< + NfdSetPrimaryNfdResponses, + NfdSetPrimaryNfdErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdSetPrimaryNfdResponses, + NfdSetPrimaryNfdErrors, ThrowOnError >({ url: '/nfd/links/setPrimaryNFD/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * Reverse Address lookup with results returned per address + * * Get the primary NFD for an address. Must be verified address, or if allowUnverified is set, it may match against an unverified address */ -export const nfdGetLookup = ( +export const nfd_getLookup = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdGetLookupResponse, - NfdGetLookupError, +): RequestResult => + (options.client ?? client).get< + NfdGetLookupResponses, + NfdGetLookupErrors, ThrowOnError - >({ - url: '/nfd/lookup', - ...options, - }) -} + >({ url: '/nfd/lookup', ...options }) /** * mint nfd + * * Mint a new NFD, with user buying specified NFD and paying for a prorated amount of time based on its yearly price. */ -export const nfdMint = ( +export const nfd_mint = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdMintResponse, - NfdMintError, +): RequestResult => + (options.client ?? client).post< + NfdMintResponses, + NfdMintErrors, ThrowOnError >({ url: '/nfd/mint', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * getNameSig nfd + * * Returns NameSig address for an NFD name (usable for V1 only) */ -export const nfdGetNameSig = ( +export const nfd_getNameSig = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdGetNameSigResponse, - NfdGetNameSigError, +): RequestResult => + (options.client ?? client).get< + NfdGetNameSigResponses, + NfdGetNameSigErrors, ThrowOnError - >({ - url: '/nfd/nameSig/{name}', - ...options, - }) -} + >({ url: '/nfd/nameSig/{name}', ...options }) /** * offer nfd + * * Offer up an NFD for sale - specifying price and optionally an address it is reserved for. */ -export const nfdOffer = ( +export const nfd_offer = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdOfferResponse, - NfdOfferError, +): RequestResult => + (options.client ?? client).post< + NfdOfferResponses, + NfdOfferErrors, ThrowOnError >({ url: '/nfd/offer/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * postOfferToOwner nfd + * * Post an offer to buy to the owner of an NFD, offering up a particular amount with optional note for them to consider */ -export const nfdPostOfferToOwner = ( +export const nfd_postOfferToOwner = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdPostOfferToOwnerResponse, - NfdPostOfferToOwnerError, +): RequestResult< + NfdPostOfferToOwnerResponses, + NfdPostOfferToOwnerErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdPostOfferToOwnerResponses, + NfdPostOfferToOwnerErrors, ThrowOnError >({ url: '/nfd/postOfferToOwner/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * purchase nfd + * * Purchase an NFD for sale - specifying buyer (to sign transaction) and price */ -export const nfdPurchase = ( +export const nfd_purchase = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdPurchaseResponse, - NfdPurchaseError, +): RequestResult => + (options.client ?? client).post< + NfdPurchaseResponses, + NfdPurchaseErrors, ThrowOnError >({ url: '/nfd/purchase/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * renew nfd + * * Renew or extend the expiration of an NFD. If current owner, renews at base price. If other owner, can take ownership but goes through reverse auction process for first 28 days where price drops to base price - with price being for 1 year */ -export const nfdRenew = ( +export const nfd_renew = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdRenewResponse, - NfdRenewError, +): RequestResult => + (options.client ?? client).post< + NfdRenewResponses, + NfdRenewErrors, ThrowOnError >({ url: '/nfd/renew', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * rescindOffer nfd + * * Rescind offer of sale. Claiming NFD back for self, and removing it for sale. */ -export const nfdRescindOffer = ( +export const nfd_rescindOffer = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdRescindOfferResponse, - NfdRescindOfferError, +): RequestResult< + NfdRescindOfferResponses, + NfdRescindOfferErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdRescindOfferResponses, + NfdRescindOfferErrors, ThrowOnError >({ url: '/nfd/rescindOffer/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * getRevAddressSig nfd + * * Returns RevAddress address for an NFD name (usable for V1 only) */ -export const nfdGetRevAddressSig = ( +export const nfd_getRevAddressSig = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdGetRevAddressSigResponse, - NfdGetRevAddressSigError, +): RequestResult< + NfdGetRevAddressSigResponses, + NfdGetRevAddressSigErrors, + ThrowOnError +> => + (options.client ?? client).get< + NfdGetRevAddressSigResponses, + NfdGetRevAddressSigErrors, ThrowOnError - >({ - url: '/nfd/revAddressSig/{address}', - ...options, - }) -} + >({ url: '/nfd/revAddressSig/{address}', ...options }) /** * segmentLeaders nfd + * * Get top segment roots */ -export const nfdSegmentLeaders = ( +export const nfd_segmentLeaders = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdSegmentLeadersResponse, - NfdSegmentLeadersError, +): RequestResult< + NfdSegmentLeadersResponses, + NfdSegmentLeadersErrors, + ThrowOnError +> => + (options?.client ?? client).get< + NfdSegmentLeadersResponses, + NfdSegmentLeadersErrors, ThrowOnError - >({ - url: '/nfd/segment/leaders', - ...options, - }) -} + >({ url: '/nfd/segment/leaders', ...options }) /** * Lock/Unlock an NFD segment - specifying open price if unlocking + * * Lock/Unlock an NFD segment - if locked, the segment only allows minted names created by the segment owner. If unlocked, anyone can mint off the segment for the price (in USD) the owner sets */ -export const nfdSegmentLock = ( +export const nfd_segmentLock = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdSegmentLockResponse, - NfdSegmentLockError, +): RequestResult => + (options.client ?? client).post< + NfdSegmentLockResponses, + NfdSegmentLockErrors, ThrowOnError >({ url: '/nfd/segment/lock/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * suggest nfd + * * Suggest NFDs to purchase */ -export const nfdSuggest = ( +export const nfd_suggest = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdSuggestResponse, - NfdSuggestError, +): RequestResult => + (options.client ?? client).get< + NfdSuggestResponses, + NfdSuggestErrors, ThrowOnError - >({ - url: '/nfd/suggest/{name}', - ...options, - }) -} + >({ url: '/nfd/suggest/{name}', ...options }) /** * totals nfd + * * Fetch NFD summary data - results subject to change in the future */ -export const nfdTotals = ( +export const nfd_totals = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdTotalsResponse, - NfdTotalsError, +): RequestResult => + (options?.client ?? client).get< + NfdTotalsResponses, + NfdTotalsErrors, ThrowOnError - >({ - url: '/nfd/totals', - ...options, - }) -} + >({ url: '/nfd/totals', ...options }) /** * twitterLeaders nfd + * * Get top twitter influencers */ -export const nfdTwitterLeaders = ( +export const nfd_twitterLeaders = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdTwitterLeadersResponse, - NfdTwitterLeadersError, +): RequestResult< + NfdTwitterLeadersResponses, + NfdTwitterLeadersErrors, + ThrowOnError +> => + (options?.client ?? client).get< + NfdTwitterLeadersResponses, + NfdTwitterLeadersErrors, ThrowOnError - >({ - url: '/nfd/twitter/leaders', - ...options, - }) -} + >({ url: '/nfd/twitter/leaders', ...options }) /** * updatePartial nfd + * * Set an attribute in an NFD on behalf of a particular sender (who must be the owner). Can set user-defined fields, or clear verified fields (except v.ca*) */ -export const nfdUpdatePartial = ( +export const nfd_updatePartial = ( options: Options, -) => { - return (options.client ?? _heyApiClient).patch< - NfdUpdatePartialResponse, - NfdUpdatePartialError, +): RequestResult< + NfdUpdatePartialResponses, + NfdUpdatePartialErrors, + ThrowOnError +> => + (options.client ?? client).patch< + NfdUpdatePartialResponses, + NfdUpdatePartialErrors, ThrowOnError >({ url: '/nfd/update/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * updateAll nfd + * * Replace all NFD user-settable attributes with those passed-in, removing, adding and replacing on behalf of a particular sender (who must be the owner). Returns transaction group of transactions to sign */ -export const nfdUpdateAll = ( +export const nfd_updateAll = ( options: Options, -) => { - return (options.client ?? _heyApiClient).put< - NfdUpdateAllResponse, - NfdUpdateAllError, +): RequestResult => + (options.client ?? client).put< + NfdUpdateAllResponses, + NfdUpdateAllErrors, ThrowOnError >({ url: '/nfd/update/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * updateImage nfd + * * Update the avatar or banner image associated with an NFD by uploading new image content */ -export const nfdUpdateImage = ( +export const nfd_updateImage = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdUpdateImageResponse, - NfdUpdateImageError, +): RequestResult => + (options.client ?? client).post< + NfdUpdateImageResponses, + NfdUpdateImageErrors, ThrowOnError - >({ - url: '/nfd/updateImage/{name}/{sender}/{which}', - ...options, - }) -} + >({ url: '/nfd/updateImage/{name}/{sender}/{which}', ...options }) /** * Reverse Address lookup with results returned per address + * * Get all NFDs which have been explicitly linked to one or more verified [or unverified] Algorand address(es). Unverified addresses will match but return as unverifiedCaAlgo array. These should be treated specially and not have the same trust level as verified addresses as they can be falsely attributed. The caAlgo array is what should be trusted for things like NFT creation addresses. For reverse lookups returning multiple NFDs, the first result should be used. */ -export const nfdGetNfdsForAddressesV2 = ( +export const nfd_getNfdsForAddressesV2 = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdGetNfdsForAddressesV2Response, - NfdGetNfdsForAddressesV2Error, +): RequestResult< + NfdGetNfdsForAddressesV2Responses, + NfdGetNfdsForAddressesV2Errors, + ThrowOnError +> => + (options.client ?? client).get< + NfdGetNfdsForAddressesV2Responses, + NfdGetNfdsForAddressesV2Errors, ThrowOnError - >({ - url: '/nfd/v2/address', - ...options, - }) -} + >({ url: '/nfd/v2/address', ...options }) /** * donationLeadersV2 nfd + * * Get top donors to a specific NFD Donation target */ -export const nfdDonationLeadersV2 = ( +export const nfd_donationLeadersV2 = ( options: Options, -) => { - return (options.client ?? _heyApiClient).get< - NfdDonationLeadersV2Response, - NfdDonationLeadersV2Error, +): RequestResult< + NfdDonationLeadersV2Responses, + NfdDonationLeadersV2Errors, + ThrowOnError +> => + (options.client ?? client).get< + NfdDonationLeadersV2Responses, + NfdDonationLeadersV2Errors, ThrowOnError - >({ - url: '/nfd/v2/donations/leaders/{name}', - ...options, - }) -} + >({ url: '/nfd/v2/donations/leaders/{name}', ...options }) /** * donationListV2 nfd + * * Fetch list of tracked Donation NFD 'targets'. */ -export const nfdDonationListV2 = ( +export const nfd_donationListV2 = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdDonationListV2Response, - NfdDonationListV2Error, +): RequestResult< + NfdDonationListV2Responses, + NfdDonationListV2Errors, + ThrowOnError +> => + (options?.client ?? client).get< + NfdDonationListV2Responses, + NfdDonationListV2Errors, ThrowOnError - >({ - url: '/nfd/v2/donations/list', - ...options, - }) -} + >({ url: '/nfd/v2/donations/list', ...options }) /** * Search NFDs via various filters + * * Search NFDs via various filters */ -export const nfdSearchV2 = ( +export const nfd_searchV2 = ( options?: Options, -) => { - return (options?.client ?? _heyApiClient).get< - NfdSearchV2Response, - NfdSearchV2Error, +): RequestResult => + (options?.client ?? client).get< + NfdSearchV2Responses, + NfdSearchV2Errors, ThrowOnError - >({ - url: '/nfd/v2/search', - ...options, - }) -} + >({ url: '/nfd/v2/search', ...options }) /** * ContractUpgradeV3 nfd + * * Request upgrade of a 2.11 or 3.x NFD to 3.x+ (post renewals). First switch to 3.x will pay 1 year renewal fee */ -export const nfdContractUpgradeV3 = ( +export const nfd_ContractUpgradeV3 = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdContractUpgradeV3Response, - NfdContractUpgradeV3Error, +): RequestResult< + NfdContractUpgradeV3Responses, + NfdContractUpgradeV3Errors, + ThrowOnError +> => + (options.client ?? client).post< + NfdContractUpgradeV3Responses, + NfdContractUpgradeV3Errors, ThrowOnError >({ url: '/nfd/v3/contract/upgrade/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * vaultOptInLock nfd + * * Lock/Unlock ability for the specified NFD Vault to auto opt-in to assets, allowing airdrops from other accounts */ -export const nfdVaultOptInLock = ( +export const nfd_vaultOptInLock = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdVaultOptInLockResponse, - NfdVaultOptInLockError, +): RequestResult< + NfdVaultOptInLockResponses, + NfdVaultOptInLockErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdVaultOptInLockResponses, + NfdVaultOptInLockErrors, ThrowOnError >({ url: '/nfd/vault/lock/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * sendFromVault nfd + * * Send an amount of an asset [0 == ALGO] to another account FROM the NFD Vault. Only owner of NFD can send. */ -export const nfdSendFromVault = ( +export const nfd_sendFromVault = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdSendFromVaultResponse, - NfdSendFromVaultError, +): RequestResult< + NfdSendFromVaultResponses, + NfdSendFromVaultErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdSendFromVaultResponses, + NfdSendFromVaultErrors, ThrowOnError >({ url: '/nfd/vault/sendFrom/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * sendToVault nfd + * * Provide transaction to send an asset owned by sender account to an NFD vault. Call to have opt-in to vault will be included if necessary. Callable by NFD owner, or if Opt-in is UNLOCKED (or asset already opted-in), anyone can call */ -export const nfdSendToVault = ( +export const nfd_sendToVault = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdSendToVaultResponse, - NfdSendToVaultError, +): RequestResult => + (options.client ?? client).post< + NfdSendToVaultResponses, + NfdSendToVaultErrors, ThrowOnError >({ url: '/nfd/vault/sendTo/{name}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * verifyConfirm nfd + * * Verify a particular piece of data on, or off-chain. Each verification differs in its requirements */ -export const nfdVerifyConfirm = ( +export const nfd_verifyConfirm = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdVerifyConfirmResponse, - NfdVerifyConfirmError, +): RequestResult< + NfdVerifyConfirmResponses, + NfdVerifyConfirmErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdVerifyConfirmResponses, + NfdVerifyConfirmErrors, ThrowOnError >({ url: '/nfd/verify/confirm/{id}', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} /** * verifyRequest nfd + * * Request Verification for particular piece of data on, or off-chain. Each verification differs in its requirements. Returns data to be used in challenge */ -export const nfdVerifyRequest = ( +export const nfd_verifyRequest = ( options: Options, -) => { - return (options.client ?? _heyApiClient).post< - NfdVerifyRequestResponse, - NfdVerifyRequestError, +): RequestResult< + NfdVerifyRequestResponses, + NfdVerifyRequestErrors, + ThrowOnError +> => + (options.client ?? client).post< + NfdVerifyRequestResponses, + NfdVerifyRequestErrors, ThrowOnError >({ url: '/nfd/verify/request', ...options, headers: { 'Content-Type': 'application/json', - ...options?.headers, + ...options.headers, }, }) -} diff --git a/packages/sdk/src/api/types.gen.ts b/packages/sdk/src/api/types.gen.ts index 9aa632f..d197310 100644 --- a/packages/sdk/src/api/types.gen.ts +++ b/packages/sdk/src/api/types.gen.ts @@ -1,5 +1,95 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: + | 'https://api.nf.domains' + | 'https://api.testnet.nf.domains' + | 'https://api.betanet.nf.domains' + | 'http://localhost:80' + | (string & {}) +} + +/** + * Asset contains basic information about an asset (Fungible or Non-Fungible) + */ +export type Asset = { + /** + * amounts of the asset for any accounts it was found in (depending on filters) + */ + amounts: Array + /** + * An Algorand Account address + */ + creator: string + /** + * Number of decimal places for the ASA + */ + decimals: number + /** + * ASA ID + */ + id: number + /** + * URL of image w/in metatadata, if different to url + */ + imageUrl: string + name: string + /** + * Total number of units created for this ASA + */ + totalCreated: number + unitName: string + /** + * URL for ASA + */ + url: string +} + +/** + * AssetAmounts specifies an account and amount contained for that account + */ +export type AssetAmounts = { + /** + * An Algorand Account address + */ + account: string + /** + * Amount + */ + amount: number +} + +/** + * Collection of Asset records + */ +export type AssetRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array +} + +export type Attachment = { + contentType: string + height?: number + /** + * id of the media attachment + */ + id: string + size: number + url: string + width?: number +} + /** * BlueskyRecord contains information about an NFD w/ Verified Blueesky account and basic info on its metrics */ @@ -13,6 +103,48 @@ export type BlueskyRecord = { posts: number } +/** + * Collection of Bluesky records + */ +export type BlueskyRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array +} + +/** + * Collection of Consensus metrics data + */ +export type ConsensusMetricsData = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: { + [key: string]: Array<{ + [key: string]: string + }> + } +} + /** * ConsensusRecord contains information about an account that participated in consensus */ @@ -30,6 +162,25 @@ export type ConsensusRecord = { votes?: number } +/** + * Collection of Consensus records + */ +export type ConsensusRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array +} + export type ContractLockRequestBody = { /** * Whether to lock (true), or unlock (false) @@ -41,12 +192,146 @@ export type ContractLockRequestBody = { sender: string } +/** + * An event the client wants to distribute to other users + */ +export type ControlEvent = { + conversation?: ConversationEvent +} + +/** + * Notification of a control event - ie, user is typing something, etc. + */ +export type ControlNotification = { + conversation?: ConversationNotification +} + +export type ConversationDetails = { + /** + * NFD App ID of room + */ + appId: number + convId: string + description: string + imageUrl?: string + name: string + /** + * Name of NFD for room + */ + nfdName: string +} + +export type ConversationEvent = { + id: string + /** + * changes active conversation to conversationId + */ + setActive?: boolean + /** + * message id of last seen message in specified conversation + */ + setLastSeen?: string + /** + * sender is typing in the active (specified) conversation + */ + typing?: boolean +} + +export type ConversationNotification = { + /** + * conversation id + */ + id: string + /** + * indicates user has been removed from this conversation (likely lost permissions because of nfd being sold) + */ + removedFromConversation?: boolean + typingEvent?: ConversationTypingEvent +} + +export type ConversationState = { + /** + * ID of last seen message in this conversation + */ + lastSeenId?: string +} + +export type ConversationTypingEvent = { + senderUid: string + /** + * typing started, or stopped + */ + typing: boolean +} + +/** + * Direct Message + */ +export type Dm = { + attachments?: Array + conversationId: string + createdAt: string + hasAttachments?: boolean + id: string + reactions?: Array + recipUid: string + senderUid: string + text: string +} + +/** + * Direct Message Response in ack data event + */ +export type DmDataResp = { + conversationId: string + id: string +} + +export type DmConversation = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + meta?: Pagination + msgs: Array +} + +export type DmConversations = { + /** + * Cache-Control header + */ + 'cache-control'?: string + conversations: Array + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + meta?: Pagination +} + +export type DmWithState = { + latestDm: Dm + state: ConversationState +} + /** * Donation contains basic information about donation totals to specific addresses from accounts related to an NFD */ export type Donation = { /** - * Sender or Receiver Algorand address depending on request + * An Algorand Account address */ address: string /** @@ -55,7 +340,33 @@ export type Donation = { total: number } -export type _Error = { +/** + * Name and account defined as a donation target + */ +export type DonationAccount = { + /** + * An Algorand Account address + */ + address: string + /** + * url of image for this donation target + */ + image: string + name: string + /** + * Name of a NFD, alphanumeric only or emojis/alphanumeric + */ + nfd: string +} + +/** + * Collection of Donation records + */ +export type DonationRecords = { + results: Array +} + +export type Error = { /** * Is the error a server-side fault? */ @@ -82,6 +393,21 @@ export type _Error = { timeout: boolean } +export type ErrorResponse = { + /** + * error name + */ + code?: string + /** + * description of error if present + */ + message?: string + /** + * if rate-limited error, seconds remaining until rate limit expires + */ + secsRemaining?: number +} + export type GetQuoteResponseBody = { /** * extra needed to cover MBR (if necessary) - price already includes this amount @@ -91,6 +417,10 @@ export type GetQuoteResponseBody = { * whether the nfd exists. if so, cost is renewal, otherwise mint (including carry) */ exists: boolean + /** + * extra needed to cover MBR if linking address on mint + */ + extraCarryIfLinkOnMint: number /** * if nfd is in auction pricing for given buyer */ @@ -145,6 +475,10 @@ export type MintRequestBody = { * Address paying/signing for minting transaction */ buyer: string + /** + * Whether the buyer address (must also be owner!) should be automatically linked to the NFD upon minting + */ + linkOnMint?: boolean name: string /** * Address NFD is being minted for if not buyer @@ -180,13 +514,16 @@ export type Nfd = { * Cache-Control header */ 'cache-control'?: string + /** + * Category of NFD + */ category?: 'curated' | 'premium' | 'common' /** * Round this data was last fetched from */ currentAsOfBlock?: number /** - * account wallets should send funds to - precedence is: caAlgo[0], unverifiedCaAlgo[0], owner + * An Algorand Account address */ depositAccount?: string /** @@ -203,9 +540,12 @@ export type Nfd = { */ metaTags?: Array name: string + /** + * An Algorand Account address + */ nfdAccount?: string /** - * Owner of NFD + * An Algorand Account address */ owner?: string /** @@ -214,19 +554,28 @@ export type Nfd = { parentAppID?: number properties?: NfdProperties /** - * Reserved owner of NFD + * An Algorand Account address */ reservedFor?: string + /** + * Sale type of NFD + */ saleType?: 'auction' | 'buyItNow' /** * amount NFD is being sold for (microAlgos) */ sellAmount?: number /** - * RecipientUid of NFD sales + * An Algorand Account address */ seller?: string + /** + * An Algorand Account address + */ sigNameAddress?: string + /** + * State of NFD + */ state?: 'available' | 'minting' | 'reserved' | 'forSale' | 'owned' | 'expired' /** * Tags assigned to this NFD @@ -281,6 +630,25 @@ export type NfdActivity = { timeChanged: string } +/** + * Collection of NFD activity records + */ +export type NfdActivityRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array +} + /** * NFDAnalyticEvent contains a price history record for a point in time of an NFD */ @@ -291,6 +659,9 @@ export type NfdAnalyticEvent = { * extra amount paid to cover minimum balance requirements - add to price to determine total amount paid */ carryCost?: number + /** + * Category of NFD + */ category?: 'curated' | 'premium' | 'common' /** * NFD current owner - if set via includeOwner property @@ -319,6 +690,9 @@ export type NfdAnalyticEvent = { * price for one year mint/renew */ oneYearRenewalPrice?: number + /** + * Sale type of NFD + */ saleType?: 'auction' | 'buyItNow' seller?: string } @@ -339,7 +713,18 @@ export type NfdAnalyticRecord = { timestamp?: string } +/** + * Collection of NFD analytic records + */ export type NfdAnalyticRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string /** * Not returned, used in tagging for response to indicate if-none-match etag matched */ @@ -351,6 +736,105 @@ export type NfdAnalyticRecords = { total: number } +export type NfdAnalyticRecords2 = { + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array + /** + * total number of results, with data containing paged amount based on offset/limit + */ + total: number +} + +export type NfdAuction = { + /** + * Price in microAlgos + */ + ceilingPrice: number + /** + * Price in microAlgos + */ + currentPrice?: number + endTime: string + /** + * Price in microAlgos + */ + floorPrice: number + /** + * Name of a NFD, alphanumeric only or emojis/alphanumeric + */ + name: string + newEndTime?: string + /** + * Escrowed floor price in microAlgos + */ + newFloorPrice?: number + startTime: string +} + +export type NfdAuctionAndPrice = { + auctionInfo: NfdAuction + /** + * Change in price per minute + */ + changePerMinute?: number + /** + * Minutes elapsed so far in Auction + */ + elapsedMinutes?: number + /** + * Current price in microAlgos + */ + price?: number + /** + * Total number of minutes in Auction + */ + totalMinutes?: number +} + +/** + * Collection of NFD badge records + */ +export type NfdBadges = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: { + [key: string]: Array<{ + [key: string]: string + }> + } +} + +/** + * NFDMarketInfo contains price, category information from backend to provide pricing and type data to public api / user + */ +export type NfdMarketInfo = { + /** + * Category of NFD + */ + category: 'curated' | 'premium' | 'common' + /** + * Sell price in microAlgos + */ + price: number + /** + * Sale type of NFD + */ + saleType: 'auction' | 'buyItNow' +} + /** * NFDProperties contains the expanded metadata stored within an NFD contracts' global-state */ @@ -375,6 +859,85 @@ export type NfdProperties = { } } +/** + * NFT contains basic information that a gallery viewer can use when displaying NFTs for the user to choose from + */ +export type Nft = { + /** + * Amount + */ + amount: number + /** + * NFT ASA ID + */ + asaID: number + /** + * An Algorand Account address + */ + creator: string + /** + * Number of decimal places for the ASA + */ + decimals: number + /** + * URL of image w/in metatadata, if different to url + */ + imageUrl: string + name: string + /** + * Total number of units created for this ASA + */ + totalCreated: number + unitName: string + /** + * URL for ASA + */ + url: string +} + +/** + * Collection of NFT records + */ +export type NftRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array +} + +/** + * Collection of Linked Address and NFD results + */ +export type NfdLookupRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + nfds: { + [key: string]: NfdRecordinaddress + } +} + +/** + * NFD contains all known information about an NFD record + */ export type NfdRecord = { /** * NFD Application ID @@ -392,15 +955,26 @@ export type NfdRecord = { * Verified Algorand addresses for this NFD */ caAlgo?: Array + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * Category of NFD + */ category?: 'curated' | 'premium' | 'common' /** * Round this data was last fetched from */ currentAsOfBlock?: number /** - * account wallets should send funds to - precedence is: caAlgo[0], unverifiedCaAlgo[0], owner + * An Algorand Account address */ depositAccount?: string + /** + * ETag + */ + etag?: string expired?: boolean /** * Not returned, used in tagging for response to indicate if-none-match etag matched @@ -411,9 +985,12 @@ export type NfdRecord = { */ metaTags?: Array name: string + /** + * An Algorand Account address + */ nfdAccount?: string /** - * Owner of NFD + * An Algorand Account address */ owner?: string /** @@ -422,19 +999,28 @@ export type NfdRecord = { parentAppID?: number properties?: NfdProperties /** - * Reserved owner of NFD + * An Algorand Account address */ reservedFor?: string + /** + * Sale type of NFD + */ saleType?: 'auction' | 'buyItNow' /** * amount NFD is being sold for (microAlgos) */ sellAmount?: number /** - * RecipientUid of NFD sales + * An Algorand Account address */ seller?: string + /** + * An Algorand Account address + */ sigNameAddress?: string + /** + * State of NFD + */ state?: 'available' | 'minting' | 'reserved' | 'forSale' | 'owned' | 'expired' /** * Tags assigned to this NFD @@ -579,13 +1165,16 @@ export type NfdRecordinaddress = { * Cache-Control header */ 'cache-control'?: string + /** + * Category of NFD + */ category?: 'curated' | 'premium' | 'common' /** * Round this data was last fetched from */ currentAsOfBlock?: number /** - * account wallets should send funds to - precedence is: caAlgo[0], unverifiedCaAlgo[0], owner + * An Algorand Account address */ depositAccount?: string /** @@ -602,9 +1191,12 @@ export type NfdRecordinaddress = { */ metaTags?: Array name: string + /** + * An Algorand Account address + */ nfdAccount?: string /** - * Owner of NFD + * An Algorand Account address */ owner?: string /** @@ -613,19 +1205,28 @@ export type NfdRecordinaddress = { parentAppID?: number properties?: NfdProperties /** - * Reserved owner of NFD + * An Algorand Account address */ reservedFor?: string + /** + * Sale type of NFD + */ saleType?: 'auction' | 'buyItNow' /** * amount NFD is being sold for (microAlgos) */ sellAmount?: number /** - * RecipientUid of NFD sales + * An Algorand Account address */ seller?: string + /** + * An Algorand Account address + */ sigNameAddress?: string + /** + * State of NFD + */ state?: 'available' | 'minting' | 'reserved' | 'forSale' | 'owned' | 'expired' /** * Tags assigned to this NFD @@ -649,7 +1250,58 @@ export type NfdRecordinaddress = { export type NfdRecordinaddressCollection = Array +/** + * Collection of NFD results + */ +export type NfdRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + nfds?: NfdRecordCollection +} + +/** + * Collection of Linked Address and NFD results + */ +export type NfdV2AddressRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + nfds: { + [key: string]: NfdRecordinaddressCollection + } +} + +/** + * Collection of NFD browse results + */ export type NfdV2SearchRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string /** * Not returned, used in tagging for response to indicate if-none-match etag matched */ @@ -677,6 +1329,33 @@ export type OfferRequestBody = { sender: string } +export type Pagination = { + nextToken?: string + prevToken?: string +} + +export type Participant = { + activeNFD?: UserActiveNfd + algoAccount: string + uid: string +} + +export type PostDmEvent = { + /** + * array of media ids to attach to message + */ + attachments?: Array + conversationId: string + /** + * An Algorand Account address + */ + recipient: string + /** + * Text of message to send + */ + text: string +} + export type PostOfferToOwnerRequestBody = { /** * Note to pass along to the NFD owner. Must be provided but can be blank @@ -689,6 +1368,34 @@ export type PostOfferToOwnerRequestBody = { sender: string } +export type PostReactionEvent = { + conversationId: string + /** + * message id to add/update reaction on + */ + id: string + /** + * emoji to add as reaction - set as blank to remove reaction + */ + reaction: string +} + +export type PostRoomPostEvent = { + /** + * array of media ids to attach to message + */ + attachments?: Array + conversationId: string + /** + * ID of post being replied to + */ + replyTo?: string + /** + * Text of message to send + */ + text: string +} + export type PurchaseRequestBody = { buyer: string /** @@ -702,6 +1409,24 @@ export type RateLimited = { secsRemaining: number } +/** + * Reaction to a message + */ +export type Reaction = { + conversationId: string + reaction: string + reactionToId: string + senderUid: string +} + +/** + * Reaction Response in ack data event + */ +export type ReactionDataResp = { + conversationId: string + reactionToId: string +} + export type RenewRequestBody = { /** * Offer price in ALGO. Expiration time set prorated based on amount paid vs fixed per-year cost when years argument is used @@ -725,6 +1450,86 @@ export type RescindOfferRequestBody = { sender: string } +export type RoomConversation = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + meta?: Pagination + msgs: Array +} + +export type RoomConversations = { + /** + * Cache-Control header + */ + 'cache-control'?: string + conversations: Array + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + meta?: Pagination +} + +export type RoomParticipants = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + meta?: Pagination + participants: Array +} + +/** + * Room Post + */ +export type RoomPost = { + attachments?: Array + conversationId: string + createdAt: string + hasAttachments?: boolean + id: string + reactions?: Array + replyTo?: RoomPost + senderUid: string + text: string +} + +/** + * Room Post Response in ack data event + */ +export type RoomPostDataResp = { + conversationId: string + id: string +} + +export type RoomPostWithState = { + conversation: ConversationDetails + latestPost?: RoomPost + state: ConversationState +} + export type SegmentLockRequestBody = { /** * Whether to lock (true), or unlock (false) @@ -810,6 +1615,70 @@ export type SetPrimaryAddressRequestBody = { sender: string } +export type StreamingCmdAck = { + data?: StreamingDataResponse + /** + * Request ID from event this ack corresponds to + */ + requestId: string +} + +export type StreamingDataResponse = { + conversation?: ConversationEvent + dm?: DmDataResp + error?: ErrorResponse + reaction?: ReactionDataResp +} + +export type StreamingDataRoomPostResponse = { + conversation?: ConversationEvent + error?: ErrorResponse + post?: RoomPostDataResp + reaction?: ReactionDataResp +} + +export type StreamingDmEvent = { + control?: ControlEvent + dm?: PostDmEvent + reaction?: PostReactionEvent + /** + * ID for this event, returned in errors if this request fails + */ + requestId: string +} + +export type StreamingDmEventResponse = { + ack?: StreamingCmdAck + control?: ControlNotification + dm?: Dm + reaction?: Reaction +} + +export type StreamingRoomPostCmdAck = { + data?: StreamingDataRoomPostResponse + /** + * Request ID from event this ack corresponds to + */ + requestId: string +} + +export type StreamingRoomPostEvent = { + control?: ControlEvent + post?: PostRoomPostEvent + reaction?: PostReactionEvent + /** + * ID for this event, returned in errors if this request fails + */ + requestId: string +} + +export type StreamingRoomPostEventResponse = { + ack?: StreamingRoomPostCmdAck + control?: ControlNotification + post?: RoomPost + reaction?: Reaction +} + export type TotalsOkResponseBody = { contractTotals: { /** @@ -869,6 +1738,36 @@ export type TwitterRecord = { twitterHandle: string } +/** + * Collection of Twitter records + */ +export type TwitterRecords = { + /** + * Cache-Control header + */ + 'cache-control'?: string + /** + * ETag + */ + etag?: string + /** + * Not returned, used in tagging for response to indicate if-none-match etag matched + */ + 'match-check'?: string + results: Array +} + +export type UnlinkAddressRequestBody = { + /** + * Address(es) to unlink from the NFD (must be able to sign for it) + */ + address: Array + /** + * Address that will be signing the returned transactions. Should be owner of NFD + */ + sender: string +} + export type UpdatePartialRequestBody = { properties: NfdProperties /** @@ -877,6 +1776,25 @@ export type UpdatePartialRequestBody = { sender: string } +export type UserActiveNfd = { + /** + * activation time stamp + */ + activatedAt: string + /** + * nfd app id + */ + appID: number + /** + * nfd name + */ + name: string + /** + * owner of the application + */ + owner: string +} + export type VerifyConfirmRequestBody = { /** * Challenge value, optional depending on verification type @@ -891,6 +1809,20 @@ export type VerifyConfirmResponseBody = { confirmed: boolean } +/** + * Verification request response + */ +export type VerifyRequest = { + /** + * The data to use as a challenge, specific ot each type. The UI will provide instructions + */ + challenge?: string + /** + * Array of unsigned and/or signed grouped transactions to sign/submit prior to verification being allowed + */ + transactions?: string +} + export type VerifyRequestRequestBody = { /** * User defined field name to verify @@ -999,11 +1931,11 @@ export type NfdGetNfdErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1063,11 +1995,11 @@ export type NfdActivityErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1189,11 +2121,11 @@ export type NfdAnalyticsErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1206,7 +2138,7 @@ export type NfdAnalyticsResponses = { /** * OK response. */ - 200: NfdAnalyticRecords + 200: NfdAnalyticRecords2 } export type NfdAnalyticsResponse = @@ -1234,11 +2166,11 @@ export type NfdBadgesErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1277,11 +2209,11 @@ export type NfdBlueskyLeadersErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1416,11 +2348,11 @@ export type NfdBrowseErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1460,11 +2392,11 @@ export type NfdConsensusLeadersErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1501,11 +2433,11 @@ export type NfdConsensusMetricsErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1545,11 +2477,11 @@ export type NfdContractLockErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1585,15 +2517,15 @@ export type NfdContractUpgradeErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeNotNeeded: The NFD contract doesn't need upgraded */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1629,11 +2561,11 @@ export type NfdDonationsErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1673,15 +2605,15 @@ export type NfdGetQuoteErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: unknown + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1716,11 +2648,11 @@ export type NfdIsValidNfdErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1755,11 +2687,11 @@ export type NfdIsValidAsaErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1794,15 +2726,15 @@ export type NfdLinkAddressErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1823,7 +2755,7 @@ export type NfdLinkAddressResponse = NfdLinkAddressResponses[keyof NfdLinkAddressResponses] export type NfdUnlinkAddressData = { - body: LinkAddressRequestBody + body: UnlinkAddressRequestBody path: { /** * Name of a NFD, alphanumeric only or emojis/alphanumeric @@ -1838,15 +2770,15 @@ export type NfdUnlinkAddressErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1882,15 +2814,15 @@ export type NfdSetPrimaryAddressErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1926,15 +2858,15 @@ export type NfdSetPrimaryNfdErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -1984,11 +2916,11 @@ export type NfdGetLookupErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: unknown + 400: Error /** * notFound: Not Found response. */ - 404: unknown + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2020,15 +2952,15 @@ export type NfdMintErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: unknown + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2042,10 +2974,6 @@ export type NfdMintResponses = { * Returns (as escaped string) array of paired values representing a transaction group to submit to an Algorand node. u or s for unsigned or signed, followed by the base64-encoded message-pack of an unsigned transaction (to be signed by sender/buyer) or a signed transaction to be submitted as-is. */ 201: string - /** - * alreadyExists: NFD already exists - */ - 204: void } export type NfdMintResponse = NfdMintResponses[keyof NfdMintResponses] @@ -2066,11 +2994,11 @@ export type NfdGetNameSigErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2105,19 +3033,19 @@ export type NfdOfferErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * tooManyTransactions: The number of transactions allowed in a single transaction group (16) have been exceeded. Update fewer fields in one transaction, or if selling, reduce the data within the NFD first. */ - 413: _Error + 413: Error /** * rateLimited: Too Many Requests response. */ @@ -2151,11 +3079,11 @@ export type NfdPostOfferToOwnerErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2191,11 +3119,11 @@ export type NfdPurchaseErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: unknown + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2225,15 +3153,15 @@ export type NfdRenewErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2267,11 +3195,11 @@ export type NfdRescindOfferErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2307,11 +3235,11 @@ export type NfdGetRevAddressSigErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2348,11 +3276,11 @@ export type NfdSegmentLeadersErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2388,15 +3316,15 @@ export type NfdSegmentLockErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * segmentPriceTooLow: segment price doesn't meet minimum required price */ - 403: unknown + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2445,15 +3373,15 @@ export type NfdSuggestErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * segmentNotSupported: parent segment isn't at contract version supporting segments */ - 403: unknown + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2488,11 +3416,11 @@ export type NfdTotalsErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2527,11 +3455,11 @@ export type NfdTwitterLeadersErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2567,19 +3495,19 @@ export type NfdUpdatePartialErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * invalidFieldSet: You can only set user-defined properties, or clear verified properties */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * tooManyTransactions: The number of transactions allowed in a single transaction group (16) have been exceeded. Update fewer fields in one transaction, or if selling, reduce the data within the NFD first. */ - 413: _Error + 413: Error /** * rateLimited: Too Many Requests response. */ @@ -2615,19 +3543,19 @@ export type NfdUpdateAllErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * invalidFieldSet: You can only set user-defined properties, or clear verified properties */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * tooManyTransactions: The number of transactions allowed in a single transaction group (16) have been exceeded. Update fewer fields in one transaction, or if selling, reduce the data within the NFD first. */ - 413: _Error + 413: Error /** * rateLimited: Too Many Requests response. */ @@ -2675,19 +3603,19 @@ export type NfdUpdateImageErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * imageTooLarge: Images must be <10 Megabytes in size */ - 413: _Error + 413: Error /** * rateLimited: Too Many Requests response. */ @@ -2737,11 +3665,11 @@ export type NfdGetNfdsForAddressesV2Errors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: unknown + 400: Error /** * notFound: Not Found response. */ - 404: unknown + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2779,11 +3707,11 @@ export type NfdDonationLeadersV2Errors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2814,11 +3742,11 @@ export type NfdDonationListV2Errors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -2980,11 +3908,11 @@ export type NfdSearchV2Errors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -3019,15 +3947,15 @@ export type NfdContractUpgradeV3Errors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeNotNeeded: The NFD contract doesn't need upgraded */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -3063,11 +3991,11 @@ export type NfdVaultOptInLockErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -3103,15 +4031,15 @@ export type NfdSendFromVaultErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -3147,19 +4075,19 @@ export type NfdSendToVaultErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * upgradeRequired: The NFD contract needs upgraded before this operation will be allowed */ - 403: _Error + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * tooManyTransactions: The number of transactions allowed in a single transaction group (16) have been exceeded. */ - 413: _Error + 413: Error /** * rateLimited: Too Many Requests response. */ @@ -3195,15 +4123,15 @@ export type NfdVerifyConfirmErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * noNFDNSubscription: No active subscription to NFDN */ - 403: unknown + 403: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -3234,11 +4162,11 @@ export type NfdVerifyRequestErrors = { /** * invalidAddress: invalidAddress is returned for an Algorand address that doesn't appear to be valid */ - 400: _Error + 400: Error /** * notFound: Not Found response. */ - 404: _Error + 404: Error /** * rateLimited: Too Many Requests response. */ @@ -3257,12 +4185,3 @@ export type NfdVerifyRequestResponses = { export type NfdVerifyRequestResponse = NfdVerifyRequestResponses[keyof NfdVerifyRequestResponses] - -export type ClientOptions = { - baseUrl: - | 'https://api.nf.domains' - | 'https://api.testnet.nf.domains' - | 'https://api.betanet.nf.domains' - | 'http://localhost:80' - | (string & {}) -} diff --git a/packages/sdk/vite.config.ts b/packages/sdk/vite.config.ts index 3740ad3..57769a7 100644 --- a/packages/sdk/vite.config.ts +++ b/packages/sdk/vite.config.ts @@ -16,11 +16,7 @@ export default defineConfig({ }, outDir: 'dist', rollupOptions: { - external: [ - 'algosdk', - '@algorandfoundation/algokit-utils', - '@hey-api/client-fetch', - ], + external: ['algosdk', '@algorandfoundation/algokit-utils'], output: [ { format: 'es', diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac49a4b..45dd5bd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -430,9 +430,6 @@ importers: '@algorandfoundation/algokit-utils': specifier: ^8.2.2 version: 8.2.2(algosdk@3.7.0) - '@hey-api/client-fetch': - specifier: ^0.8.4 - version: 0.8.4 devDependencies: '@algorandfoundation/algokit-client-generator': specifier: ^4.0.9 @@ -979,10 +976,6 @@ packages: '@gerrit0/mini-shiki@1.27.2': resolution: {integrity: sha512-GeWyHz8ao2gBiUW4OJnQDxXQnFgZQwwQk05t/CVVgNBN7/rK8XZ7xY6YhLVv9tH3VppWWmr9DCl3MwemB/i+Og==} - '@hey-api/client-fetch@0.8.4': - resolution: {integrity: sha512-SWtUjVEFIUdiJGR2NiuF0njsSrSdTe7WHWkp3BLH3DEl2bRhiflOnBo29NSDdrY90hjtTQiTQkBxUgGOF29Xzg==} - deprecated: Starting with v0.73.0, this package is bundled directly inside @hey-api/openapi-ts. - '@hey-api/codegen-core@0.9.1': resolution: {integrity: sha512-s97jL1dgTMuiMHv2BZ1X4Tgd99Mf9GOvGdNqNcGwIMmnR+PgYNoraj4Zvp134MKsNCap/m7k0r0vKKnl56pj4w==} engines: {node: '>=22.18.0'} @@ -5597,8 +5590,6 @@ snapshots: '@shikijs/types': 1.29.2 '@shikijs/vscode-textmate': 10.0.2 - '@hey-api/client-fetch@0.8.4': {} - '@hey-api/codegen-core@0.9.1(magicast@0.3.5)': dependencies: '@hey-api/types': 0.1.4