流水线
流水线
流水线定义规范的集合导入与导出行为。每条流水线是模型旁的一个文件,自动被发现。
import { Schema } from 'effect';
import type { Pipelines } from './$types.js';
export default {
export: {
description: 'Streams every site as a CSV body.',
handler: ({ records }) => ({ filename: 'sites.csv', body: toCsv(records) })
},
import: {
description: 'Imports a client feed; each returned record is written by the platform.',
input: Schema.Struct({ sites: Schema.Array(SiteFeedRow) }),
handler: ({ input }) => input.sites.map((row) => ({ name: row.name }))
}
} satisfies Pipelines; 处处一致的单一约定
租户集合 UI、Agent 与集成复用同一流水线约定,因此在一个地方导入的文件在所有地方行为一致。
导入走同一条写入路径
一次导入发送一份文档。导入处理器用它自己的 Effect Schema 解码文档并返回插入负载;这批行一起通过同一条规范变更管线写入,因此策略、写入契约、历史、同步与审计与任何其他写入完全一致。
谁运行流水线
流水线不绑定单一调用方——同一份定义服务于每个触及集合数据的界面:
- 集合 UI ——集合表格上的导入与导出操作
- Agents ——Agent 通过其工具执行的批量摄取
- 集成 ——复用该约定的入站与出站投递
选择最窄的角色
配套角色刻意重叠——选择最合适的一个: