Archived
**资料文件全链**(用户:审核资料这一步要真产出 word/excel/md/html,前端能渲、点资料名能开)
接手时这一步一个文件都产不出来 —— S3 剧本白纸黑字写着「file_ref 本 MVP 阶段可留空」。
文件是台账那一行的投影,不另存一份:
· 声明 `file:{titleColumn,bodyColumn,formatColumn}`,它同时是授权面(没声明就点不开)
· 现造真字节 —— docx/xlsx 是自己打的 OOXML 包(zip-write:store+CRC32,零依赖)
· 读回来渲 —— 解的就是造出来那份字节,渲得出来才证明文件是真的
· 件上 `data-file-of` → 工作区二级界面(Word 纸面/Excel 网格/渲好的 md/沙箱 html)+ 下载原件
放行落地前把每一份冻进 `sys.task_asset_file`(迁移 0029):归档件点开的必须是签字那一刻
那一份,而资料落在主数据上、试跑单不落正式表 —— 不存这一份,收工后一个都点不开。
工作成果里「产出的资料」自成一摞。Markdown 富文本渲染顺带销账(仍零依赖)。
**Harness**
· 画面按「这一拍办完之后」在办的那一步挑 —— 从前拿拍首的局面决定拍尾的事:
收掉 S4、发出 S5 的卡,而屏上还摆着 S4 的只读件,人无处可填(墙要配路第四次现形)
· 验收「重做」真能退回重做,且打回后台账没动就不许再提交(软硬两段,不锁死单子)
· 立监听的授权面是清单声明;发卡的授权面是调人预算,不是计划项
· 读工具同参重调有兜底;空转写身后还有行动就不废串;finish 的 doneWhen 按写完后的草稿算
**界面**
· 翻件与翻页各归各位(从前二选一,多卡多页时页翻不动);没得翻写「—」不写 0/0
· 工作成果详情能翻份;表宽超出能横滑(E04/I01 抄版式时把 overflow-x 抄丢了)
· 查看面灰底滚过一屏变白 —— 两条独立的路都治了(沙箱内不同色 / 弹性子项不长个)
· 测试台「取不到」不再当成「还活着」
**活动**
E04 关系覆盖、I01 品牌内容各自补到验收线:判据全读基座数、判据指向的东西摆上卡面、
样例满载且名字 ≤14 字;提交前要裁的判据搬进说明书(模型会压拍,压过之后只有说明书还在)。
验收:e2e i01 4/4、e04 3/3 全部 released,资料在办中渲得出、放行后存了档点得开;
门禁 typecheck/lint/depcruise/1628 测全绿。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EEJX8Z7CHejvwmDQyPQuBX
270 lines
11 KiB
TypeScript
270 lines
11 KiB
TypeScript
/**
|
|
* 数据与台账(编码规范 §8.1 / §7.2;语义出处 OS 04 / 09,AM 10.3 / 11.1)。
|
|
*
|
|
* 三级寻址「数据域.数据对象.字段」+ 通用事务性接口 + 写三分(系统写 / 草稿写 / 放行写)。
|
|
* 写三分是 `ledger` 出口上的**三个不同方法**,不是一个带 flag 的方法 —— 调用方拿不到「绕门」的形态。
|
|
*/
|
|
import { z } from 'zod';
|
|
/**
|
|
* 数据域:活动自持域用活动名,共享域固定为 `shared`(AM 11.3 暗耦合禁令)。
|
|
* 活动间不得共享自持域的数据表;跨活动的事实只有两条路 —— 输出口载荷,或共享域。
|
|
*/
|
|
export declare const SHARED_DOMAIN = "shared";
|
|
export declare const ledgerAddressSchema: z.ZodObject<{
|
|
domain: z.ZodString;
|
|
object: z.ZodString;
|
|
field: z.ZodOptional<z.ZodString>;
|
|
}, z.core.$strip>;
|
|
export type LedgerAddress = z.infer<typeof ledgerAddressSchema>;
|
|
export declare function formatAddress(address: LedgerAddress): string;
|
|
export declare function parseAddress(text: string): LedgerAddress;
|
|
export declare function isSharedDomain(address: LedgerAddress): boolean;
|
|
/**
|
|
* 字段类型 —— 台账自生长的类型格。
|
|
* 「同名异型取能兼容双方的最宽类型」(放宽即增,不破坏);语义互斥才拦下(OS 04)。
|
|
*/
|
|
export declare const LEDGER_FIELD_TYPES: readonly ["text", "number", "integer", "boolean", "date", "timestamp", "json"];
|
|
export declare const ledgerFieldTypeSchema: z.ZodEnum<{
|
|
number: "number";
|
|
boolean: "boolean";
|
|
json: "json";
|
|
text: "text";
|
|
date: "date";
|
|
integer: "integer";
|
|
timestamp: "timestamp";
|
|
}>;
|
|
export type LedgerFieldType = z.infer<typeof ledgerFieldTypeSchema>;
|
|
/** 字段使用声明 —— 声明的是**活动要用什么字段**,不是对象该定义什么字段 */
|
|
export declare const fieldDeclarationSchema: z.ZodObject<{
|
|
name: z.ZodString;
|
|
type: z.ZodEnum<{
|
|
number: "number";
|
|
boolean: "boolean";
|
|
json: "json";
|
|
text: "text";
|
|
date: "date";
|
|
integer: "integer";
|
|
timestamp: "timestamp";
|
|
}>;
|
|
label: z.ZodOptional<z.ZodString>;
|
|
primaryKey: z.ZodDefault<z.ZodBoolean>;
|
|
masked: z.ZodDefault<z.ZodBoolean>;
|
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
tally: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
expect: z.ZodOptional<z.ZodBoolean>;
|
|
auto: z.ZodOptional<z.ZodBoolean>;
|
|
requiredWhen: z.ZodOptional<z.ZodObject<{
|
|
column: z.ZodString;
|
|
value: z.ZodString;
|
|
}, z.core.$strip>>;
|
|
}, z.core.$strip>;
|
|
export type FieldDeclaration = z.infer<typeof fieldDeclarationSchema>;
|
|
/**
|
|
* 台账对象的**性质** —— 这条数据归谁管、活多久、谁有权改它。
|
|
*
|
|
* 从前台账只有「地址 + 列」,没有这一维,于是**没人需要回答「这张表是什么」**——
|
|
* 后果不是不好看,是主键写歪了还没人发现:A4 的报价草案本该一单一份,
|
|
* 主键却只有 `pn`,第二单报同一个料号直接 upsert 覆盖上一单
|
|
* (实测:跑了四轮 A4,`quote_pricing.draft` 只剩最后一轮的 3 行;
|
|
* 而主键带了单号的 `quote_intake.record` 是 61 行 / 20 单,一单不少)。
|
|
*
|
|
* 分三类,判据是**机械的**,不靠感觉:
|
|
*
|
|
* · `record` 单据 —— 一单一份的过程与结论。主键**必含单标识**(`caseKey`),
|
|
* 放行即定稿、只增不改。它不需要「管理」,需要的是查得到、回放得出。
|
|
* · `master` 主数据 —— 跨单积累的经营资产(客户、供应商、料号规格、历史价)。
|
|
* 主键是**业务实体**,会被反复更新,下一单读它做判断。治理都在这一类上:
|
|
* 谁能改、依据是什么、怎么去重、多久算过期。
|
|
* · `derived` 派生 —— 能由前两类算出来的指标(落地率、命中率)。
|
|
* **本不该手写**:手写的派生值能和它的来源打架,而没人会发现。
|
|
* 标出来至少让它可被重算校验。
|
|
*/
|
|
export declare const LEDGER_OBJECT_KINDS: readonly ["record", "master", "derived"];
|
|
export declare const ledgerObjectKindSchema: z.ZodEnum<{
|
|
record: "record";
|
|
master: "master";
|
|
derived: "derived";
|
|
}>;
|
|
export type LedgerObjectKind = z.infer<typeof ledgerObjectKindSchema>;
|
|
export declare const LEDGER_KIND_LABEL: Readonly<Record<LedgerObjectKind, string>>;
|
|
export declare const LEDGER_KIND_DESC: Readonly<Record<LedgerObjectKind, string>>;
|
|
export declare const objectDeclarationSchema: z.ZodObject<{
|
|
domain: z.ZodString;
|
|
object: z.ZodString;
|
|
label: z.ZodOptional<z.ZodString>;
|
|
kind: z.ZodDefault<z.ZodEnum<{
|
|
record: "record";
|
|
master: "master";
|
|
derived: "derived";
|
|
}>>;
|
|
caseKey: z.ZodOptional<z.ZodString>;
|
|
file: z.ZodOptional<z.ZodObject<{
|
|
titleColumn: z.ZodString;
|
|
bodyColumn: z.ZodString;
|
|
formatColumn: z.ZodString;
|
|
}, z.core.$strip>>;
|
|
fields: z.ZodArray<z.ZodObject<{
|
|
name: z.ZodString;
|
|
type: z.ZodEnum<{
|
|
number: "number";
|
|
boolean: "boolean";
|
|
json: "json";
|
|
text: "text";
|
|
date: "date";
|
|
integer: "integer";
|
|
timestamp: "timestamp";
|
|
}>;
|
|
label: z.ZodOptional<z.ZodString>;
|
|
primaryKey: z.ZodDefault<z.ZodBoolean>;
|
|
masked: z.ZodDefault<z.ZodBoolean>;
|
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
tally: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
expect: z.ZodOptional<z.ZodBoolean>;
|
|
auto: z.ZodOptional<z.ZodBoolean>;
|
|
requiredWhen: z.ZodOptional<z.ZodObject<{
|
|
column: z.ZodString;
|
|
value: z.ZodString;
|
|
}, z.core.$strip>>;
|
|
}, z.core.$strip>>;
|
|
}, z.core.$strip>;
|
|
export type ObjectDeclaration = z.infer<typeof objectDeclarationSchema>;
|
|
export declare const ledgerRowSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
export type LedgerRow = z.infer<typeof ledgerRowSchema>;
|
|
export declare const ledgerKeySchema: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
export type LedgerKey = z.infer<typeof ledgerKeySchema>;
|
|
export declare const LEDGER_OPERATIONS: readonly ["insert", "update", "upsert", "delete"];
|
|
export declare const ledgerOperationSchema: z.ZodEnum<{
|
|
insert: "insert";
|
|
update: "update";
|
|
delete: "delete";
|
|
upsert: "upsert";
|
|
}>;
|
|
export type LedgerOperation = z.infer<typeof ledgerOperationSchema>;
|
|
export declare const ledgerMutationSchema: z.ZodObject<{
|
|
address: z.ZodObject<{
|
|
object: z.ZodString;
|
|
domain: z.ZodString;
|
|
}, z.core.$strip>;
|
|
operation: z.ZodEnum<{
|
|
insert: "insert";
|
|
update: "update";
|
|
delete: "delete";
|
|
upsert: "upsert";
|
|
}>;
|
|
key: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
values: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
}, z.core.$strip>;
|
|
export type LedgerMutation = z.infer<typeof ledgerMutationSchema>;
|
|
/** 查询:简单等值过滤 + 排序 + 分页(治理台数据管理的记录浏览也走这里) */
|
|
export declare const ledgerQuerySchema: z.ZodObject<{
|
|
address: z.ZodObject<{
|
|
object: z.ZodString;
|
|
domain: z.ZodString;
|
|
}, z.core.$strip>;
|
|
where: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
orderBy: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
field: z.ZodString;
|
|
dir: z.ZodEnum<{
|
|
desc: "desc";
|
|
asc: "asc";
|
|
}>;
|
|
}, z.core.$strip>>>;
|
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
}, z.core.$strip>;
|
|
export type LedgerQuery = z.infer<typeof ledgerQuerySchema>;
|
|
export declare const ledgerPageSchema: z.ZodObject<{
|
|
rows: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
total: z.ZodNumber;
|
|
}, z.core.$strip>;
|
|
export type LedgerPage = z.infer<typeof ledgerPageSchema>;
|
|
/**
|
|
* ① system —— 系统写:入站归一、流转记录、留痕。登记世界已发生的事实,不过放行门,
|
|
* 写入正式版并**即时产生数据事件**。
|
|
* ② draft —— 草稿写:任务级草稿层(读己之写:本任务可见、正式版不可见、**不产生数据事件**)。
|
|
* ③ release —— 放行写:草稿层合并入正式版,**此刻才产生数据事件**。
|
|
*/
|
|
export declare const WRITE_KINDS: readonly ["system", "draft", "release"];
|
|
export declare const writeKindSchema: z.ZodEnum<{
|
|
draft: "draft";
|
|
system: "system";
|
|
release: "release";
|
|
}>;
|
|
export type WriteKind = z.infer<typeof writeKindSchema>;
|
|
export declare const WRITE_KIND_LABEL: Readonly<Record<WriteKind, string>>;
|
|
/** 三分的不变量,机检用:只有 draft 不抛数据事件 */
|
|
export declare function emitsDataEvent(kind: WriteKind): boolean;
|
|
/** 任务视图 = 正式版 + 本任务草稿层;环内推进读它,不依赖事件(OS 09) */
|
|
export declare const taskViewRequestSchema: z.ZodObject<{
|
|
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
|
query: z.ZodObject<{
|
|
address: z.ZodObject<{
|
|
object: z.ZodString;
|
|
domain: z.ZodString;
|
|
}, z.core.$strip>;
|
|
where: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
orderBy: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
field: z.ZodString;
|
|
dir: z.ZodEnum<{
|
|
desc: "desc";
|
|
asc: "asc";
|
|
}>;
|
|
}, z.core.$strip>>>;
|
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
}, z.core.$strip>;
|
|
}, z.core.$strip>;
|
|
export type TaskViewRequest = z.infer<typeof taskViewRequestSchema>;
|
|
export declare const draftPatchSchema: z.ZodObject<{
|
|
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
|
address: z.ZodObject<{
|
|
object: z.ZodString;
|
|
domain: z.ZodString;
|
|
}, z.core.$strip>;
|
|
key: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
patch: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
tombstone: z.ZodDefault<z.ZodBoolean>;
|
|
}, z.core.$strip>;
|
|
export type DraftPatch = z.infer<typeof draftPatchSchema>;
|
|
/** 数据冲突检查(落地预检第五项):他单已改同一字段即预检不过(OS 7.3) */
|
|
export declare const draftConflictSchema: z.ZodObject<{
|
|
address: z.ZodObject<{
|
|
domain: z.ZodString;
|
|
object: z.ZodString;
|
|
field: z.ZodOptional<z.ZodString>;
|
|
}, z.core.$strip>;
|
|
key: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
field: z.ZodString;
|
|
draftValue: z.ZodUnknown;
|
|
officialValue: z.ZodUnknown;
|
|
baselineValue: z.ZodUnknown;
|
|
}, z.core.$strip>;
|
|
export type DraftConflict = z.infer<typeof draftConflictSchema>;
|
|
export declare const ACTION_INTENT_STATES: readonly ["drafted", "prechecked", "landed", "failed", "abandoned"];
|
|
export declare const actionIntentStateSchema: z.ZodEnum<{
|
|
failed: "failed";
|
|
drafted: "drafted";
|
|
prechecked: "prechecked";
|
|
landed: "landed";
|
|
abandoned: "abandoned";
|
|
}>;
|
|
export type ActionIntentState = z.infer<typeof actionIntentStateSchema>;
|
|
export declare const actionIntentSchema: z.ZodObject<{
|
|
id: z.ZodString;
|
|
taskId: z.core.$ZodBranded<z.ZodString, "TaskId", "out">;
|
|
tool: z.ZodString;
|
|
input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
idempotencyKey: z.ZodString;
|
|
state: z.ZodEnum<{
|
|
failed: "failed";
|
|
drafted: "drafted";
|
|
prechecked: "prechecked";
|
|
landed: "landed";
|
|
abandoned: "abandoned";
|
|
}>;
|
|
label: z.ZodString;
|
|
detail: z.ZodOptional<z.ZodString>;
|
|
error: z.ZodOptional<z.ZodString>;
|
|
}, z.core.$strip>;
|
|
export type ActionIntent = z.infer<typeof actionIntentSchema>;
|