Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

@akashnetwork/console-api-types

Generated types and operations table for the akash console API. Consumed by @akashnetwork/openapi-sdk's createApi(...) to produce a typed client.

What's in here

  • src/schema.d.ts — generated by openapi-typescript from apps/api/swagger/openapi.json. Provides paths, components, and operations types.
  • src/operations.gen.ts — generated by scripts/gen-operations.ts. A flat operations table grouped by URL version (v1, …) keyed by operationId.
  • src/index.ts — public surface: re-exports paths, components, operationDefs (types) and operations, Operations (runtime).

Both generated files are committed; consumers do not need to regenerate to install.

Usage

import { createApi } from "@akashnetwork/openapi-sdk";
import { operations, type paths } from "@akashnetwork/console-api-types";

const api = createApi<paths, typeof operations>(operations, { baseUrl: "/api/proxy" });

const alerts = await api.v1.getAlerts();

Regeneration

The merged spec lives at apps/api/swagger/openapi.json (api routes + on-disk notifications spec). To refresh after an api change:

# from repo root — rebuilds the api spec, then this package
npm run sdk:gen

# or just this package, against the existing spec
npm run generate -w @akashnetwork/console-api-types

generate runs:

  1. openapi-typescript ../../apps/api/swagger/openapi.json -o src/schema.d.ts
  2. tsx scripts/gen-operations.ts — reads the spec, groups by URL version prefix, writes src/operations.gen.ts

Commit both regenerated files alongside any spec change.

Operation grouping

gen-operations.ts groups by URL version prefix (e.g. /v1/..."v1"), falling back to the first openapi tag, then "default". This keeps a stable api.v1.<operationId> surface across producers regardless of tag noise.

Operations without operationId are skipped

The generator silently skips routes that don't declare operationId. Today most apps/api routes are in this category, so this package's operations table is dominated by notifications. To bring more routes into the typed surface, add operationId to their createRoute(...) declarations.