@alvera-ai/platform-sdk

中文文档
0.22.0发布于 2026/11/12MITTypeScriptES Module零依赖近 30 天下载 2150

Typed SDK for the Alvera platform API — manage data sources, tools, generic tables, AI agents, and action status updaters.

原始使用文档
文档目录10 节
  1. Install
  2. Quick start
  3. Session scopes
  4. A few things to know
  5. TypeScript configuration
  6. Environments
  7. Resources
  8. For coding agents
  9. Documentation
  10. License

@alvera-ai/platform-sdk

Typed TypeScript SDK for the Alvera platform API — manage datalakes, data sources, tools, AI agents, interoperability contracts, data activation clients, workflows, and more, all from a single typed client.

Install

npm install @alvera-ai/platform-sdk
# or: pnpm add / bun add / yarn add @alvera-ai/platform-sdk

Quick start

Authentication is two steps — mint a session, then build a typed client:

import {
  createSession,
  createIsolatedPlatformApi,
  type PlatformApi,
} from '@alvera-ai/platform-sdk'

// 1. mint a session (pass tenantSlug to scope it to a tenant)
const session = await createSession({
  baseUrl: 'https://api.alvera.ai',
  email,
  password,
  tenantSlug,
})

// 2. build a typed client
const api: PlatformApi = createIsolatedPlatformApi({
  baseUrl: 'https://api.alvera.ai',
  sessionToken: session.sessionToken,
})

// 3. call resources — every nested resource is tenant + datalake scoped
const { data: datalake } = await api.datalakes.create(tenantSlug, {
  name: 'Production Lake',
  type: 'raw',
  // …db_reader_* / db_writer_* + cloud_storage credentials…
})

const { data, meta } = await api.tools.list(tenantSlug, datalake.slug)

Session scopes

createSession mints one of three scopes:

  • root — Alvera root admin (user signup + confirmation).
  • tenantless — an authenticated user with no tenant yet; used once to create a tenant, or to accept an invitation. Omit tenantSlug.
  • tenant-scoped — the canonical bearer for tenant operations. Pass tenantSlug.

Holding more than one client in the same process (e.g. a test or an app serving multiple users)? Use createIsolatedPlatformApi — it builds a fresh, private client. createPlatformApi mutates a shared singleton and is only safe for a single bearer.

A few things to know

  • update() replaces the whole resource — there is no partial update; send the full body.
  • List endpoints return { data, meta } — destructure, don't iterate the response directly.
  • Slugs are server-derived — read slug off a create() response; never pre-compute it.
  • The SDK validates nothing client-side — a bad body comes back as a thrown 422 AlveraApiError with a source.pointer to the offending field.

TypeScript configuration

The SDK uses @hey-api/client-fetch, whose generated code references WHATWG fetch types — BodyInit, RequestInit, Headers, FormData, etc. Those names live in lib.dom.d.ts, not @types/node, so a Node-only consumer with "lib": ["ES2022"] in its tsconfig.json will see errors like Cannot find name 'BodyInit' when typechecking.

The fix is to add DOM and DOM.Iterable to your lib:

// tsconfig.json
{
  "compilerOptions": {
    "lib": ["ES2022", "DOM", "DOM.Iterable"]
    //               ^^^^^^^^^^^^^^^^^^^^^^^
    // Required by @hey-api/client-fetch — see hey-api/openapi-ts#2539.
    // Type-only: adds NOTHING to the runtime — Node 18+ provides real
    // fetch independently of these declarations.
  }
}

This is the workaround for hey-api's open issue #2539; drop the DOM entries again once the upstream fix emits self-contained types. Browser consumers (React, Vue, Next, Nuxt, Remix) already enable DOM / DOM.Iterable by default — no change needed.

Environments

Base URLs ship with the package, derived at build time from the servers[] block of the committed OpenAPI spec and exported as ENVIRONMENTS:

import { ENVIRONMENTS, DEFAULT_ENVIRONMENT } from '@alvera-ai/platform-sdk'

