soma-kit 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -110
- package/bin/soma-kit.mjs +1 -1
- package/bin/soma.mjs +22 -0
- package/package.json +13 -7
- package/packs/finance/reconcile-board.ts +5 -2
- package/packs/finance/reconcile-desk/compile.ts +3 -2
- package/spec/generated/kit-app.schema.json +776 -38
- package/spec/generated/kit-page.schema.json +1613 -224
- package/spec/kit-grammar.json +770 -529
- package/spec/kit-grammar.schema.json +1962 -392
- package/src/app/app-config.ts +371 -347
- package/src/app/component-gate.ts +12 -15
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +174 -31
- package/src/app/define-kit-view.ts +100 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +13 -2
- package/src/app/kit-view-context.ts +290 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/server-pages.ts +8 -2
- package/src/app/server.ts +491 -101
- package/src/app/submit.types.ts +1 -1
- package/src/app/theme-endpoint.ts +63 -0
- package/src/app/theme-runtime-shared.ts +1 -0
- package/src/app/theme-runtime.ts +663 -0
- package/src/base/action-busy.ts +2 -2
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +47 -0
- package/src/base/alert.ts +5 -3
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +46 -29
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +1 -1
- package/src/base/choice.ts +28 -26
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +6 -6
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +9 -5
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +25 -11
- package/src/base/date.ts +85 -17
- package/src/base/divider.ts +2 -2
- package/src/base/fab.ts +11 -4
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +9 -3
- package/src/base/input.ts +42 -13
- package/src/base/kbd.ts +3 -1
- package/src/base/link.ts +4 -4
- package/src/base/listbox-core.ts +50 -30
- package/src/base/loading-gate.ts +133 -0
- package/src/base/mentions.ts +5 -5
- package/src/base/menu-button.ts +6 -1
- package/src/base/menu-core.ts +4 -0
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +2 -2
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +2 -2
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +4 -1
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +40 -8
- package/src/base/popup.ts +79 -14
- package/src/base/price-text.ts +2 -2
- package/src/base/progress.ts +2 -2
- package/src/base/qr-code.ts +4 -4
- package/src/base/qty-stepper.ts +9 -3
- package/src/base/range.ts +2 -2
- package/src/base/rating.ts +1 -1
- package/src/base/segmented.ts +4 -0
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +221 -29
- package/src/base/swap.ts +4 -1
- package/src/base/switch.ts +1 -1
- package/src/base/tag-input.ts +14 -10
- package/src/base/tag.ts +5 -1
- package/src/base/text.ts +39 -6
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +12 -9
- package/src/base/tree-select.ts +15 -8
- package/src/base/upload.ts +34 -5
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/category-crud/compile.ts +22 -36
- package/src/biz/checkout-page/compile.ts +21 -5
- package/src/biz/compose.ts +13 -27
- package/src/biz/define.ts +5 -4
- package/src/biz/import-wizard/compile.ts +22 -26
- package/src/biz/import-wizard/hub.ts +126 -61
- package/src/biz/import-wizard/shell.ts +3 -3
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +49 -20
- package/src/biz/link/shared.ts +115 -118
- package/src/biz/master-sub/compile.ts +31 -44
- package/src/biz/multi-board/compile.ts +34 -49
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +24 -15
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/page-templates/domain-templates.ts +80 -13
- package/src/biz/page-templates/result-page/compile.ts +11 -2
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/record-detail/compile.ts +47 -42
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/settings-center/compile.ts +6 -5
- package/src/biz/shared/action-host.ts +91 -211
- package/src/biz/shared/compile-helpers.ts +80 -0
- package/src/biz/shared/coordinator.ts +486 -83
- package/src/biz/shared/index.ts +8 -2
- package/src/biz/shared/overlay-shell.ts +80 -0
- package/src/biz/shared/pipes.ts +43 -30
- package/src/biz/shared/remove-key.ts +6 -0
- package/src/biz/shared/remove-wire.ts +29 -0
- package/src/biz/shared/runtime-hub.ts +216 -24
- package/src/biz/single-form/compile.ts +15 -37
- package/src/biz/standard-crud/compile.ts +62 -107
- package/src/biz/standard-crud/shell.ts +16 -66
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +130 -26
- package/src/cli/kit-init.ts +222 -0
- package/src/cli/service-endpoint-check.ts +425 -0
- package/src/cli/source-path-check.d.mts +17 -0
- package/src/cli/source-path-check.mjs +334 -0
- package/src/cli/view-writes.ts +752 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +509 -0
- package/src/compile/compile-page.ts +219 -72
- package/src/compile/component-candidates.ts +1 -1
- package/src/compile/hints.ts +30 -1
- package/src/compile/index.ts +1 -0
- package/src/compile/kit-error.ts +1 -0
- package/src/compile/locate.ts +21 -1
- package/src/compile/parse.ts +370 -41
- package/src/compile/redirect.ts +6 -2
- package/src/compile/styles.ts +35 -2
- package/src/compile/types.ts +18 -2
- package/src/compile/view-check.ts +151 -0
- package/src/data/amount-breakdown.ts +2 -2
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +2 -2
- package/src/data/assignment-picker.ts +40 -29
- package/src/data/async-result-panel.ts +62 -6
- package/src/data/breadcrumbs.ts +2 -2
- package/src/data/calendar.ts +22 -25
- package/src/data/carousel.ts +5 -2
- package/src/data/chart.ts +42 -34
- package/src/data/checklist.ts +2 -2
- package/src/data/code-view.ts +4 -2
- package/src/data/comment-thread.ts +5 -2
- package/src/data/confirm-dialog.ts +10 -0
- package/src/data/context-menu.ts +29 -37
- package/src/data/d9-util.ts +2 -18
- package/src/data/diff.ts +4 -2
- package/src/data/dock.ts +2 -2
- package/src/data/embed.ts +2 -1
- package/src/data/field-mapper.ts +31 -26
- package/src/data/flow-editor-contract.ts +1 -1
- package/src/data/flow-editor.ts +89 -100
- package/src/data/flow-node-options.ts +90 -0
- package/src/data/flow-remote-options.ts +0 -103
- package/src/data/footer.ts +2 -2
- package/src/data/form-draft-registry.ts +2 -4
- package/src/data/gantt.ts +14 -17
- package/src/data/hero.ts +2 -2
- package/src/data/image-viewer.ts +20 -26
- package/src/data/index.ts +0 -2
- package/src/data/item-list.ts +31 -22
- package/src/data/kanban.ts +43 -42
- package/src/data/media-grid.ts +14 -19
- package/src/data/menu.ts +2 -2
- package/src/data/mockup.ts +2 -2
- package/src/data/modal-dialog.ts +22 -18
- package/src/data/navbar.ts +7 -2
- package/src/data/notify-renderer.ts +235 -0
- package/src/data/object-form.ts +1036 -648
- package/src/data/pager.ts +65 -29
- package/src/data/permission-matrix.ts +20 -21
- package/src/data/permission-tree.ts +28 -26
- package/src/data/pricing-table.ts +9 -3
- package/src/data/reaction-bar.ts +77 -88
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +3 -3
- package/src/data/record-picker.ts +93 -50
- package/src/data/redirect.ts +32 -32
- package/src/data/remote-options.ts +13 -6
- package/src/data/request-console.ts +5 -3
- package/src/data/resident.ts +2 -1
- package/src/data/result-panel.ts +4 -2
- package/src/data/rich-text.ts +45 -55
- package/src/data/row-editor.ts +285 -52
- package/src/data/rule-builder.ts +18 -12
- package/src/data/shape-util.ts +4 -0
- package/src/data/stat-group.ts +243 -101
- package/src/data/static-registry.ts +22 -11
- package/src/data/steps.ts +2 -2
- package/src/data/survey.ts +24 -29
- package/src/data/system-switcher.ts +2 -2
- package/src/data/timeline.ts +2 -2
- package/src/data/tour-guide.ts +22 -29
- package/src/data/transfer.ts +27 -23
- package/src/data/tree-table.ts +96 -48
- package/src/data/tree.ts +27 -34
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +118 -76
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +12 -11
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +2 -2
- package/src/frames/shared.ts +23 -17
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +5 -5
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +2 -13
- package/src/frames/tabs-frame/wiring.ts +4 -8
- package/src/frames/top-main-frame.ts +1 -0
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +20 -4
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +1 -0
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +119 -25
- package/src/generated/kit-grammar-runtime.ts +430 -366
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +23 -27
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +71 -77
- package/src/object-renderer/collapse-wiring.ts +2 -2
- package/src/object-renderer/collection-expand.ts +2 -2
- package/src/object-renderer/collection-parts.ts +216 -100
- package/src/object-renderer/collection-table.ts +180 -42
- package/src/object-renderer/collection.ts +95 -79
- package/src/object-renderer/compile-data.ts +85 -100
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +8 -14
- package/src/object-renderer/display-checks.ts +3 -24
- package/src/object-renderer/emit-events.ts +186 -172
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +174 -132
- package/src/object-renderer/field-value.ts +593 -396
- package/src/object-renderer/filter-reload.ts +70 -0
- package/src/object-renderer/form-detail.ts +112 -2
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +405 -86
- package/src/object-renderer/request-actions.ts +230 -249
- package/src/object-renderer/table-actions.ts +195 -95
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +418 -84
- package/src/object-renderer/types.ts +128 -122
- package/src/object-renderer/view-binding.ts +196 -0
- package/src/page-target/ai-surface.ts +37 -0
- package/src/page-target/compile.ts +48 -8
- package/src/page-target/index.ts +8 -1
- package/src/page-target/intent-schema.ts +154 -28
- package/src/page-target/target.ts +257 -50
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +165 -0
- package/src/recipes/control.ts +219 -0
- package/src/recipes/index.ts +263 -0
- package/src/recipes/overlay.ts +182 -0
- package/src/recipes/state.ts +70 -0
- package/src/recipes/table-row.ts +51 -0
- package/src/recipes/typography.ts +87 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/envelope.ts +207 -0
- package/src/shared/escape.ts +57 -0
- package/src/shared/kit-error.ts +21 -0
- package/src/shared/paged-list-adapter.ts +240 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +175 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +38 -1
- package/src/theme/kit-theme.tpl +38 -1
- package/src/theme/nine-dim-structure.ts +77 -0
- package/src/theme/surface-layers.ts +97 -0
- package/src/theme/theme-tokens.ts +85 -79
- package/src/theme/theme-types.ts +71 -0
- package/src/theme/typography.ts +17 -17
- package/src/biz/shared/step-values.ts +0 -25
- package/src/biz/step-form/steps-ref.ts +0 -112
- package/src/data/options-bus.ts +0 -24
- package/src/data/prompt-dialog.ts +0 -235
- package/src/object-renderer/adopt-gate.ts +0 -333
- package/src/object-renderer/field-policy.ts +0 -89
- package/src/object-renderer/outcome-draft.ts +0 -61
- package/src/theme/nine-dim-palettes.ts +0 -1473
|
@@ -16,9 +16,14 @@ import type { KitAppContext } from '../compile/types';
|
|
|
16
16
|
import { blockThemeDomain } from '../theme/block-theme';
|
|
17
17
|
import {
|
|
18
18
|
aiActionOn,
|
|
19
|
+
aiFieldAccess,
|
|
20
|
+
aiFieldEmphasis,
|
|
21
|
+
aiKeysOf,
|
|
19
22
|
aiPermissions,
|
|
20
23
|
aiTones,
|
|
21
24
|
blockThemeAitIssues,
|
|
25
|
+
fieldHintKeys,
|
|
26
|
+
hintSlots,
|
|
22
27
|
isThemeKey,
|
|
23
28
|
kitAiDisplayMap,
|
|
24
29
|
kitAiWriter,
|
|
@@ -26,6 +31,7 @@ import {
|
|
|
26
31
|
kitFieldTypes,
|
|
27
32
|
kitViewSlots,
|
|
28
33
|
knownNonAiKeys,
|
|
34
|
+
roleShapeOf,
|
|
29
35
|
} from './ai-surface';
|
|
30
36
|
import { KIT_INTENT_MAP, frameKindOfIntent, kitFrameIntents, kitProductIntents, productKindOfIntent, type KitIntentMap } from './intent-map';
|
|
31
37
|
|
|
@@ -51,10 +57,16 @@ export interface KitIntentField {
|
|
|
51
57
|
readonly options?: readonly KitIntentOption[];
|
|
52
58
|
/** 展示语义词(text / tag / progress …,闭集在 aiDisplayMap);只作用于 list / summary 视图,组件名由目标映射,AI 不写 */
|
|
53
59
|
readonly display?: string;
|
|
60
|
+
/** 输入框占位提示(纯文本);只作用于 form / filter 视图里的该字段(aiWriter.fieldRef.placeholder) */
|
|
61
|
+
readonly placeholder?: string;
|
|
62
|
+
/** 字段说明文字(纯文本);只作用于 form / filter 视图里的该字段(aiWriter.fieldRef.help) */
|
|
63
|
+
readonly help?: string;
|
|
64
|
+
readonly access?: string;
|
|
65
|
+
readonly emphasis?: 'strong' | 'muted';
|
|
66
|
+
readonly highlight?: boolean;
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
export interface KitIntentObject {
|
|
57
|
-
readonly label?: string;
|
|
58
70
|
/** 已授权接口路径(读);是否在授权内由目标的 accept 对 ctx 核对 */
|
|
59
71
|
readonly api?: string;
|
|
60
72
|
/** 已授权接口路径(写) */
|
|
@@ -132,8 +144,19 @@ export const KIT_INTENT_SECTION_KEYS = ['product', 'objects', 'roles', 'views',
|
|
|
132
144
|
export const KIT_INTENT_THEME_KEY = 'theme';
|
|
133
145
|
export const KIT_INTENT_TOP_KEYS = ['title', 'subtitle', 'frame', ...KIT_INTENT_SECTION_KEYS, 'top', 'tabs', 'locale', 'notes', KIT_INTENT_THEME_KEY] as const;
|
|
134
146
|
export const KIT_INTENT_TAB_KEYS = ['id', 'title', ...KIT_INTENT_SECTION_KEYS, KIT_INTENT_THEME_KEY] as const;
|
|
135
|
-
export const KIT_INTENT_OBJECT_KEYS = ['
|
|
136
|
-
|
|
147
|
+
export const KIT_INTENT_OBJECT_KEYS = ['api', 'write_api', 'delete_api', 'fields'] as const;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 蓝图字段键,全部从真源派生(不手抄):
|
|
151
|
+
* name = 字段 id(蓝图自有);aiWriter.fieldRef 的 ai 键(label / placeholder / help);aiWriter.schema 的 ai 键(去掉 rules,规则由 aiRuleKeys 展开成 required / max_len);展示词键 aiDisplayMap.key。
|
|
152
|
+
* 每个键在 `FIELD_PROP_SCHEMAS` 里有结构化输出的取值 schema;真源新增 ai 键而这里没有取值 schema → `checkIntentSurface` 在装配期报出。
|
|
153
|
+
*/
|
|
154
|
+
export function deriveIntentFieldKeys(): readonly string[] {
|
|
155
|
+
const w = kitAiWriter();
|
|
156
|
+
const schemaKeys = aiKeysOf(w.schema).filter((k) => k !== 'rules' && k !== 'name');
|
|
157
|
+
return [...new Set(['name', ...aiKeysOf(w.fieldRef), ...schemaKeys, ...w.aiRuleKeys, kitAiDisplayMap().key])];
|
|
158
|
+
}
|
|
159
|
+
export const KIT_INTENT_FIELD_KEYS: readonly string[] = deriveIntentFieldKeys();
|
|
137
160
|
export const KIT_INTENT_OPTION_KEYS = ['value', 'label', 'tone'] as const;
|
|
138
161
|
export const KIT_INTENT_ACTION_KEYS = ['id', 'label', 'on', 'builtin', 'tone', 'role', 'confirm_text'] as const;
|
|
139
162
|
|
|
@@ -167,9 +190,62 @@ function themeSchema(): Record<string, unknown> {
|
|
|
167
190
|
};
|
|
168
191
|
}
|
|
169
192
|
|
|
193
|
+
/** 每个蓝图字段键的取值 schema(键集合由 `KIT_INTENT_FIELD_KEYS` 决定,缺项 → `checkIntentSurface` 报装配错误) */
|
|
194
|
+
const FIELD_PROP_SCHEMAS: Readonly<Record<string, () => Record<string, unknown>>> = {
|
|
195
|
+
name: () => ({ type: 'string', pattern: ID_PATTERN }),
|
|
196
|
+
label: () => STR,
|
|
197
|
+
type: () => ({ type: 'string', enum: [...kitFieldTypes()] }),
|
|
198
|
+
key: () => ({ type: 'boolean' }),
|
|
199
|
+
required: () => ({ type: 'boolean' }),
|
|
200
|
+
max_len: () => ({ type: 'integer', minimum: 1 }),
|
|
201
|
+
permission: () => ({ type: 'string', enum: [...aiPermissions()] }),
|
|
202
|
+
display: () => ({ type: 'string', enum: [...kitDisplayWords()], description: '展示语义词(只作用于 list / summary 视图;不写组件名)' }),
|
|
203
|
+
placeholder: () => ({ type: 'string', maxLength: kitAiWriter().limits.subtitleMax, description: '输入框占位提示(纯文本;只作用于 form / filter 视图里的该字段)' }),
|
|
204
|
+
help: () => ({ type: 'string', maxLength: kitAiWriter().limits.subtitleMax, description: '字段说明文字(纯文本;只作用于 form / filter 视图里的该字段)' }),
|
|
205
|
+
access: () => ({ type: 'string', enum: [...aiFieldAccess()], description: '字段访问权限(只读 read / 可写 write / 仅创建 create)' }),
|
|
206
|
+
emphasis: () => ({ type: 'string', enum: [...aiFieldEmphasis()], description: '字段视觉强调(strong 强显 / muted 弱化)' }),
|
|
207
|
+
highlight: () => ({ type: 'boolean', description: '字段视觉高亮' }),
|
|
208
|
+
options: () => {
|
|
209
|
+
const w = kitAiWriter();
|
|
210
|
+
return {
|
|
211
|
+
type: 'array',
|
|
212
|
+
maxItems: w.limits.optionsMax,
|
|
213
|
+
items: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
additionalProperties: false,
|
|
216
|
+
required: ['value', 'label'],
|
|
217
|
+
properties: { value: { type: ['string', 'number'] }, label: STR, tone: { type: 'string', enum: [...aiTones()] } },
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
function fieldProperties(): Record<string, unknown> {
|
|
224
|
+
return Object.fromEntries(KIT_INTENT_FIELD_KEYS.map((k) => [k, (FIELD_PROP_SCHEMAS[k] ?? (() => STR))()]));
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 装配期自检:蓝图字段键与真源对得上。真源 aiWriter 里 ai 级的字段键(fieldRef / schema / 规则 / 展示词)都能写,
|
|
229
|
+
* 且每个键都有取值 schema;有缺项说明真源新增了 ai 键而目标还没接,返回问题清单,由装配(createKitPageTarget)映射成配置错误。
|
|
230
|
+
*/
|
|
231
|
+
export function checkIntentSurface(): readonly PageDiagnostic[] {
|
|
232
|
+
const out: PageDiagnostic[] = [];
|
|
233
|
+
const keys = deriveIntentFieldKeys();
|
|
234
|
+
for (const k of keys) {
|
|
235
|
+
if (FIELD_PROP_SCHEMAS[k] === undefined) {
|
|
236
|
+
out.push({ code: CODE_SHAPE, severity: 'error', situation: '装配 kit 意图蓝图写面', problem: `真源 aiWriter 的 ai 级字段键 ${k} 没有对应的蓝图取值 schema`, fix: `在 intent-schema 的 FIELD_PROP_SCHEMAS 补 ${k},并在 compile 里落地`, at: `field.${k}` });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
for (const k of fieldHintKeys()) {
|
|
240
|
+
if (!keys.includes(k)) {
|
|
241
|
+
out.push({ code: CODE_SHAPE, severity: 'error', situation: '装配 kit 意图蓝图写面', problem: `fieldRef 的 ai 级键 ${k} 没有进蓝图字段键`, fix: `把 ${k} 加进蓝图字段键`, at: `field.${k}` });
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return out;
|
|
245
|
+
}
|
|
246
|
+
|
|
170
247
|
function sectionProperties(): Record<string, unknown> {
|
|
171
248
|
const w = kitAiWriter();
|
|
172
|
-
const fieldTypes = [...kitFieldTypes()];
|
|
173
249
|
return {
|
|
174
250
|
product: { type: 'string', enum: [...kitProductIntents()], description: '页面模式意图词' },
|
|
175
251
|
objects: {
|
|
@@ -180,7 +256,6 @@ function sectionProperties(): Record<string, unknown> {
|
|
|
180
256
|
additionalProperties: false,
|
|
181
257
|
required: ['fields'],
|
|
182
258
|
properties: {
|
|
183
|
-
label: STR,
|
|
184
259
|
api: STR,
|
|
185
260
|
write_api: STR,
|
|
186
261
|
delete_api: STR,
|
|
@@ -192,26 +267,7 @@ function sectionProperties(): Record<string, unknown> {
|
|
|
192
267
|
type: 'object',
|
|
193
268
|
additionalProperties: false,
|
|
194
269
|
required: ['name', 'type'],
|
|
195
|
-
properties:
|
|
196
|
-
name: { type: 'string', pattern: ID_PATTERN },
|
|
197
|
-
label: STR,
|
|
198
|
-
type: { type: 'string', enum: fieldTypes },
|
|
199
|
-
key: { type: 'boolean' },
|
|
200
|
-
required: { type: 'boolean' },
|
|
201
|
-
max_len: { type: 'integer', minimum: 1 },
|
|
202
|
-
permission: { type: 'string', enum: [...aiPermissions()] },
|
|
203
|
-
display: { type: 'string', enum: [...kitDisplayWords()], description: '展示语义词(只作用于 list / summary 视图;不写组件名)' },
|
|
204
|
-
options: {
|
|
205
|
-
type: 'array',
|
|
206
|
-
maxItems: w.limits.optionsMax,
|
|
207
|
-
items: {
|
|
208
|
-
type: 'object',
|
|
209
|
-
additionalProperties: false,
|
|
210
|
-
required: ['value', 'label'],
|
|
211
|
-
properties: { value: { type: ['string', 'number'] }, label: STR, tone: { type: 'string', enum: [...aiTones()] } },
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
},
|
|
270
|
+
properties: fieldProperties(),
|
|
215
271
|
},
|
|
216
272
|
},
|
|
217
273
|
},
|
|
@@ -240,7 +296,8 @@ function sectionProperties(): Record<string, unknown> {
|
|
|
240
296
|
};
|
|
241
297
|
}
|
|
242
298
|
|
|
243
|
-
|
|
299
|
+
/** `locales` 给了就把蓝图 locale 收成应用语言集的枚举(accept 阶段另有同口径核对) */
|
|
300
|
+
export function kitIntentSchema(locales?: readonly string[]): JsonSchemaObject {
|
|
244
301
|
const w = kitAiWriter();
|
|
245
302
|
const section = sectionProperties();
|
|
246
303
|
return {
|
|
@@ -266,7 +323,7 @@ export function kitIntentSchema(): JsonSchemaObject {
|
|
|
266
323
|
},
|
|
267
324
|
description: '页签页面框用:每个页签一个页面模式',
|
|
268
325
|
},
|
|
269
|
-
locale: STR,
|
|
326
|
+
locale: locales !== undefined && locales.length > 0 ? { type: 'string', enum: [...locales], description: '页面语言(应用支持的语言之一)' } : STR,
|
|
270
327
|
notes: { type: 'array', items: STR },
|
|
271
328
|
},
|
|
272
329
|
};
|
|
@@ -340,6 +397,21 @@ function checkField(f: unknown, at: string, out: PageDiagnostic[]): void {
|
|
|
340
397
|
out.push(issue(CODE_UNKNOWN, `${at}.permission`, `permission ${String(f.permission)} 不在 AI 可写的档位内`, `改用 ${aiPermissions().join(' / ')}`));
|
|
341
398
|
}
|
|
342
399
|
}
|
|
400
|
+
if (f.access !== undefined) {
|
|
401
|
+
const accessLevels = aiFieldAccess();
|
|
402
|
+
if (typeof f.access !== 'string' || !accessLevels.includes(f.access)) {
|
|
403
|
+
out.push(issue(CODE_UNKNOWN, `${at}.access`, `access ${String(f.access)} 不在允许的取值内`, `改用 ${accessLevels.join(' / ')}`));
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (f.emphasis !== undefined) {
|
|
407
|
+
const emphasisLevels = aiFieldEmphasis();
|
|
408
|
+
if (typeof f.emphasis !== 'string' || !emphasisLevels.includes(f.emphasis)) {
|
|
409
|
+
out.push(issue(CODE_UNKNOWN, `${at}.emphasis`, `emphasis ${String(f.emphasis)} 不在允许的取值内`, `改用 ${emphasisLevels.join(' / ')}`));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (f.highlight !== undefined && typeof f.highlight !== 'boolean') {
|
|
413
|
+
shape(out, `${at}.highlight`, 'highlight 须是布尔', '改成 true / false');
|
|
414
|
+
}
|
|
343
415
|
if (f.display !== undefined) {
|
|
344
416
|
const words = kitDisplayWords();
|
|
345
417
|
const word = typeof f.display === 'string' && words.includes(f.display) ? kitAiDisplayMap().words[f.display] : undefined;
|
|
@@ -349,6 +421,17 @@ function checkField(f: unknown, at: string, out: PageDiagnostic[]): void {
|
|
|
349
421
|
out.push(issue(CODE_INSUFFICIENT, `${at}.display`, `展示词 ${String(f.display)} 不适用于 ${f.type} 类型的字段(可用类型:${word.types.join(' / ')})`, `改用适合 ${f.type} 的展示词,或删去 display`));
|
|
350
422
|
}
|
|
351
423
|
}
|
|
424
|
+
for (const k of fieldHintKeys()) {
|
|
425
|
+
const v = f[k];
|
|
426
|
+
if (v === undefined) continue;
|
|
427
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
428
|
+
shape(out, `${at}.${k}`, `${k} 须是非空纯文本`, `写一句话,或删去 ${k}`);
|
|
429
|
+
} else if (v.length > w.limits.subtitleMax) {
|
|
430
|
+
shape(out, `${at}.${k}`, `${k} 超过上限 ${w.limits.subtitleMax} 个字符`, `精简 ${k}`);
|
|
431
|
+
} else if (/[<>|]/.test(v) || v.trimStart().startsWith('$t:')) {
|
|
432
|
+
shape(out, `${at}.${k}`, `${k} 只收纯文本:不得含 HTML 标记、竖线或词条引用`, `改写成不含 < > | 的纯文本`);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
352
435
|
if (f.options !== undefined) {
|
|
353
436
|
if (!Array.isArray(f.options)) return void shape(out, `${at}.options`, 'options 须是数组', '写成 [{ value, label, tone? }]');
|
|
354
437
|
if (f.options.length > w.limits.optionsMax) shape(out, `${at}.options`, `options 超过上限 ${w.limits.optionsMax}`, '精简候选项');
|
|
@@ -384,7 +467,7 @@ function checkObjects(v: unknown, at: string, out: PageDiagnostic[]): Record<str
|
|
|
384
467
|
continue;
|
|
385
468
|
}
|
|
386
469
|
checkKeys(desc, KIT_INTENT_OBJECT_KEYS, oat, out);
|
|
387
|
-
for (const k of ['
|
|
470
|
+
for (const k of ['api', 'write_api', 'delete_api'] as const) {
|
|
388
471
|
if (desc[k] !== undefined && typeof desc[k] !== 'string') shape(out, `${oat}.${k}`, `${k} 须是字符串`, '改成字符串');
|
|
389
472
|
}
|
|
390
473
|
if (!Array.isArray(desc.fields) || desc.fields.length === 0) {
|
|
@@ -478,6 +561,39 @@ function checkDisplayUsage(
|
|
|
478
561
|
}
|
|
479
562
|
}
|
|
480
563
|
|
|
564
|
+
/** 提示文字只作用于 form / filter 视图:字段写了 placeholder / help 却不在任何这类视图里 → 不会生效,回喂 */
|
|
565
|
+
function checkHintUsage(
|
|
566
|
+
objects: Record<string, Record<string, unknown>>,
|
|
567
|
+
roleObjects: Record<string, string[]>,
|
|
568
|
+
views: Record<string, unknown>,
|
|
569
|
+
at: string,
|
|
570
|
+
out: PageDiagnostic[],
|
|
571
|
+
): void {
|
|
572
|
+
const slotsOfHint = hintSlots();
|
|
573
|
+
const keys = fieldHintKeys();
|
|
574
|
+
for (const [name, desc] of Object.entries(objects)) {
|
|
575
|
+
if (!Array.isArray(desc.fields)) continue;
|
|
576
|
+
const shown = new Set<string>();
|
|
577
|
+
for (const [role, names] of Object.entries(roleObjects)) {
|
|
578
|
+
if (!names.includes(name)) continue;
|
|
579
|
+
const slots = slotsOfRoleView(views[role], name);
|
|
580
|
+
if (slots === undefined) continue;
|
|
581
|
+
for (const slot of slotsOfHint) {
|
|
582
|
+
const list = slots[slot];
|
|
583
|
+
if (Array.isArray(list)) for (const f of list) if (typeof f === 'string') shown.add(f);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
desc.fields.forEach((f, i) => {
|
|
587
|
+
if (!isRecord(f) || typeof f.name !== 'string') return;
|
|
588
|
+
for (const k of keys) {
|
|
589
|
+
if (typeof f[k] === 'string' && !shown.has(f.name)) {
|
|
590
|
+
out.push(issue(CODE_INSUFFICIENT, `${at}.${name}.fields[${i}].${k}`, `字段 ${f.name} 写了 ${k},但它不在任何 ${slotsOfHint.join(' / ')} 视图里;${k} 只显示在编辑态的字段上(list / summary 不显示)`, `把 ${f.name} 放进 ${slotsOfHint.join(' / ')} 视图,或删去 ${k}`));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
481
597
|
type Env = { readonly app?: KitIntentOptions['app']; readonly map: KitIntentMap };
|
|
482
598
|
|
|
483
599
|
function parseSection(raw: Record<string, unknown>, at: string, env: Env, out: PageDiagnostic[]): void {
|
|
@@ -571,6 +687,16 @@ function parseSection(raw: Record<string, unknown>, at: string, env: Env, out: P
|
|
|
571
687
|
|
|
572
688
|
// 展示词只作用于 list / summary 视图:字段带了 display(非默认的 text),却不在任何角色的这类视图里 → 不会生效
|
|
573
689
|
checkDisplayUsage(objects, roleObjects, isRecord(raw.views) ? raw.views : {}, p('objects'), out);
|
|
690
|
+
checkHintUsage(objects, roleObjects, isRecord(raw.views) ? raw.views : {}, p('objects'), out);
|
|
691
|
+
|
|
692
|
+
// 写死模板禁止的对象键(roleShape.omit):该角色的视图由模板写死,蓝图不得为它写 views
|
|
693
|
+
if (kind !== undefined && isRecord(raw.views)) {
|
|
694
|
+
for (const role of Object.keys(raw.views)) {
|
|
695
|
+
if (roleShapeOf(kind, role).omit.includes('view')) {
|
|
696
|
+
out.push(issue(CODE_INSUFFICIENT, p(`views.${role}`), `页面模式 ${String(productIntent)} 的角色 ${role} 的界面由模板写死,不收 views`, `删去 views.${role}`));
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
574
700
|
|
|
575
701
|
// 动作
|
|
576
702
|
if (raw.actions !== undefined) {
|