普通用户建应用集成收尾:

- 问数据和个人应用的图放行绑定只读查询等合规工具的调用工具节点,只读和遮罩在这条路径上生效;被治理成写入的工具在只读运行里直接拒;知识库范围在工具层固定(图级默认值、参数名纠错、Agent 都改不了)
- 个人应用的刷新和个人蓝图的试运行只有拥有者能读:运行、事件、证据、工件、文件、运行与审批列表、对比、可验证报告、质询、假设分析、提取工作流一并收紧;个人蓝图的试运行不论谁发起都按个人应用约束
- 共享蓝图只给拥有者、对应应用的管理者、管理员,看不到的一律 404;审核副本归审核人;管理员看别人的个人应用只有元数据、可以归档
- 记录表跨版本汇总(只读挂载旧版本、按当前列 UNION ALL、各版本各自固定高水位,缺的版本照实写进印章);停用前发起的运行可以继续写旧版本;更正沿用原提交人、更正人记审计
- 约定收口:待办种类 review、事件 file.extracted、表单错误 file、模板定义带示例与预置;前端类型一次补齐、去掉临时的局部类型;审核待办卡不再给打不开的链接;读附件事件有中文说法;检查脚本补断言
This commit is contained in:
ThearchyHelios
2026-10-15 13:55:19 +08:00
parent a702a5c14b
commit 7739340607
95 changed files with 3107 additions and 611 deletions
+29 -16
View File
@@ -8,26 +8,28 @@
* 只有一层:顶层 object,字段是 string / number / integer / boolean,数组只装枚举字符串(多选)。
*
* 文件(normal-user-apps N9、§3.8):字段 type 为 object、x-widget 为 file,只有这个控件能用 object。值是上传后拿回的
* 引用 {file_id, name, size, sha256, type},规则和服务端 apps/forms.py 同一份:必填,形状是文件引用。允许的类型和大小
* 写在 x-file(accept、max_mb),只在上传时用,提交时不再查(上传那一步服务端已经核对过)。
* 引用 {file_id, name, size, sha256, type},规则和服务端 apps/forms.py 同一份:必填,形状是文件引用,不合时错误的 code 是
* file(同服务端 files/store.FILE_ERROR_CODE)。允许的类型和大小写在 x-file(accept、max_mb),只在上传时用,提交时不再查
* (上传那一步服务端已经核对过)。
*/
import type { FormError, FormField, FormSchema, FormWidget } from '../typesApp'
import type { FileLimits, FormError, FormField, FormSchema, FormWidget } from '../typesApp'
import type { FileRef } from '../typesBlueprint'
import { FILE_TEXT, FORM_TEXT } from './termsApp'
/** 文件控件的限制:允许的类型(MIME 或扩展名)、大小上限(MB)。x-file 由服务端随表单给 */
export interface FileLimits { accept?: string[]; max_mb?: number | null }
/** 表单字段上的 x-file(typesApp.FormField 还没有这一项,见报告的接口约定请求) */
/**
* 表单字段上的 x-file(FormField['x-file'])整理成控件用的样子:可选类型去掉空的,大小上限不是正数的当没写。
* 服务端保存表单时已经按同一套规则查过(apps/forms._file_field_problems),这里只防手写的老表单
*/
export function fileLimitsOf(field: FormField): FileLimits {
const raw = (field as FormField & { 'x-file'?: unknown })['x-file']
if (!raw || typeof raw !== 'object') return {}
const x = raw as { accept?: unknown; max_mb?: unknown }
const accept = Array.isArray(x.accept) ? x.accept.filter((a): a is string => typeof a === 'string' && !!a.trim())
: typeof x.accept === 'string' ? x.accept.split(',').map((a) => a.trim()).filter(Boolean) : undefined
const x = field['x-file']
if (!x || typeof x !== 'object') return {}
// 画布上手写的老图可能把可选类型写成一串逗号分隔的字
const raw: unknown = x.accept
const accept = Array.isArray(raw) ? raw.filter((a): a is string => typeof a === 'string' && !!a.trim())
: typeof raw === 'string' ? raw.split(',').map((a) => a.trim()).filter(Boolean) : undefined
return {
accept: accept?.length ? accept : undefined,
max_mb: typeof x.max_mb === 'number' && Number.isFinite(x.max_mb) && x.max_mb > 0 ? x.max_mb : null,
max_mb: typeof x.max_mb === 'number' && Number.isFinite(x.max_mb) && x.max_mb > 0 ? x.max_mb : undefined,
}
}
@@ -44,6 +46,17 @@ export function toFileRef(raw: FileRef): FileRef {
return { file_id: raw.file_id, name: raw.name, size: raw.size, sha256: raw.sha256, type: raw.type }
}
/** 表单引用的写法(同服务端 apps/tree.FORM_REF_PREFIX):{"$ref": "#/forms/<名字>"} */
const FORM_REF_PREFIX = '#/forms/'
/** 内联的表单原样交回;引用换成 forms 里的那一份;引用不到的是 null(同服务端 apps/tree.resolve_form) */
export function resolveForm(forms: Record<string, FormSchema> | null | undefined,
form: FormSchema | { $ref: string } | null | undefined): FormSchema | null {
if (!form) return null
if (!('$ref' in form)) return form
return form.$ref.startsWith(FORM_REF_PREFIX) ? forms?.[form.$ref.slice(FORM_REF_PREFIX.length)] ?? null : null
}
/** 字段顺序:x-order 里写到的在前(按写的顺序),没写到的按 properties 的原顺序跟在后面;不存在的名字跳过 */
export function fieldOrder(schema: FormSchema): string[] {
const props = schema.properties ?? {}
@@ -54,8 +67,8 @@ export function fieldOrder(schema: FormSchema): string[] {
/** 这个字段画成哪种控件:写了 x-widget 照它,没写按类型推 */
export function widgetOf(field: FormField): FormWidget {
if (field['x-widget']) return field['x-widget']
// 只有文件控件用 object(typesApp.FormField 的 type 还没列 object)
if ((field.type as string) === 'object') return 'file'
// 只有文件控件用 object
if (field.type === 'object') return 'file'
switch (field.type) {
case 'boolean': return 'checkbox'
case 'array': return 'multiselect'
@@ -139,7 +152,7 @@ export function validateForm(schema: FormSchema, values: Record<string, unknown>
function fieldError(field: FormField, v: unknown, required: boolean): Omit<FormError, 'path'> | null {
if (isEmpty(v)) return required ? { code: 'required', message: FORM_TEXT.required } : null
if (widgetOf(field) === 'file') return isFileRef(v) ? null : { code: 'type', message: FILE_TEXT.invalid }
if (widgetOf(field) === 'file') return isFileRef(v) ? null : { code: 'file', message: FILE_TEXT.invalid }
switch (field.type) {
case 'string': {
if (typeof v !== 'string') return { code: 'type', message: FORM_TEXT.type.string }
+5 -1
View File
@@ -4934,6 +4934,8 @@ export const ORIGIN_LABEL: Record<OriginKind, string> = {
app_backfill: '按新口径补算',
hook: '外部系统触发',
api: '接口',
trial: '蓝图试运行',
personal_app: '个人应用刷新',
}
export const ORIGIN_TEXT = {
@@ -5188,6 +5190,8 @@ export const NOTIFY_TEXT = {
'task.opened': '待办打开', 'task.escalated': '待办升级', 'task.expired': '待办超时', 'task.resolved': '待办处理完',
'action.unknown': '动作结果未知', 'action.failed': '动作失败', 'action.confirmed': '动作已生效',
'run.failed': '运行失败', 'run.finished': '运行结束',
// 个人应用提交审核有了结果(发布了或退回了),通知提交人:只对个人渠道、全局渠道有意义(服务端 notify/service.notify_review)
'review.done': '我提交审核的应用有结果',
} as Record<string, string>,
enabled: '启用',
signed: '已签名',
@@ -5624,7 +5628,7 @@ export const TASK_NOTIFY_TEXT = {
export const SETTINGS_ROLE_TEXT = {
subtitleUser: '个人的主题和通知',
themeLocal: '主题只保存在当前浏览器中,更换设备后需重新选择',
prefsReadOnly: '运行默认值、证据裁判和核查的设置全站共用,只有管理员可以修改',
prefsReadOnly: '运行默认值、证据裁判、核查和应用的设置全站共用,只有管理员可以修改',
notifyPersonal: '个人渠道只推送派给你的待办和你发起的实例的事件',
}
+30 -5
View File
@@ -65,11 +65,8 @@ export const APP_HOME_TEXT = {
taskNotFound: '待办不存在,所属的运行可能已被删除',
}
/**
* 待办的种类:看中断内容里的 kind,不看 mode(§3.7)。review 是个人应用提交审核(docs/design/normal-user-apps.md N7):
* typesApp 的 TaskKind 还没有它(契约待补),这里先按多一种写
*/
export const TASK_KIND_LABEL: Record<TaskKind | 'review', string> = {
/** 待办的种类:看中断内容里的 kind,不看 mode(§3.7)。review 是个人应用提交审核(docs/design/normal-user-apps.md N7) */
export const TASK_KIND_LABEL: Record<TaskKind, string> = {
approve: '人工审批',
input: '补充输入',
edit: '改稿',
@@ -547,6 +544,14 @@ export const FILE_TEXT = {
/** 值不是上传后拿回的引用(前后端同一条:必填,形状是文件引用) */
invalid: '请上传文件',
empty: '未上传',
// ---- 运行详情里读入附件的一行(file.extracted,服务端 files/text.py 的模板函数 file_text)。数由调用方按千分位写好 ----
extracted: (name: string, chars: string | null) => {
const what = name ? `读入附件「${name}」` : '读入附件'
return chars == null ? what : `${what}${name ? '' : ' '}${chars} 字`
},
extractedAll: (total: string) => `全文 ${total} 字,已全部读入`,
extractedCut: (chars: string, total: string) => `全文 ${total} 字,只读入了前 ${chars} 字,其余没有读入`,
extractFailed: (name: string) => (name ? `附件「${name}」抽不出文字` : '附件抽不出文字'),
typeLabels: {
'application/pdf': 'PDF', 'application/msword': 'Word', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'Word',
'application/vnd.ms-excel': 'Excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'Excel',
@@ -586,6 +591,7 @@ export const RECORDS_TEXT = {
more: '加载更多',
reload: '重新读取',
tableMissing: '这个应用还没有记录表:发布之后、有人提交过才会有记录',
preview: '按草稿预览:这里不列真实的记录,发布之后按看的人列出',
yes: '是',
no: '否',
}
@@ -625,6 +631,25 @@ export const PERSONAL_TEXT = {
rejectedNote: (note: string) => `上次的审核已退回:${note}`,
graphChanged: '蓝图在存成个人应用之后又改过:刷新按存下的那一版运行,要用改过的,请回到蓝图重新存成你的应用。',
graphChangedGo: '回到蓝图',
switchedOff: '管理员关闭了「使用者可以建个人应用」:已有的结果还能看,暂时不能刷新、提交审核',
// ---- 管理员看别人的个人应用:只有名称、拥有者、时间,可以归档,看不到内容
othersGroup: '使用者的个人应用',
othersGroupHint: '使用者自己建的个人应用。管理员只看得到名称、拥有者和时间,可以归档,看不到页面、运行和蓝图的内容',
owner: (who: string) => `拥有者:${who}`,
ownerUnknown: '拥有者未记录',
createdAt: (t: string) => `创建于 ${t}`,
updatedAt: (t: string) => `更新于 ${t}`,
stubTitle: (who: string) => `这是 ${who} 的个人应用`,
stubBody: '个人应用只有拥有者看得见。管理员看得到名称、拥有者和时间,可以归档,但看不到页面、运行和蓝图的内容。',
archive: '归档',
archiveTitle: (name: string) => `归档「${name}」?`,
archiveConsequences: [
'拥有者的应用列表里不再列出它,不能再刷新或提交审核',
'它的蓝图和以前的刷新记录照常保留,你看不到它们的内容',
'目前没有恢复的操作',
],
archiveConfirm: '归档个人应用',
archiveDone: (name: string) => `已归档「${name}」`,
}
/** 审核待办(个人应用提交审核,N7):处理人在待办里取一份共享副本,在副本上试运行、走发布单;不发布就退回 */
-1
View File
@@ -131,7 +131,6 @@ export const BLUEPRINT_TEXT = {
templateOf: (label: string, version: number) => `${label}(模板 v${version})`,
// 对到数据的项
dataTable: '表',
dataTableLabel: '中文名',
dataGrain: '粒度',
dataDate: '业务日期',
dataReuseText: (metric: string, version: number) => `复用口径卡里的「${metric}」(v${version}),不重写指标式`,