ENVIRONMENTS.local.base_url // http://localhost:4000
ENVIRONMENTS.demo.base_url  // https://demo.alvera.ai
ENVIRONMENTS.prod.base_url  // https://app.alvera.ai

DEFAULT_ENVIRONMENT // 'prod'

Pass the chosen base_url into createSession and createIsolatedPlatformApi.

Resources

Every resource is a typed namespace on the client (api.<resource>.<verb>):

ResourceOperations
pinghealth check
sessionsverify
authsignUp
adminconfirmUser
tenantslist, create
invitationslist, create, accept
datasetssearch, metadata, createUserSearch
datalakeslist, get, create, metadata, migrate, createUploadLink, createDownloadLink, textToSql, executeSql
dataSourceslist, create, update
toolslist, get, create, update, delete, testInvocation
genericTableslist, create
actionStatusUpdaterslist, create, update
aiAgentslist, get, create, update, delete, invoke
authenticatedLinksexchange, updateMessageTracking
dataActivationClientslist, get, create, update, delete, metadata, runManually, ingest, ingestFile, logs.list, logs.get
interoperabilityContractslist, get, create, update, delete, metadata, run
mdmverify
workflowslist, get, create, update, delete, metadata, execute, run, workflowLogs.list/get/download, batchLogs.list/get/start/stop/refresh

Tenant and datalake provisioning are performed by Alvera admins — contact your representative to onboard a new tenant.

For coding agents

This package ships an agent-docs corpus under .agent/ — it lands at node_modules/@alvera-ai/platform-sdk/.agent/ after install, and an agent that walks node_modules discovers it automatically. It is self-sufficient for building an app or a test suite against the SDK:

  • .agent/AGENTS.md — the index + per-resource reference.
  • .agent/cookbook/ — validated, runnable recipes: business cookbooks (one outcome each) and capability docs (one capability each, e.g. bulk-ingest, ai-agent-invoke, custom-tables, invite-team).

To wire a pointer to the corpus into your own project's AGENTS.md (and a @AGENTS.md import into CLAUDE.md), run — no global install needed:

npx @alvera-ai/platform-sdk llm-export

It writes an idempotent managed block; re-running replaces only that block.

Documentation

License

MIT — see LICENSE.

版本与发布记录

@alvera-ai/platform-sdk 共发布 154 个版本,首次发布于 2026/04/13;过去 12 个月发布了 154 个版本。

版本发布日期距今
0.22.0latest2026/11/121 天前
0.21.4-next.g952cac52026/11/112 天前
0.17.4support-0.17.42026/10/2717 天前
0.17.4-next.gfd8e37csupport-next2026/10/2618 天前
0.17.4-next.gc508af12026/10/2618 天前
0.17.4-next.g6daa7812026/10/2518 天前

其他发布通道:support-0.17.1 → 0.17.1,support-0.17.2 → 0.17.2,support-0.17.3 → 0.17.3,support-next → 0.17.4-next.gfd8e37c,support-0.17.4 → 0.17.4。

关于 @alvera-ai/platform-sdk 的常见问题

@alvera-ai/platform-sdk 是什么?

Typed SDK for the Alvera platform API — manage data sources, tools, generic tables, AI agents, and action status updaters.

如何安装 @alvera-ai/platform-sdk?

在项目目录运行 npm install @alvera-ai/platform-sdk,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 platform-sdk,可以用 npx platform-sdk 直接运行。

@alvera-ai/platform-sdk 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alvera-ai/platform-sdk 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@alvera-ai/platform-sdk 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@alvera-ai/platform-sdk 可以商用吗?

@alvera-ai/platform-sdk 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alvera-ai/platform-sdk 的下载量有多少?

根据 npm 官方下载统计,@alvera-ai/platform-sdk 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,150 次,日均约 72 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alvera-ai/platform-sdk 还在维护吗?

最新版本 0.22.0 发布于 2026/11/12(1 天前);至今共发布 154 个版本,其中过去 12 个月发布了 154 个;首次发布于 2026/04/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。