@ariestools/aries-datalake-client

中文文档
0.3.1发布于 2026/10/31LGPL-3.0-onlyTypeScriptES Module近 30 天下载 1945

Client SDK for the Aries on-demand XL1 datalake control plane

原始使用文档
文档目录4 节
  1. Entry points
  2. Bounded exact-root archive
  3. Multiple required datalakes
  4. Explicit public payload reads

@ariestools/aries-datalake-client

REST clients for the Aries datalake control and data planes, with Node-only local development helpers kept behind the Node entry point.

Entry points

  • @ariestools/aries-datalake-client is the Node entry point. It includes the REST clients plus local filesystem-backed clients, credentials, defaults, and ARIES_HOME helpers.
  • @ariestools/aries-datalake-client/browser is the browser entry point. It exports REST clients, the composite client, their interfaces, the asynchronous token-supplier contract, and browser-safe datalake wire contracts.

Use an asynchronous token supplier that is invoked for each request. The application adapter may return a still-valid short-lived token from page memory or request a fresh wallet JWT through the XL1 browser wallet gateway:

import {
  RestDatalakeClient,
  RestPayloadsClient,
} from '@ariestools/aries-datalake-client/browser'

// Application-supplied adapter around the installed XL1 wallet gateway.
// The wallet derives and signs the browser origin; the page does not supply it.
declare function requestWalletJwt(audience: string): Promise<string>

const authToken = async ({ audience }: { audience: string }): Promise<string> => {
  return await requestWalletJwt(audience)
}

const control = new RestDatalakeClient({
  baseUrl: 'https://control.example',
  authToken,
})

const payloads = new RestPayloadsClient({
  baseUrl: 'https://data.example',
  datalakeId: 'dl_example',
  authToken,
})

The supplier receives the exact control-plane audience or datalake id. Treat its return value as a sensitive, short-lived bearer token: cache it only in page memory when useful, and never persist it in browser storage or logs. The wallet gateway controls key access; the Aries HTTP services independently verify audience, signature, origin, scope, signer identity, and live ACL state.

Bounded exact-root archive

ExactRootArchive is available from both entries. Supply an explicit native SDK root-identity callback, configured hash domain and lake, a trusted append-only issuer, and all six positive finite limits: root count, request bytes, decoded response bytes, token bytes, whole-operation milliseconds and concurrent work. The client snapshots JSON bodies, verifies native roots, sends the native insert request, then independently resolves every required root through anonymous readback with credentials omitted and redirects rejected. Duplicate receipts never replace readback. No write cache, queue, automatic retry or recovery journal is introduced.

For the opt-in service-wallet profile, the issuer signs a JWT with the lake id as its exact audience and payloadScopes: ['payload:append'], without browser origin/scope or record/blob claims. The data plane must explicitly enable service wallet JWTs and the signer must hold a live runner grant. A live public-viewer grant independently permits readback. Tokens without payloadScopes retain legacy service authority and do not qualify this restricted profile.

ExactRootArchiveError reports a secret-free code and writeState: not-started, uncertain after dispatch, or acknowledged after an HTTP success. Every public failure is a fresh error with a validated code and captured write state; callback messages, causes and private receipts are discarded. A caller timeout does not undo storage. Pending callbacks/effects retain the concurrency slot until they settle, even after the caller receives cancellation. Late response bodies are cancelled, and native stream cancellation cleanup is awaited before that slot is released; hanging cleanup keeps capacity occupied. Byte limits count UTF-8 JSON requests and decoded response streams, including errors; raw network/decompression/header/chunk allocation limits belong to the trusted host transport. The trusted issuer separately bounds its own transport, returns no logged/persisted credentials and honors the supplied abort signal. The identity callback preserves client/application fields and uses the owning SDK projection for storage metadata; claimed hashes are never proof.

Multiple required datalakes

CompositePayloadsClient writes each target's eligible subset and verifies it by reading the content back. Configure a complete S3 collection alongside a selected Auto Drive collection using already authenticated RestPayloadsClient instances:

import { CompositePayloadsClient, type RestPayloadsClient } from '@ariestools/aries-datalake-client/browser'
import { asAnyPayload, PayloadBuilder } from '@xyo-network/sdk'

declare const autoDriveClient: RestPayloadsClient
declare const s3Client: RestPayloadsClient

const composite = new CompositePayloadsClient({
  identify: async (payload) => {
    const canonical = asAnyPayload(payload, true)
    return {
      hash: await PayloadBuilder.hash(canonical),
      dataHash: await PayloadBuilder.dataHash(canonical),
    }
  },
  targets: [
    {
      name: 'auto-drive',
      client: autoDriveClient,
      policy: {
        mode: 'selected',
        allowedSchemas: ['com.example.smallrecord'],
        maxPayloadBytes: 4096, // Example deployment limit, not a provider default.
        revision: 'v1',
      },
    },
    { name: 's3', client: s3Client, policy: { mode: 'all' } },
  ],
})

const result = await composite.insertWithReceipts([
  { schema: 'com.example.smallrecord', value: 1 },
  { schema: 'com.example.other', value: 2 },
])
const read = await composite.getWithReceipts(result.acknowledged.map(payload => payload._hash))

All targets are required for their eligible subset. A selected policy requires an explicit allowlist and positive byte limit; an empty list selects nothing. disallowedSchemas takes precedence. schemaMaxPayloadBytes may tighten the global byte limit, and isValid may supply a trusted structural validator. Sizes count UTF-8 JSON including client metadata and excluding storage metadata. The receiving service must enforce its policy independently; this client does not authorize permanent uploads or implement service quotas.

insert(payloads) returns the verified acknowledgment array, including duplicates; insertWithReceipts(payloads) also returns per-target eligibility and outcomes. A rejected expected-eligible item or failed required target throws CompositePayloadsWriteError. Its result retains verified partial success and sanitized receipts, not raw provider errors. A complete target's success does not satisfy a different target's obligation. Callers own durable retry state and policy-revision coordination; this client does not resume a failed operation.

get(hashes) and getMany(hashes) return verified payload arrays. getWithReceipts(hashes) adds source attribution. Reads try targets in declared order for unresolved hashes only. Provider errors or corrupt responses throw CompositePayloadsReadError; they are not silently converted into misses. Reads never copy content between targets. Supply canonical XYO PayloadBuilder hashes through identify; the composite package itself adds no XYO runtime dependency to browser consumers.

Only flat payload bodies are accepted. Validate and flatten known hydrated protocol envelopes before insertion. There is no global sequence, clear, delete, or usage API and no automatic registration into an XL1 connection. The payload-array insert/get methods are intended for a protocol adapter; keep the SDK's exact transaction-content acknowledgment check in that adapter. Successful read-back is readable storage, not proof of provider network archival.

Explicit public payload reads

Use RestPublicPayloadsReader when the provider has granted public viewer access to the datalake. This is separate from the authenticated clients above; an authentication failure never triggers an anonymous retry.

import { RestPublicPayloadsReader } from '@ariestools/aries-datalake-client/browser'

const reader = new RestPublicPayloadsReader({
  baseUrl: 'https://data.example/plane/v1/datalakes/dl_public',
  datalakeId: 'dl_public',
})
const controller = new AbortController()
const payload = await reader.get('configured-content-hash', {
  maxResponseBytes: 65_536,
  signal: controller.signal,
})

The reader exposes only get(hash, options?) and getMany(hashes, options?). It has no token supplier, header hooks, listing or mutation methods. Requests omit ambient credentials and reject redirects. Configuration accepts absolute HTTP(S) URLs, including a shared-host path prefix, and rejects userinfo and fragments. Local HTTP is permitted explicitly; address/DNS policy remains the host's responsibility. An optional fetchImpl is a trusted transport override that must retain those policies. Without it, fetch is resolved at request time.

maxResponseBytes is an optional positive safe integer. It counts decoded Fetch response-stream bytes before JSON parsing, on success and error responses, including the whole native object/array and its metadata. Omission means no size limit. It does not bound raw compressed traffic, headers, decompression work or connection buffers. The signal is forwarded to fetch and remains active during body consumption; aborting does not wait indefinitely for stream cleanup.

Successful reads validate the stored-payload shape and preserve all fields. Neither requested paths nor _hash/_dataHash metadata verify content identity; callers that need content assurance must hash and validate the returned data. Transport, size, cancellation, malformed-response and access failures remain failed reads, not evidence that an advertised object never existed.

Public viewer access applies to the whole datalake, including provider-side enumeration and usage APIs. Prefer a dedicated public viewer lake with authenticated writers; public runner access also permits mutations. New lakes are private until granted access, and browser access additionally requires the provider's CORS configuration. This client does not change ACLs or retention.

The public reader requires the released @ariestools/sdk 8.2.0 or a compatible 8.2 patch, plus its required @opentelemetry/api peer. It does not require zod for these reads; other SDK features and datalake peers can have separate needs.

版本与发布记录

@ariestools/aries-datalake-client 共发布 14 个版本,首次发布于 2026/07/22;过去 12 个月发布了 14 个版本。

版本发布日期距今
0.3.1latest2026/10/318 天前
0.3.02026/10/308 天前
0.2.12026/10/2711 天前
0.2.02026/10/021 个月前
0.1.222026/09/141 个月前
0.1.212026/09/131 个月前

关于 @ariestools/aries-datalake-client 的常见问题

@ariestools/aries-datalake-client 是什么?

Client SDK for the Aries on-demand XL1 datalake control plane

如何安装 @ariestools/aries-datalake-client?

在项目目录运行 npm install @ariestools/aries-datalake-client,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@opentelemetry/api(^1.10)、@ariestools/cli-kit-daemon(^2.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ariestools/aries-datalake-client 支持 TypeScript 吗?

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

@ariestools/aries-datalake-client 支持 ESM 还是 CommonJS?

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

@ariestools/aries-datalake-client 需要什么版本的 Node.js?

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

@ariestools/aries-datalake-client 可以商用吗?

@ariestools/aries-datalake-client 使用 LGPL-3.0-only 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@ariestools/aries-datalake-client 的下载量有多少?

根据 npm 官方下载统计,@ariestools/aries-datalake-client 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,945 次,日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ariestools/aries-datalake-client 还在维护吗?

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