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/apps/api/src/modules/ledger/port.d.ts
T
ChaiHaoandClaude Fable 5 ec0b78c550 UI②:数据对象全用中文名 —— label 随物化落 PG 注释,全链读回
此前 label 在建表那一步就丢了,治理台只剩 project__intake_record 这种键给人看。
用表/列注释而非另建元数据表:名字与表同生共死,不会对不上。
设计台/运营台/对象详情/触发器下拉一律中文名在前、键在后。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
2026-07-28 02:33:09 +08:00

51 lines
2.2 KiB
TypeScript

/**
* module: ledger —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。
*/
import type { EnvelopeDraft, LedgerKey, LedgerQuery, LedgerRow } from '@contracts';
import type { MaterializedObject, SchemaChange } from './internal/domain/schema-merge.ts';
import type { DraftEntry } from './internal/domain/task-view.ts';
export type Clock = {
now(): Date;
};
export type IdGenerator = {
next(): string;
};
/** 数据事件的发射口 —— app 注入 `event` 模块的出口(§5.2) */
export type EventPublisher = {
publish(envelope: EnvelopeDraft): Promise<void>;
};
export type ObjectRef = {
readonly domain: string;
readonly object: string;
};
/**
* 台账存储 —— 运行时 DDL / DML 由声明生成,ORM 静态 schema 不适用,
* 一律 node-postgres 直写(§1 / ADR-002)。
*/
export type LedgerStore = {
/** 已物化对象的列与主键;未物化返回 undefined */
describe(ref: ObjectRef): Promise<MaterializedObject | undefined>;
/** 出参带人读名(表注释);没登记就没有 label,呈现退回对象键 */
listObjects(): Promise<Array<ObjectRef & {
label?: string | undefined;
}>>;
/** 执行「只增不破坏」的变更计划 */
applyChanges(ref: ObjectRef, changes: readonly SchemaChange[]): Promise<void>;
select(query: LedgerQuery): Promise<{
rows: LedgerRow[];
total: number;
}>;
selectByKeys(ref: ObjectRef, keys: readonly LedgerKey[]): Promise<LedgerRow[]>;
upsert(ref: ObjectRef, key: LedgerKey, values: LedgerRow): Promise<void>;
deleteRow(ref: ObjectRef, key: LedgerKey): Promise<void>;
/** 放行写的原子性:草稿合并与事件登记同一事务 */
transaction<T>(fn: (store: LedgerStore, drafts: DraftStore) => Promise<T>): Promise<T>;
};
/** 任务级草稿层 —— 推荐形态 ledger.__draft;物理形态可换,功能约束不可变(§7.2) */
export type DraftStore = {
list(taskId: string): Promise<Array<DraftEntry & ObjectRef>>;
listForObject(taskId: string, ref: ObjectRef): Promise<DraftEntry[]>;
put(taskId: string, ref: ObjectRef, entry: DraftEntry): Promise<void>;
clear(taskId: string): Promise<void>;
};