跳到主要内容

集成

集成

集成把外部收发行为绑定到集合。每个集成是模型旁的一个文件,自动被发现。

定义

把集成声明为 +integrations.ts 中的具名绑定——每个外部系统一个绑定,各自拥有独立的 receive 与 send 行为:

import type { Integrations } from './$types.js';

export default {
  accounting: {
    receive: { /* parse inbound payloads into collection writes */ },
    send: { /* deliver outbound payloads to the external system */ }
  }
} satisfies Integrations;

连接留在宿主

连接与密钥值仍然是宿主设施;租户源码只声明需求——凭据永远不会到达工作区代码。参见 设施

选择最窄的角色

配套角色刻意重叠——选择最合适的一个:

  • 钩子 ——变更不变量与同事务副作用( 钩子
  • 流水线 ——可复用的批量摄取与产物约定( 流水线
  • 集成 ——复用流水线的可靠外部投递