soma-kit 0.1.11 → 0.1.13
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 +106 -112
- package/bin/soma-kit.mjs +32 -2
- package/bin/soma.mjs +22 -0
- package/package.json +14 -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 +929 -37
- package/spec/generated/kit-page.schema.json +1684 -161
- package/spec/kit-grammar.json +1176 -584
- package/spec/kit-grammar.schema.json +1971 -393
- package/src/app/app-config.ts +449 -347
- package/src/app/component-gate.ts +283 -28
- package/src/app/compose-apps.ts +79 -8
- package/src/app/define-kit-actions.ts +245 -41
- package/src/app/define-kit-app.ts +176 -33
- package/src/app/define-kit-view.ts +104 -0
- package/src/app/dev-diagnostic.ts +5 -0
- package/src/app/envelope.ts +1 -161
- package/src/app/index.ts +29 -6
- package/src/app/kit-view-context.ts +439 -0
- package/src/app/notify-renderer.ts +1 -115
- package/src/app/paged-list-adapter.ts +1 -240
- package/src/app/render-ports.ts +18 -0
- package/src/app/server-pages.ts +11 -3
- package/src/app/server.ts +530 -103
- 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 +667 -0
- package/src/base/action-busy.ts +103 -6
- package/src/base/action-gate.ts +4 -255
- package/src/base/action-slots.ts +58 -0
- package/src/base/alert.ts +5 -3
- package/src/base/anchored-layer.ts +50 -0
- package/src/base/avatar.ts +2 -2
- package/src/base/button.ts +99 -37
- package/src/base/cascader.ts +11 -12
- package/src/base/check-core.ts +9 -1
- package/src/base/checkbox.ts +2 -1
- package/src/base/choice.ts +49 -28
- package/src/base/class-candidates.ts +17 -0
- package/src/base/color-picker.ts +16 -11
- package/src/base/combobox.ts +5 -3
- package/src/base/command-palette.ts +10 -6
- package/src/base/context-menu.ts +10 -7
- package/src/base/countdown.ts +1 -1
- package/src/base/date-range.ts +32 -18
- package/src/base/date.ts +135 -28
- package/src/base/delta.ts +72 -0
- package/src/base/divider.ts +2 -2
- package/src/base/end-edge.ts +49 -0
- package/src/base/fab.ts +12 -5
- package/src/base/gap-value.ts +148 -0
- package/src/base/hint-tips.ts +170 -0
- package/src/base/icons.ts +8 -0
- package/src/base/illustrations.ts +94 -0
- package/src/base/image.ts +1 -1
- package/src/base/index.ts +35 -11
- 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 +56 -35
- package/src/base/loading-gate.ts +186 -0
- package/src/base/mentions.ts +7 -6
- package/src/base/menu-button.ts +28 -12
- package/src/base/menu-core.ts +41 -8
- package/src/base/motion/aura.ts +2 -2
- package/src/base/motion/hover-3d.ts +3 -3
- package/src/base/motion/hover-gallery.ts +2 -2
- package/src/base/motion/marquee.ts +3 -3
- package/src/base/motion/text-rotate.ts +2 -2
- package/src/base/number.ts +93 -80
- package/src/base/otp.ts +9 -5
- package/src/base/overlay-runtime.ts +235 -0
- package/src/base/permission-gate.ts +6 -0
- package/src/base/popover.ts +48 -16
- package/src/base/popup.ts +143 -19
- package/src/base/portal-core.ts +4 -0
- 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 +14 -8
- package/src/base/radio.ts +2 -1
- package/src/base/range.ts +21 -4
- package/src/base/rating.ts +12 -7
- package/src/base/reason-tip.ts +150 -0
- package/src/base/segmented.ts +27 -21
- package/src/base/select.ts +4 -3
- package/src/base/shared.ts +387 -49
- package/src/base/state-panel.ts +346 -0
- package/src/base/status-tone.ts +27 -0
- package/src/base/sticky-edge.ts +116 -0
- package/src/base/swap.ts +10 -7
- package/src/base/switch.ts +11 -6
- package/src/base/tag-input.ts +20 -16
- package/src/base/tag.ts +68 -34
- package/src/base/text.ts +80 -18
- package/src/base/textarea.ts +37 -11
- package/src/base/time-picker.ts +18 -13
- package/src/base/tree-select.ts +21 -12
- package/src/base/trend-tone.ts +9 -0
- package/src/base/upload.ts +48 -14
- package/src/base/view-transition.ts +77 -0
- package/src/base/virtual-list.ts +107 -1
- package/src/biz/approval-desk/compile.ts +23 -41
- package/src/biz/approval-desk/shell.ts +11 -8
- package/src/biz/auth-panel/compile.ts +37 -52
- package/src/biz/auth-panel/index.ts +1 -1
- package/src/biz/auth-panel/shell.ts +5 -4
- package/src/biz/category-crud/compile.ts +23 -37
- package/src/biz/category-crud/shell.ts +2 -1
- package/src/biz/checkout-page/compile.ts +22 -5
- package/src/biz/checkout-page/shell.ts +4 -3
- 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 +5 -4
- package/src/biz/index.ts +3 -3
- package/src/biz/landing-page/compile.ts +19 -3
- package/src/biz/link/hub.ts +69 -22
- package/src/biz/link/shared.ts +127 -119
- package/src/biz/master-sub/compile.ts +127 -48
- package/src/biz/master-sub/index.ts +5 -2
- package/src/biz/master-sub/shell.ts +95 -18
- package/src/biz/multi-board/compile.ts +38 -50
- package/src/biz/multi-board/index.ts +18 -1
- package/src/biz/multi-board/shell.ts +32 -20
- package/src/biz/notification-center/compile.ts +21 -33
- package/src/biz/notification-center/shell.ts +6 -4
- 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/result-page/shell.ts +2 -1
- package/src/biz/page-templates/shared.ts +34 -36
- package/src/biz/page-templates/sign-in-page/shell.ts +2 -2
- package/src/biz/record-detail/compile.ts +48 -43
- package/src/biz/record-detail/index.ts +11 -1
- package/src/biz/record-detail/shell.ts +8 -6
- package/src/biz/settings-center/compile.ts +7 -5
- package/src/biz/settings-center/shell.ts +6 -4
- package/src/biz/shared/action-host.ts +97 -211
- package/src/biz/shared/compile-helpers.ts +98 -0
- package/src/biz/shared/coordinator.ts +472 -92
- package/src/biz/shared/index.ts +13 -2
- package/src/biz/shared/object-aliases.ts +154 -0
- package/src/biz/shared/overlay-compile.ts +239 -0
- package/src/biz/shared/overlay-shell.ts +209 -0
- package/src/biz/shared/pipes.ts +50 -31
- package/src/biz/shared/remove-wire.ts +14 -0
- package/src/biz/shared/runtime-hub.ts +226 -24
- package/src/biz/single-form/compile.ts +16 -37
- package/src/biz/single-form/shell.ts +4 -3
- package/src/biz/standard-crud/compile.ts +72 -255
- package/src/biz/standard-crud/shell.ts +21 -99
- package/src/biz/step-form/compile.ts +26 -97
- package/src/biz/step-form/hub.ts +34 -41
- package/src/biz/step-form/shell.ts +5 -5
- package/src/biz/types.ts +4 -3
- package/src/cli/core-imports.ts +54 -0
- package/src/cli/kit-cli.ts +254 -25
- package/src/cli/kit-init.ts +227 -0
- package/src/cli/layout-cli.ts +167 -0
- package/src/cli/migrate/index.ts +10 -0
- package/src/cli/migrate/migrate.ts +248 -0
- package/src/cli/migrate/text-utils.ts +306 -0
- package/src/cli/migrate/theme-map.ts +104 -0
- package/src/cli/migrate/ts-rules.ts +235 -0
- package/src/cli/migrate/types.ts +95 -0
- package/src/cli/migrate/view-skeleton.ts +159 -0
- package/src/cli/migrate/yaml-report.ts +376 -0
- package/src/cli/migrate/yaml-rules.ts +465 -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 +761 -0
- package/src/compile/action-host-attach.ts +21 -29
- package/src/compile/closed-set.ts +570 -0
- package/src/compile/compile-page.ts +267 -76
- package/src/compile/component-candidates.ts +13 -2
- 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/layout-lint/engine.ts +82 -0
- package/src/compile/layout-lint/index.ts +55 -0
- package/src/compile/layout-lint/rules-composition.ts +218 -0
- package/src/compile/layout-lint/rules-form.ts +192 -0
- package/src/compile/layout-lint/rules-table.ts +194 -0
- package/src/compile/layout-lint/score.ts +52 -0
- package/src/compile/layout-lint/types.ts +51 -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/remove-guard.ts +10 -7
- package/src/compile/styles.ts +63 -2
- package/src/compile/types.ts +31 -3
- package/src/compile/view-check.ts +284 -0
- package/src/data/amount-breakdown.ts +8 -3
- package/src/data/anchor-nav.ts +2 -2
- package/src/data/approval-flow.ts +3 -3
- package/src/data/assignment-picker.ts +92 -55
- package/src/data/async-result-panel.ts +111 -9
- package/src/data/breadcrumbs.ts +5 -4
- package/src/data/calendar.ts +24 -27
- package/src/data/carousel.ts +13 -8
- package/src/data/chart.ts +183 -44
- package/src/data/checklist.ts +20 -7
- package/src/data/code-view.ts +12 -6
- package/src/data/comment-thread.ts +7 -4
- package/src/data/confirm-dialog.ts +81 -18
- 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 +3 -3
- package/src/data/embed.ts +233 -30
- package/src/data/field-mapper.ts +35 -30
- package/src/data/flow-editor-contract.ts +8 -1
- package/src/data/flow-editor.ts +113 -108
- package/src/data/flow-node-options.ts +120 -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 +19 -19
- package/src/data/hero.ts +4 -3
- package/src/data/image-viewer.ts +27 -30
- package/src/data/index.ts +5 -2
- package/src/data/item-list.ts +48 -31
- package/src/data/kanban.ts +82 -52
- package/src/data/media-grid.ts +20 -20
- package/src/data/mega-menu.ts +6 -4
- package/src/data/menu-dom.ts +4 -2
- package/src/data/menu.ts +47 -15
- package/src/data/mockup.ts +10 -6
- package/src/data/modal-dialog.ts +49 -25
- package/src/data/navbar.ts +12 -7
- package/src/data/notice-list.ts +268 -0
- package/src/data/notify-renderer.ts +250 -0
- package/src/data/object-form.ts +1360 -666
- package/src/data/outcome-watch.ts +61 -2
- package/src/data/pager.ts +80 -34
- package/src/data/permission-matrix.ts +52 -31
- package/src/data/permission-tree.ts +71 -44
- package/src/data/pricing-table.ts +30 -14
- package/src/data/prompt-dialog.ts +124 -194
- package/src/data/reaction-bar.ts +83 -92
- package/src/data/read-rollback.ts +73 -0
- package/src/data/record-card.ts +26 -5
- package/src/data/record-picker.ts +104 -55
- 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 +8 -4
- package/src/data/rich-text.ts +61 -55
- package/src/data/row-editor.ts +362 -76
- package/src/data/rule-builder.ts +26 -20
- package/src/data/shape-util.ts +27 -9
- package/src/data/stat-group.ts +392 -109
- package/src/data/static-lazy.ts +1 -0
- package/src/data/static-registry.ts +24 -11
- package/src/data/steps.ts +10 -5
- package/src/data/survey.ts +27 -32
- package/src/data/system-switcher.ts +3 -3
- package/src/data/text-action-button.ts +17 -0
- package/src/data/timeline.ts +19 -8
- package/src/data/tour-guide.ts +23 -30
- package/src/data/transfer.ts +62 -38
- package/src/data/tree-table.ts +152 -78
- package/src/data/tree.ts +49 -36
- package/src/data/trend-line.ts +6 -24
- package/src/data/virtual-rows.ts +133 -82
- package/src/data/watermark.ts +2 -2
- package/src/data/wrap.ts +63 -38
- package/src/data/wrapped-candidates.ts +10 -0
- package/src/frames/blank-frame.ts +1 -0
- package/src/frames/index.ts +2 -2
- package/src/frames/page-bar.ts +26 -24
- package/src/frames/page-header.ts +14 -5
- package/src/frames/page-status.ts +9 -7
- package/src/frames/shared.ts +36 -25
- package/src/frames/single-frame.ts +1 -0
- package/src/frames/split-frame/shell.ts +6 -6
- package/src/frames/split-frame/wiring.ts +2 -2
- package/src/frames/tabs-frame/shell.ts +4 -14
- package/src/frames/tabs-frame/wiring.ts +5 -8
- package/src/frames/top-main-frame.ts +3 -2
- package/src/frames/types.ts +13 -2
- package/src/frames/workspace-frame/extras.ts +21 -5
- package/src/frames/workspace-frame/index.ts +1 -1
- package/src/frames/workspace-frame/shell.ts +3 -2
- package/src/frames/workspace-frame/state.ts +13 -6
- package/src/frames/workspace-frame/view.ts +250 -48
- package/src/generated/kit-grammar-runtime.ts +645 -397
- package/src/generated/page-origin.ts +0 -11
- package/src/i18n/kit-text.ts +84 -29
- package/src/i18n/resolve-text-refs.ts +22 -6
- package/src/index.ts +2 -1
- package/src/object-renderer/action-gate.ts +11 -147
- package/src/object-renderer/arrange.ts +112 -84
- 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 +401 -104
- package/src/object-renderer/collection-table.ts +287 -45
- package/src/object-renderer/collection.ts +258 -104
- package/src/object-renderer/compile-data.ts +112 -102
- package/src/object-renderer/crud-bridge.ts +32 -0
- package/src/object-renderer/defaults.ts +38 -16
- package/src/object-renderer/display-checks.ts +4 -25
- package/src/object-renderer/emit-events.ts +224 -176
- package/src/object-renderer/emit-object.ts +15 -2
- package/src/object-renderer/emit-static.ts +533 -151
- 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 +111 -2
- package/src/object-renderer/form-notify.ts +45 -0
- package/src/object-renderer/index.ts +26 -0
- package/src/object-renderer/key-field.ts +12 -0
- package/src/object-renderer/layout-facts.ts +386 -0
- package/src/object-renderer/layout-plan.ts +132 -0
- package/src/object-renderer/layout-plan.types.ts +22 -0
- package/src/object-renderer/linkage.ts +7 -270
- package/src/object-renderer/merge-class.ts +18 -1
- package/src/object-renderer/parts.ts +252 -1
- package/src/object-renderer/path-pick.ts +27 -0
- package/src/object-renderer/render-object.ts +456 -89
- package/src/object-renderer/request-actions.ts +232 -249
- package/src/object-renderer/skeleton.ts +58 -19
- package/src/object-renderer/table-actions.ts +319 -111
- package/src/object-renderer/table-summary.ts +2 -2
- package/src/object-renderer/table-tools.ts +429 -94
- package/src/object-renderer/types.ts +204 -127
- package/src/object-renderer/view-binding.ts +393 -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 +165 -28
- package/src/page-target/target.ts +262 -51
- package/src/page-target/writer-policy.ts +14 -3
- package/src/recipes/container.ts +210 -0
- package/src/recipes/control.ts +277 -0
- package/src/recipes/index.ts +312 -0
- package/src/recipes/nowrap.ts +16 -0
- package/src/recipes/overlay.ts +240 -0
- package/src/recipes/placeholder.ts +79 -0
- package/src/recipes/rail-grid.ts +45 -0
- package/src/recipes/slot-align.ts +56 -0
- package/src/recipes/state.ts +99 -0
- package/src/recipes/status.ts +139 -0
- package/src/recipes/surface.ts +40 -0
- package/src/recipes/table-row.ts +88 -0
- package/src/recipes/title-row.ts +37 -0
- package/src/recipes/typography.ts +99 -0
- package/src/shared/action-field-guard.ts +41 -0
- package/src/shared/confirm-decl.ts +118 -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 +15 -0
- package/src/shared/path-guard.ts +127 -0
- package/src/shared/theme-runtime-shared.ts +180 -0
- package/src/shared/view-info.ts +10 -0
- package/src/theme/index.ts +13 -0
- package/src/theme/kit-theme-text.ts +1 -1
- package/src/theme/kit-theme.css +407 -10
- package/src/theme/kit-theme.tpl +407 -10
- package/src/theme/nine-dim-structure.ts +247 -0
- package/src/theme/surface-layers.ts +101 -0
- package/src/theme/theme-tokens.ts +130 -84
- package/src/theme/theme-types.ts +103 -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/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
|
@@ -1,240 +1 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
// kit 列表对象以 `GET ?pageNo=&pageSize=&<筛选字段>=…` 读数据(参数名可由 behavior.list 的 pageParam / sizeParam 改;
|
|
4
|
-
// 筛选字段名就是 schema 字段名,空值不带),期望响应 `{ rows, total }`(缺省 listShape)。旧后台常见三种不一样:
|
|
5
|
-
// 1 后端页码键叫 page / pageNum,页长叫 size / limit,筛选参数名与字段名不同 -> createPagedListAdapter 的 upstream* 与 filterMap;
|
|
6
|
-
// 2 响应是业务信封(失败判定 / 数据位置由 kit.app.yaml 的 envelope 声明),列表键与总数键不统一 -> unwrapBizEnvelope + 适配器的 rowsPath / totalPaths;
|
|
7
|
-
// 3 游标分页(cursor / limit / nextCursor),没有页码 -> cursorPageWindow(沿游标走到第 N 页)。
|
|
8
|
-
// 这里只做形状翻译,不碰业务、不发请求(请求由调用方的 load 函数发)。数字(缺省页长 / 页长上限 / 信封嵌套层数)读 design 的 kit-limits。
|
|
9
|
-
|
|
10
|
-
import { KIT_DATA_LIMITS } from 'soma-foundation/kit-limits';
|
|
11
|
-
import { getKitAppEnvelope, isEnvelopeFailure, unwrapEnvelope, type KitEnvelope, type UnwrappedEnvelope } from './envelope';
|
|
12
|
-
|
|
13
|
-
type Rec = Record<string, unknown>;
|
|
14
|
-
const LIMITS = (KIT_DATA_LIMITS as unknown as { pagedList: { pageSizeDefault: number; pageSizeMax: number; unwrapDepth: number } }).pagedList;
|
|
15
|
-
|
|
16
|
-
const isRec = (v: unknown): v is Rec => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
17
|
-
|
|
18
|
-
/** kit 列表请求里唯一的页码键与页长键;其余键都当筛选(外部后端的参数名由 upstreamPage / upstreamSize 显式配置) */
|
|
19
|
-
const KIT_PAGE_KEY = 'pageNo';
|
|
20
|
-
const KIT_SIZE_KEY = 'pageSize';
|
|
21
|
-
const RESERVED: ReadonlySet<string> = new Set([KIT_PAGE_KEY, KIT_SIZE_KEY, 'window', 'sort', 'order']);
|
|
22
|
-
const DEFAULT_ROW_KEYS: readonly string[] = ['list', 'records', 'rows', 'items', 'data'];
|
|
23
|
-
const DEFAULT_TOTAL_PATHS: readonly string[] = ['totalCount', 'total', 'count'];
|
|
24
|
-
|
|
25
|
-
function positiveInt(raw: unknown): number | null {
|
|
26
|
-
const n = typeof raw === 'number' ? raw : typeof raw === 'string' && raw.trim() !== '' ? Number(raw) : Number.NaN;
|
|
27
|
-
return Number.isInteger(n) && n > 0 ? n : null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function pathGet(root: unknown, path: string): unknown {
|
|
31
|
-
let cur = root;
|
|
32
|
-
for (const key of path.split('.')) {
|
|
33
|
-
if (!isRec(cur)) return undefined;
|
|
34
|
-
cur = cur[key];
|
|
35
|
-
}
|
|
36
|
-
return cur;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ---------------------------------------------------------------- 业务信封
|
|
40
|
-
|
|
41
|
-
export type { UnwrappedEnvelope };
|
|
42
|
-
|
|
43
|
-
/** 响应是业务错误信封:命中应用声明的 failWhen(kit.app.yaml 的 envelope;不显式传 env 时取装配登记的应用级信封) */
|
|
44
|
-
export function isBizFailure(raw: unknown, env: KitEnvelope | undefined = getKitAppEnvelope()): raw is Rec {
|
|
45
|
-
return isEnvelopeFailure(raw, env);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 拆业务信封:失败信封原样放进 `error`(调用方应把它直接回给浏览器,不要再包成成功的列表);
|
|
50
|
-
* 成功则按 envelope.dataPath 取数据(没声明不拆)。写死的 success / ret / data 约定已删,全部来自声明。
|
|
51
|
-
*/
|
|
52
|
-
export function unwrapBizEnvelope(raw: unknown, env: KitEnvelope | undefined = getKitAppEnvelope()): UnwrappedEnvelope {
|
|
53
|
-
return unwrapEnvelope(raw, env);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// ---------------------------------------------------------------- 页码协议适配器
|
|
57
|
-
|
|
58
|
-
export interface PagedListAdapterOptions {
|
|
59
|
-
/** 上游页码参数名(缺省 page) */
|
|
60
|
-
upstreamPage?: string;
|
|
61
|
-
/** 上游页长参数名(缺省 pageSize) */
|
|
62
|
-
upstreamSize?: string;
|
|
63
|
-
/** 响应里行数组的位置:点路径(相对拆信封后的 data),或候选键列表(取第一个数组);缺省 list / records / rows / items / data */
|
|
64
|
-
rowsPath?: string | readonly string[];
|
|
65
|
-
/** 总数的候选位置(相对拆信封后的 data);缺省 totalCount / total / count */
|
|
66
|
-
totalPaths?: readonly string[];
|
|
67
|
-
/** 筛选参数:kit 字段名 -> 上游参数名;数组 = 同名透传的白名单;缺省收全部非保留参数同名透传 */
|
|
68
|
-
filterMap?: Readonly<Record<string, string>> | readonly string[];
|
|
69
|
-
/** 给行补主键 id:依次取这些键里第一个非空值(已有非空 id 不动) */
|
|
70
|
-
rowId?: string | readonly string[];
|
|
71
|
-
/** 缺省页长 / 页长上限(缺省读 kit-limits) */
|
|
72
|
-
defaultPageSize?: number;
|
|
73
|
-
maxPageSize?: number;
|
|
74
|
-
/** 业务信封约定;缺省取 kit.app.yaml 的 envelope(装配登记的应用级信封) */
|
|
75
|
-
envelope?: KitEnvelope;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface PagedQuery {
|
|
79
|
-
/** 从 1 起 */
|
|
80
|
-
page: number;
|
|
81
|
-
pageSize: number;
|
|
82
|
-
/** kit 字段名 -> 值(已去空白,空值不进) */
|
|
83
|
-
filters: Record<string, string>;
|
|
84
|
-
/** 可直接拼到上游请求的参数:页码、页长、已改名的筛选 */
|
|
85
|
-
upstream: Record<string, string | number>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface PagedList {
|
|
89
|
-
rows: Rec[];
|
|
90
|
-
total: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export interface PagedListAdapter {
|
|
94
|
-
/** 请求里没有页码键 = 旧调用方(调用方可据此原样转交旧服务) */
|
|
95
|
-
hasPage(input: unknown): boolean;
|
|
96
|
-
readQuery(input: unknown): PagedQuery;
|
|
97
|
-
/** 上游响应 -> kit 列表;失败信封返回 { error } */
|
|
98
|
-
toList(raw: unknown, mapRow?: (row: Rec, index: number) => Rec): PagedList | { error: Rec };
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function entriesOf(input: unknown): Array<[string, unknown]> {
|
|
102
|
-
if (input instanceof URLSearchParams) return [...input.entries()];
|
|
103
|
-
if (typeof input === 'string') return [...new URLSearchParams(input.includes('?') ? input.slice(input.indexOf('?') + 1) : input).entries()];
|
|
104
|
-
if (isRec(input)) return Object.entries(input);
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function rowsOf(data: unknown, rowsPath: string | readonly string[] | undefined): Rec[] {
|
|
109
|
-
let list: unknown;
|
|
110
|
-
if (Array.isArray(data)) list = data;
|
|
111
|
-
else if (typeof rowsPath === 'string') list = pathGet(data, rowsPath);
|
|
112
|
-
else list = (rowsPath ?? DEFAULT_ROW_KEYS).map((key) => (isRec(data) ? data[key] : undefined)).find(Array.isArray);
|
|
113
|
-
return Array.isArray(list) ? list.filter(isRec) : [];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function totalOf(data: unknown, paths: readonly string[], fallback: number): number {
|
|
117
|
-
for (const path of paths) {
|
|
118
|
-
const v = pathGet(data, path);
|
|
119
|
-
if (typeof v === 'number' && Number.isFinite(v)) return v;
|
|
120
|
-
if (typeof v === 'string' && v.trim() !== '' && Number.isFinite(Number(v))) return Number(v);
|
|
121
|
-
}
|
|
122
|
-
return fallback;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/** 给行补主键:id 缺省时依次取 keys 里第一个非空值(字符串化),已有非空 id 不动 */
|
|
126
|
-
export function withRowId(row: Rec, keys: string | readonly string[]): Rec {
|
|
127
|
-
if (typeof row.id === 'string' && row.id !== '') return row;
|
|
128
|
-
if (typeof row.id === 'number') return { ...row, id: String(row.id) };
|
|
129
|
-
for (const key of typeof keys === 'string' ? [keys] : keys) {
|
|
130
|
-
const v = row[key];
|
|
131
|
-
if (typeof v === 'string' && v.trim() !== '') return { ...row, id: v.trim() };
|
|
132
|
-
if (typeof v === 'number') return { ...row, id: String(v) };
|
|
133
|
-
}
|
|
134
|
-
return { ...row, id: '' };
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function createPagedListAdapter(options: PagedListAdapterOptions = {}): PagedListAdapter {
|
|
138
|
-
const upstreamPage = options.upstreamPage ?? 'page';
|
|
139
|
-
const upstreamSize = options.upstreamSize ?? 'pageSize';
|
|
140
|
-
const totalPaths = options.totalPaths ?? DEFAULT_TOTAL_PATHS;
|
|
141
|
-
const defaultSize = options.defaultPageSize ?? LIMITS.pageSizeDefault;
|
|
142
|
-
const maxSize = options.maxPageSize ?? LIMITS.pageSizeMax;
|
|
143
|
-
const filterMap = options.filterMap;
|
|
144
|
-
const filterName = (key: string): string | null => {
|
|
145
|
-
if (filterMap === undefined) return key;
|
|
146
|
-
if (Array.isArray(filterMap)) return filterMap.includes(key) ? key : null;
|
|
147
|
-
const mapped = (filterMap as Readonly<Record<string, string>>)[key];
|
|
148
|
-
return mapped === undefined ? null : mapped;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
return {
|
|
152
|
-
hasPage(input) {
|
|
153
|
-
return entriesOf(input).some(([k, v]) => k === KIT_PAGE_KEY && positiveInt(v) !== null);
|
|
154
|
-
},
|
|
155
|
-
readQuery(input) {
|
|
156
|
-
const entries = entriesOf(input);
|
|
157
|
-
const pick = (key: string): number | null => {
|
|
158
|
-
const hit = entries.find(([k]) => k === key);
|
|
159
|
-
return hit === undefined ? null : positiveInt(hit[1]);
|
|
160
|
-
};
|
|
161
|
-
const page = pick(KIT_PAGE_KEY) ?? 1;
|
|
162
|
-
const pageSize = Math.min(pick(KIT_SIZE_KEY) ?? defaultSize, maxSize);
|
|
163
|
-
const filters: Record<string, string> = {};
|
|
164
|
-
const upstream: Record<string, string | number> = { [upstreamPage]: page, [upstreamSize]: pageSize };
|
|
165
|
-
for (const [key, value] of entries) {
|
|
166
|
-
if (RESERVED.has(key) || value === undefined || value === null) continue;
|
|
167
|
-
const text = String(value).trim();
|
|
168
|
-
const target = filterName(key);
|
|
169
|
-
if (text === '' || target === null) continue;
|
|
170
|
-
filters[key] = text;
|
|
171
|
-
upstream[target] = text;
|
|
172
|
-
}
|
|
173
|
-
return { page, pageSize, filters, upstream };
|
|
174
|
-
},
|
|
175
|
-
toList(raw, mapRow) {
|
|
176
|
-
const unwrapped = unwrapBizEnvelope(raw, options.envelope ?? getKitAppEnvelope());
|
|
177
|
-
if (!unwrapped.ok) return { error: unwrapped.error };
|
|
178
|
-
let rows = rowsOf(unwrapped.data, options.rowsPath);
|
|
179
|
-
if (options.rowId !== undefined) rows = rows.map((r) => withRowId(r, options.rowId!));
|
|
180
|
-
if (mapRow !== undefined) rows = rows.map(mapRow);
|
|
181
|
-
return { rows, total: totalOf(unwrapped.data, totalPaths, rows.length) };
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// ---------------------------------------------------------------- 游标分页
|
|
187
|
-
|
|
188
|
-
export type CursorLoader = (query: { cursor?: string; limit: number }) => Promise<unknown>;
|
|
189
|
-
|
|
190
|
-
export interface CursorPageOptions<T> {
|
|
191
|
-
load: CursorLoader;
|
|
192
|
-
/** 响应里行数组的键(缺省 rows) */
|
|
193
|
-
rowsKey?: string;
|
|
194
|
-
/** 响应里总数的键(缺省 total) */
|
|
195
|
-
totalKey?: string;
|
|
196
|
-
/** 响应里下一页游标的键(缺省 nextCursor) */
|
|
197
|
-
nextKey?: string;
|
|
198
|
-
parse?: (raw: unknown) => T;
|
|
199
|
-
/** 目标页(从 1 起)与页长 */
|
|
200
|
-
page: number;
|
|
201
|
-
pageSize: number;
|
|
202
|
-
/** 出错信息前缀(如「接口目录」) */
|
|
203
|
-
label: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export interface CursorPageResult<T> {
|
|
207
|
-
rows: T[];
|
|
208
|
-
total: number;
|
|
209
|
-
/** 最后一次取到的原始响应(调用方要读其它字段,如 snapshotVersion);页号超过末页时是末页那次的响应 */
|
|
210
|
-
raw: Rec | null;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* 沿游标走到第 page 页,返回该页行与总数;页号超过末页返回空行(total 仍真实)。
|
|
215
|
-
* 响应结构非法(行不是数组、总数不是非负整数、行数超过页长)抛错,不静默截断;游标重复也抛错(防死循环)。
|
|
216
|
-
*/
|
|
217
|
-
export async function cursorPageWindow<T = unknown>(options: CursorPageOptions<T>): Promise<CursorPageResult<T>> {
|
|
218
|
-
const { load, page, pageSize, label } = options;
|
|
219
|
-
const rowsKey = options.rowsKey ?? 'rows';
|
|
220
|
-
const totalKey = options.totalKey ?? 'total';
|
|
221
|
-
const nextKey = options.nextKey ?? 'nextCursor';
|
|
222
|
-
const parse = options.parse ?? ((raw: unknown) => raw as T);
|
|
223
|
-
let cursor: string | undefined;
|
|
224
|
-
const seen = new Set<string>();
|
|
225
|
-
let total = 0;
|
|
226
|
-
for (let current = 1; current <= page; current += 1) {
|
|
227
|
-
const response = await load({ ...(cursor !== undefined ? { cursor } : {}), limit: pageSize });
|
|
228
|
-
if (!isRec(response)) throw new Error(`${label}分页响应结构非法`);
|
|
229
|
-
const result: Rec = response;
|
|
230
|
-
const raw = result[rowsKey];
|
|
231
|
-
total = Number(result[totalKey]);
|
|
232
|
-
if (!Array.isArray(raw) || !Number.isSafeInteger(total) || total < 0 || raw.length > pageSize) throw new Error(`${label}分页响应结构非法`);
|
|
233
|
-
if (current === page) return { rows: raw.map(parse), total, raw: result };
|
|
234
|
-
const next = typeof result[nextKey] === 'string' ? (result[nextKey] as string).trim() : '';
|
|
235
|
-
if (next === '' || next === cursor || seen.has(next)) return { rows: [], total, raw: result };
|
|
236
|
-
seen.add(next);
|
|
237
|
-
cursor = next;
|
|
238
|
-
}
|
|
239
|
-
return { rows: [], total, raw: null };
|
|
240
|
-
}
|
|
1
|
+
export * from '../shared/paged-list-adapter';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// kit 应用的渲染端口装配:通知渲染器 + 浮层隐藏前过渡钩子(core `renderPorts.hideTransition`),并在此安装页面侧浮层通报。
|
|
2
|
+
// 这是「页内浮层 -> 外壳遮罩」通报(base/overlay-runtime)的唯一安装点:每个 kit 页面都经此装配,
|
|
3
|
+
// 监听按文档级 aria-modal 统计,各类浮层(业务浮层 / 命令式模态 / 图片查看 / 引导 / 命令面板)自动覆盖,不在各浮层里各装一次。
|
|
4
|
+
import type { SomaRenderPorts } from 'soma-core';
|
|
5
|
+
import { createKitHideTransition, installKitOverlayRuntime } from '../base/overlay-runtime';
|
|
6
|
+
import { installStickyEdgeFallback } from '../base/sticky-edge';
|
|
7
|
+
import { createKitNotifyRenderer } from '../data/notify-renderer';
|
|
8
|
+
|
|
9
|
+
/** 应用自带的端口优先(只补 kit 的隐藏前过渡);没给则用 kit 的通知渲染器 + 过渡钩子 */
|
|
10
|
+
export function createKitRenderPorts(own?: SomaRenderPorts): SomaRenderPorts {
|
|
11
|
+
if (typeof document !== 'undefined') {
|
|
12
|
+
installKitOverlayRuntime(document);
|
|
13
|
+
// 吸顶页头的分隔:不支持 CSS 滚动驱动的浏览器走 IntersectionObserver 回退(支持的什么也不做)
|
|
14
|
+
installStickyEdgeFallback(document);
|
|
15
|
+
}
|
|
16
|
+
const hideTransition = createKitHideTransition();
|
|
17
|
+
return own !== undefined ? { hideTransition, ...own } : { notify: createKitNotifyRenderer(), hideTransition };
|
|
18
|
+
}
|
package/src/app/server-pages.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// 按 URL 提交(《soma-kit AI 页目标施工规格》§4.3):`pages.submit(地址, kit 源, 选项)` -> 本线闸门 -> 编译 -> 注入 core runtime 空间(owner `soma-kit`)。
|
|
2
|
-
// 与 soma-
|
|
2
|
+
// 与 soma-ui 共用 core 的提交步骤工具集(`soma-core/server/runtime` 的 checkSubmitOptions / decideSubmitAddress /
|
|
3
3
|
// precheckSubmitSlot / checkExpectedGeneration / stampSubmitEnvelope / buildRegisterRequest / registerPageOrReject /
|
|
4
4
|
// createProvenanceLedger / unbindOwnedPage / listPageBindings);方言自己只编排并保留与方言有关的步骤:
|
|
5
5
|
// ① 定址:submit 参数 × 源 `page.url`(占位值 KIT_PLACEHOLDER_URL 视为没写),对账由 core `decideSubmitAddress` 做;
|
|
@@ -20,6 +20,7 @@ import { canonicalJson, fnv1a64Hex } from 'soma-foundation/fingerprint';
|
|
|
20
20
|
import { compileKitPage } from '../compile/compile-page';
|
|
21
21
|
import { createYamlLocator } from '../compile/locate';
|
|
22
22
|
import type { KitAppContext, KitPageArtifact } from '../compile/types';
|
|
23
|
+
import { KIT_LAYOUT_LATEST_PIN } from '../object-renderer/layout-plan';
|
|
23
24
|
import {
|
|
24
25
|
KIT_PLACEHOLDER_URL,
|
|
25
26
|
KitSubmitError,
|
|
@@ -51,7 +52,13 @@ export interface KitServerPagesDeps {
|
|
|
51
52
|
readonly now?: () => number;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* 方言源内容摘要:与 URL、授权、调用方无关(dryRun 与 submit 的 `digest` 同值)。
|
|
57
|
+
*
|
|
58
|
+
* 只作来源登记(`options.source.digest`)与结果回显,不是 core 的判重键:`registerPageOrReject` 判重看的 `version`
|
|
59
|
+
* 是 `buildRegisterRequest` 对编译后标准载荷(html / uiYaml / eventYaml / styles / envelope …)取的摘要,
|
|
60
|
+
* 所以应用上下文(主题、词条、组件表、信封约定)变了、编出的载荷随之变了,重新提交不会被判为未变;载荷逐字相同才判未变。
|
|
61
|
+
*/
|
|
55
62
|
export function kitSourceDigest(source: string): string {
|
|
56
63
|
return fnv1a64Hex(canonicalJson({ source }));
|
|
57
64
|
}
|
|
@@ -189,7 +196,8 @@ export function createKitServerPages(deps: KitServerPagesDeps): KitServerPages {
|
|
|
189
196
|
// ④ 编译:page.url 覆盖为提交地址;受限写面的源里 page.roles 不收(access 由授权盖章)
|
|
190
197
|
const nextPage: Record<string, unknown> = { ...pageBlock, url: address };
|
|
191
198
|
if (restricted) delete nextPage.roles;
|
|
192
|
-
|
|
199
|
+
// 受限写面(AI 调用方)恒钉最新布局规则版本(RV-1117 T09);产物目前不随版本变(求解生效属第二期)
|
|
200
|
+
const compiled = await compileKitPage({ ...doc, page: nextPage }, restricted ? { ...appContext, layoutRules: KIT_LAYOUT_LATEST_PIN } : appContext);
|
|
193
201
|
if (compiled.artifact === undefined || compiled.diagnostics.length > 0) {
|
|
194
202
|
const locate = createYamlLocator(source.source);
|
|
195
203
|
const issues: PageDiagnostic[] = compiled.diagnostics.map((d) => {
|