Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@codespar/api-types

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codespar/api-types

Shared REST wire contract

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
68
-29.9%
Maintainers
1
Weekly downloads
 
Created
Source

@codespar/api-types

Shared REST wire contract for the CodeSpar managed-tier API at api.codespar.dev.

Every request body and response shape is defined once, as a Zod schema, and the matching TypeScript type is inferred from it. Both the backend (codespar-enterprise) and the dashboard (codespar-web) import from here — no more hand-rolled mirror types.

Why

Two bugs shipped in a 48-hour window because web and backend independently redeclared the same response types:

  • Newly-created API keys rendered as "Revoked" (revoked_at omitted on the create response, web type assumed present, undefined !== null was truthy).
  • API-key list came back empty (backend returns { keys: [...] }, web parsed data.api_keys).

Schemas here are the single source of truth. Parse responses at the fetch boundary and these failures become impossible — missing/renamed fields throw at runtime instead of rendering broken UI.

Usage

import {
  ApiKeyRowSchema,
  ListApiKeysResponseSchema,
  type ListApiKeysResponse,
} from "@codespar/api-types";

const res = await fetch("/v1/api-keys", { headers: { authorization: `Bearer ${token}` } });
const body: ListApiKeysResponse = ListApiKeysResponseSchema.parse(await res.json());
//    ^^^^ throws ZodError if the backend drifts

Every module exports both the schema (FooSchema) and the inferred type (Foo). Import whichever side you need.

Coverage

  • api-keys — create / list / row
  • projects — create / update / list / row
  • connections — create / list / row / webhook-secret rotation
  • servers — list / row / auth-schema
  • sessions — create / list / row / detail / tool-calls / execute

Versioning

  • This package mirrors the /v1/* REST surface of api.codespar.dev.
  • Additive changes (new field, new endpoint schema) → minor bump.
  • Breaking changes (field removed, type narrowed) → major bump, shipped alongside a matching backend release.

Keep TS + Python + backend aligned — drift is the loudest way to break trust.

FAQs

Package last updated on 24 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts