iii-node-sdk

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Node.js SDK

Node.js SDK

The TypeScript/JavaScript SDK for connecting workers to the iii engine.
用于将worker连接到iii引擎的TypeScript/JavaScript SDK。

Documentation

文档

Install

安装

npm install iii-sdk
npm install iii-sdk

Key APIs

核心API

APIPurpose
registerWorker(url, { workerName })
Connect to the engine and return the
iii
client
iii.registerFunction(id, handler, options?)
Register a local async function handler
iii.registerFunction(id, httpConfig, options?)
Register an HTTP-invoked external function
iii.registerTrigger({ type, function_id, config, metadata? })
Bind a trigger to a function (with optional metadata)
iii.trigger({ function_id, payload, action? })
Invoke a function
TriggerAction.Void()
Fire-and-forget invocation mode
TriggerAction.Enqueue({ queue })
Durable async invocation mode
Logger
Structured logging
withSpan
,
getTracer
,
getMeter
OpenTelemetry instrumentation
iii.createChannel()
Binary streaming between workers
iii.createStream(name, adapter)
Custom stream implementation
iii.registerTriggerType(id, handler)
Custom trigger type registration
API用途
registerWorker(url, { workerName })
连接到引擎并返回
iii
客户端
iii.registerFunction(id, handler, options?)
注册本地异步函数处理程序
iii.registerFunction(id, httpConfig, options?)
注册通过HTTP调用的外部函数
iii.registerTrigger({ type, function_id, config, metadata? })
将触发器绑定到函数(可附带元数据)
iii.trigger({ function_id, payload, action? })
调用函数
TriggerAction.Void()
即发即弃调用模式
TriggerAction.Enqueue({ queue })
持久化异步调用模式
Logger
结构化日志
withSpan
,
getTracer
,
getMeter
OpenTelemetry 埋点工具
iii.createChannel()
Worker之间的二进制流通信
iii.createStream(name, adapter)
自定义流实现
iii.registerTriggerType(id, handler)
自定义触发器类型注册

RBAC Auth Result Fields

RBAC 认证结果字段

When implementing an auth function for RBAC workers, the
AuthResult
supports:
FieldPurpose
allowed_functions: string[]
Additional function IDs to allow
forbidden_functions: string[]
Function IDs to deny (overrides expose_functions)
allowed_trigger_types?: string[]
Trigger types the worker may register
allow_trigger_type_registration
Whether the worker can register new trigger types
function_registration_prefix?
Prefix applied to functions registered by worker
context: Record<string, unknown>
Arbitrary context forwarded to middleware/handlers
为RBAC worker实现认证函数时,
AuthResult
支持以下字段:
字段用途
allowed_functions: string[]
允许调用的额外函数ID列表
forbidden_functions: string[]
禁止调用的函数ID列表(优先级高于expose_functions)
allowed_trigger_types?: string[]
worker可注册的触发器类型列表
allow_trigger_type_registration
worker是否可以注册新的触发器类型
function_registration_prefix?
应用于worker注册函数的前缀
context: Record<string, unknown>
转发给中间件/处理程序的任意上下文数据

Browser SDK

浏览器SDK

For browser environments, use
iii-browser-sdk
(same API, adapted for browser WebSocket constraints). See
iii-browser-sdk
skill for details.
对于浏览器环境,请使用
iii-browser-sdk
(API相同,适配浏览器WebSocket限制)。详情请查看
iii-browser-sdk
技能。

Pattern Boundaries

模式边界

  • For usage patterns and working examples, see
    iii-functions-and-triggers
  • For HTTP endpoint patterns, see
    iii-http-endpoints
  • For HTTP middleware patterns, see
    iii-http-middleware
  • For browser-side usage, see
    iii-browser-sdk
  • For Python SDK, see
    iii-python-sdk
  • For Rust SDK, see
    iii-rust-sdk
  • 如需使用模式和工作示例,请查看
    iii-functions-and-triggers
  • 如需HTTP端点模式,请查看
    iii-http-endpoints
  • 如需HTTP中间件模式,请查看
    iii-http-middleware
  • 如需浏览器端使用方法,请查看
    iii-browser-sdk
  • 如需Python SDK,请查看
    iii-python-sdk
  • 如需Rust SDK,请查看
    iii-rust-sdk

When to Use

使用场景

  • Use this skill when the task is primarily about
    iii-node-sdk
    in the iii engine.
  • Triggers when the request directly asks for this pattern or an equivalent implementation.
  • 当任务主要涉及iii引擎中的
    iii-node-sdk
    时,使用本技能。
  • 当请求直接询问此模式或等效实现时触发。

Boundaries

边界限制

  • Never use this skill as a generic fallback for unrelated tasks.
  • You must not apply this skill when a more specific iii skill is a better fit.
  • Always verify environment and safety constraints before applying examples from this skill.
  • 切勿将本技能作为无关任务的通用回退方案。
  • 当有更特定的iii技能更合适时,不得使用本技能。
  • 在应用本技能中的示例前,务必验证环境和安全约束。