This repository has been archived on 2026-09-13. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
BPOS-TMP-REPO/api-report/packages/contracts/src/api/ingest.d.ts
T
xcsandClaude Opus 5 a5c8d4786d 契约:三个端与路由归属(access 必填)、Principal / 角色→端 / 名册同步 schema、退役路由标 @deprecated(ADR-012)
- packages/contracts/src/api/http.ts:新增 SURFACES / surfaceSchema / Surface / SURFACE_LABEL /
  RouteAccess;RouteContract.access 必填;API_ERROR_CODES 增 'gone'。
- packages/contracts/src/org.ts:staffSchema 补 email? / roles(realm 角色快照);新增
  principalSchema/Principal、roleAccessSchema/RoleAccess、rosterSyncOutcomeSchema/RosterSyncOutcome、
  inFlightWorkSchema/InFlightWork;旧岗位授权(grant* / governanceFunction*)与 sessionSchema/Session
  全部标 @deprecated 留一轮(web 编译不受影响,下个迭代删)。
- workbench.ts / governance.ts / ingest.ts:每条既有路由补 access(按所属端/两端共用/退役 public);
  新增 meRoute、authTicketRoute(access:'any')与 syncStaffRoute、setStaffPositionRoute、
  staffInFlightRoute、listRoleAccessRoute、setRoleAccessRoute、deleteRoleAccessRoute(access:'ops')。
- apps/api 的 org-service.ts 两处 staff.insert 补 roles: [](staffSchema 新必填字段,该文件下个
  迭代会整份替换,这里只是让本次 typecheck 过)。
- 新增 packages/contracts/src/__tests__/route-access.test.ts:95 条路由的 access 归属断言。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015kAzS35kMnZNt4YGgJXtfw
2026-08-25 15:54:20 +08:00

74 lines
2.8 KiB
TypeScript

/**
* 入站路由契约(编码规范 §8.1)。
*
* 通道入站 → 归属解析 → 统一事件流(OS 06)。MVP 的邮件通道以**模拟通道**接入:
* mock 只允许出现在**外界**(邮件通道与外部系统),系统内部机制不得 mock(README MVP 完成判据)。
*/
import { z } from 'zod';
/** 一封入站邮件的归一形状 —— 真实邮件通道与模拟通道共用 */
export declare const inboundMailSchema: z.ZodObject<{
messageId: z.ZodString;
threadId: z.ZodOptional<z.ZodString>;
from: z.ZodString;
to: z.ZodArray<z.ZodString>;
cc: z.ZodDefault<z.ZodArray<z.ZodString>>;
subject: z.ZodString;
body: z.ZodString;
receivedAt: z.ZodISODateTime;
attachments: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
contentType: z.ZodString;
size: z.ZodNumber;
ref: z.ZodString;
}, z.core.$strip>>>;
}, z.core.$strip>;
export type InboundMail = z.infer<typeof inboundMailSchema>;
export declare const ingestMailRoute: {
readonly method: "POST";
readonly path: "/api/ingest/channel/:channelId/mail";
readonly access: "public";
readonly params: z.ZodObject<{
channelId: z.core.$ZodBranded<z.ZodString, "ChannelId", "out">;
}, z.core.$strip>;
readonly body: z.ZodObject<{
messageId: z.ZodString;
threadId: z.ZodOptional<z.ZodString>;
from: z.ZodString;
to: z.ZodArray<z.ZodString>;
cc: z.ZodDefault<z.ZodArray<z.ZodString>>;
subject: z.ZodString;
body: z.ZodString;
receivedAt: z.ZodISODateTime;
attachments: z.ZodDefault<z.ZodArray<z.ZodObject<{
name: z.ZodString;
contentType: z.ZodString;
size: z.ZodNumber;
ref: z.ZodString;
}, z.core.$strip>>>;
}, z.core.$strip>;
readonly output: z.ZodObject<{
eventId: z.core.$ZodBranded<z.ZodString, "EventId", "out">;
resolution: z.ZodDiscriminatedUnion<[z.ZodObject<{
outcome: z.ZodLiteral<"owned">;
rule: z.ZodEnum<{
thread: "thread";
"listener-key": "listener-key";
"address-window": "address-window";
}>;
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
}, z.core.$strip>, z.ZodObject<{
outcome: z.ZodLiteral<"unowned">;
reason: z.ZodEnum<{
"no-match": "no-match";
ambiguous: "ambiguous";
"extract-failed": "extract-failed";
}>;
fallbackPosition: z.ZodOptional<z.core.$ZodBranded<z.ZodString, "PositionId", "out">>;
}, z.core.$strip>], "outcome">;
listenersHit: z.ZodNumber;
triggersHit: z.ZodNumber;
fellBackToMessage: z.ZodBoolean;
}, z.core.$strip>;
};
export type IngestMailOutput = z.infer<typeof ingestMailRoute.output>;