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
|
@@ -15,6 +15,7 @@ import { addEmit, classesIn, isRec, newParts, patchProps, type Rec } from '../li
|
|
|
15
15
|
import {
|
|
16
16
|
addClassTokens, checkAreas, emitReadOnlyMember, finishTemplate, normalizeFormObject, templateObjectName,
|
|
17
17
|
} from '../page-templates/shared';
|
|
18
|
+
import { CheckoutPage } from './index';
|
|
18
19
|
import { CHECKOUT_PAGE_AREAS, CHECKOUT_PAGE_CLASS, checkoutPageHtml, checkoutPageIds } from './shell';
|
|
19
20
|
import { kitText } from '../../i18n/kit-text';
|
|
20
21
|
|
|
@@ -46,14 +47,21 @@ export function compileCheckoutPage(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
46
47
|
const ids = checkoutPageIds(ctx.pageId);
|
|
47
48
|
|
|
48
49
|
// ---- 表单
|
|
49
|
-
const target = normalizeFormObject(
|
|
50
|
+
const target = normalizeFormObject(
|
|
51
|
+
rawForm as unknown as Rec,
|
|
52
|
+
'product.objects.form',
|
|
53
|
+
'CheckoutPage 的 form',
|
|
54
|
+
out.diagnostics,
|
|
55
|
+
CheckoutPage.roles.form,
|
|
56
|
+
);
|
|
50
57
|
if (out.diagnostics.length > 0) return finishTemplate(out, '');
|
|
51
58
|
const formObject = checkoutPageObjectName(ctx.pageId, 'form');
|
|
59
|
+
const scope = `${formObject}_scope`;
|
|
52
60
|
const hasFrom = target.behavior.from !== undefined;
|
|
53
61
|
const formView = (target.view?.form ?? {}) as KitViewForm;
|
|
54
62
|
const r = emitObject(
|
|
55
63
|
target as KitObject,
|
|
56
|
-
{ object: formObject, scope
|
|
64
|
+
{ object: formObject, scope, registered: ctx.registeredComponents, staticComponents: ctx.staticComponents },
|
|
57
65
|
{
|
|
58
66
|
registeredActions: ctx.registeredActions,
|
|
59
67
|
formMode: hasFrom ? 'edit' : 'create',
|
|
@@ -75,18 +83,26 @@ export function compileCheckoutPage(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
75
83
|
resetLabel: RESET_LABEL,
|
|
76
84
|
classes: { ...classes, actions: CHECKOUT_PAGE_CLASS.footer },
|
|
77
85
|
});
|
|
78
|
-
out.events[`${formId}.saved`] =
|
|
86
|
+
out.events[`${formId}.saved`] = `NOTIFY | success | ${SAVED_NOTICE}`;
|
|
79
87
|
const ft = formView.title;
|
|
80
88
|
const formTitle = typeof ft === 'string' ? ft : isRec(ft) ? String((hasFrom ? ft.edit : ft.create) ?? '') : '';
|
|
81
89
|
|
|
82
90
|
// ---- 摘要栏
|
|
83
91
|
const items = emitReadOnlyMember(out, rawItems, {
|
|
84
|
-
object: checkoutPageObjectName(ctx.pageId, 'items'),
|
|
92
|
+
object: checkoutPageObjectName(ctx.pageId, 'items'),
|
|
93
|
+
path: 'product.objects.items',
|
|
94
|
+
roleName: 'items',
|
|
95
|
+
roleDef: CheckoutPage.roles.items,
|
|
96
|
+
ctx,
|
|
85
97
|
});
|
|
86
98
|
let amounts = undefined as ReturnType<typeof emitReadOnlyMember>;
|
|
87
99
|
if (rawAmounts !== undefined) {
|
|
88
100
|
amounts = emitReadOnlyMember(out, rawAmounts, {
|
|
89
|
-
object: checkoutPageObjectName(ctx.pageId, 'amounts'),
|
|
101
|
+
object: checkoutPageObjectName(ctx.pageId, 'amounts'),
|
|
102
|
+
path: 'product.objects.amounts',
|
|
103
|
+
roleName: 'amounts',
|
|
104
|
+
roleDef: CheckoutPage.roles.amounts,
|
|
105
|
+
ctx,
|
|
90
106
|
});
|
|
91
107
|
}
|
|
92
108
|
if (out.diagnostics.length > 0 || items === undefined) return finishTemplate(out, '');
|
package/src/biz/compose.ts
CHANGED
|
@@ -9,7 +9,9 @@ import { emptyFragment, mergeFragments, type KitFragment } from '../compile/frag
|
|
|
9
9
|
import { checkClasses, mergeClass } from '../object-renderer/merge-class';
|
|
10
10
|
import type { KitDiagnostic, KitObject } from '../object-renderer/types';
|
|
11
11
|
import { defineKitBizComponent } from './define';
|
|
12
|
+
import { validateBizAreaClass } from './shared/compile-helpers';
|
|
12
13
|
import type { KitBizContext, KitBizDefinition, KitBizInput, KitBizRole } from './types';
|
|
14
|
+
import { kitFail } from '../compile/kit-error';
|
|
13
15
|
|
|
14
16
|
export interface WrapBizShellContext {
|
|
15
17
|
input: KitBizInput;
|
|
@@ -53,7 +55,7 @@ export function wrapKitBizComponent(inner: KitBizDefinition, options: WrapBizOpt
|
|
|
53
55
|
const extraTokens = splitCandidateTokens(options.candidates);
|
|
54
56
|
for (const tok of extraTokens) {
|
|
55
57
|
const bad = checkClasses(tok, `${options.kind}.candidates`);
|
|
56
|
-
if (bad.length > 0)
|
|
58
|
+
if (bad.length > 0) kitFail('KIT-COMP-003', `${options.kind}.candidates`, `${options.kind} 的 candidates 含非法类 "${tok}":${bad[0]!.message}`, '候选类只能用刻度内的 Tailwind 类,不写方括号任意值');
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
return defineKitBizComponent({
|
|
@@ -65,15 +67,7 @@ export function wrapKitBizComponent(inner: KitBizDefinition, options: WrapBizOpt
|
|
|
65
67
|
const diagnostics: KitDiagnostic[] = [];
|
|
66
68
|
|
|
67
69
|
// 1. 先按包装后的完整区域闭集校验页面传入的 areaClass
|
|
68
|
-
|
|
69
|
-
if (!allAreaSet.has(key)) {
|
|
70
|
-
diagnostics.push({
|
|
71
|
-
code: 'KIT-PAGE-001',
|
|
72
|
-
path: `product.areaClass.${key}`,
|
|
73
|
-
message: `areaClass 里的区域名 "${key}" 不在 ${options.kind} 的区域闭集 ${allAreas.join(' / ')} 内`,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
70
|
+
validateBizAreaClass(input, options.kind, allAreas, diagnostics);
|
|
77
71
|
|
|
78
72
|
// 2. 执行前置输入翻译(专属语法 -> 标准业务组件入参)
|
|
79
73
|
const adapted = options.adaptInput ? options.adaptInput(input, ctx, diagnostics) : input;
|
|
@@ -179,47 +173,47 @@ const PART_KEY_RE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
|
179
173
|
export function composeKitBizComponents(options: ComposeBizOptions): KitBizDefinition {
|
|
180
174
|
const partEntries = Object.entries(options.parts);
|
|
181
175
|
if (partEntries.length === 0) {
|
|
182
|
-
|
|
176
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts`, `composeKitBizComponents(${options.kind}) 至少需要 1 个子部件`, 'parts 里至少登记一个子部件');
|
|
183
177
|
}
|
|
184
178
|
|
|
185
179
|
const roles: Record<string, KitBizRole> = {};
|
|
186
180
|
let overlayOwnerCount = 0;
|
|
187
181
|
for (const [partKey, part] of partEntries) {
|
|
188
182
|
if (!PART_KEY_RE.test(partKey)) {
|
|
189
|
-
|
|
183
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}`, `${options.kind} 的子部件名 "${partKey}" 只能是字母开头的字母数字下划线`, '子部件名改成字母开头、只含字母数字下划线');
|
|
190
184
|
}
|
|
191
185
|
if (part.forwardOverlays === true) overlayOwnerCount += 1;
|
|
192
186
|
const mappedInner = new Set<string>(Object.keys(part.roleMap));
|
|
193
187
|
for (const [innerRole, innerSpec] of Object.entries(part.component.roles)) {
|
|
194
188
|
if (innerSpec.required && !mappedInner.has(innerRole)) {
|
|
195
|
-
|
|
189
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}.roleMap`, `${options.kind}.parts.${partKey} 未映射子组件 ${part.component.kind} 的必填角色 "${innerRole}"`, `在 roleMap 里加 ${innerRole}: 对外角色名`);
|
|
196
190
|
}
|
|
197
191
|
}
|
|
198
192
|
for (const [innerRole, outerRole] of Object.entries(part.roleMap)) {
|
|
199
193
|
const spec = part.component.roles[innerRole];
|
|
200
194
|
if (!spec) {
|
|
201
|
-
|
|
195
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}.roleMap.${innerRole}`, `${options.kind}.parts.${partKey} 映射了 ${part.component.kind} 不存在的角色 "${innerRole}"`, `roleMap 的键必须是 ${part.component.kind} 的角色名:${Object.keys(part.component.roles).join(' / ')}`);
|
|
202
196
|
}
|
|
203
197
|
if (outerRole in roles) {
|
|
204
|
-
|
|
198
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts.${partKey}.roleMap`, `${options.kind} 的对外角色名 "${outerRole}" 在多个子部件中重复`, '各子部件的对外角色名互不相同');
|
|
205
199
|
}
|
|
206
200
|
roles[outerRole] = { ...spec };
|
|
207
201
|
}
|
|
208
202
|
}
|
|
209
203
|
if (overlayOwnerCount > 1) {
|
|
210
|
-
|
|
204
|
+
kitFail('KIT-COMP-002', `${options.kind}.parts`, `${options.kind} 至多只能有 1 个子部件开启 forwardOverlays`, '只保留一个子部件的 forwardOverlays: true');
|
|
211
205
|
}
|
|
212
206
|
|
|
213
207
|
const baseRootClass = options.rootClass ?? '@container flex flex-col gap-6';
|
|
214
208
|
const badRoot = checkClasses(baseRootClass, `${options.kind}.rootClass`);
|
|
215
|
-
if (badRoot.length > 0)
|
|
209
|
+
if (badRoot.length > 0) kitFail('KIT-COMP-003', `${options.kind}.rootClass`, `${options.kind} 的 rootClass 非法:${badRoot[0]!.message}`, 'rootClass 只能用刻度内的 Tailwind 类');
|
|
216
210
|
|
|
217
211
|
const areas = [...new Set(['root', ...(options.areas ?? [])])];
|
|
218
212
|
const areaSet = new Set<string>(areas);
|
|
219
213
|
const extraTokens = splitCandidateTokens([baseRootClass, ...(options.candidates ?? [])]);
|
|
220
214
|
for (const tok of extraTokens) {
|
|
221
215
|
const bad = checkClasses(tok, `${options.kind}.candidates`);
|
|
222
|
-
if (bad.length > 0)
|
|
216
|
+
if (bad.length > 0) kitFail('KIT-COMP-003', `${options.kind}.candidates`, `${options.kind} 的 candidates 含非法类 "${tok}":${bad[0]!.message}`, '候选类只能用刻度内的 Tailwind 类,不写方括号任意值');
|
|
223
217
|
}
|
|
224
218
|
|
|
225
219
|
return defineKitBizComponent({
|
|
@@ -231,15 +225,7 @@ export function composeKitBizComponents(options: ComposeBizOptions): KitBizDefin
|
|
|
231
225
|
const diagnostics: KitDiagnostic[] = [];
|
|
232
226
|
const areaMap = input.areaClass ?? {};
|
|
233
227
|
|
|
234
|
-
|
|
235
|
-
if (!areaSet.has(key)) {
|
|
236
|
-
diagnostics.push({
|
|
237
|
-
code: 'KIT-PAGE-001',
|
|
238
|
-
path: `product.areaClass.${key}`,
|
|
239
|
-
message: `areaClass 里的区域名 "${key}" 不在 ${options.kind} 的区域闭集 ${areas.join(' / ')} 内`,
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
228
|
+
validateBizAreaClass(input, options.kind, areas, diagnostics);
|
|
243
229
|
if (input.overlays !== undefined && overlayOwnerCount === 0) {
|
|
244
230
|
diagnostics.push({
|
|
245
231
|
code: 'KIT-BIZ-003',
|
package/src/biz/define.ts
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
// 业务组件的 kind 必须是 PascalCase;roles 至少一个必填角色;areas 不得重名。
|
|
3
3
|
|
|
4
4
|
import type { KitBizDefinition } from './types';
|
|
5
|
+
import { kitFail } from '../compile/kit-error';
|
|
5
6
|
|
|
6
7
|
const KIND = /^[A-Z][A-Za-z0-9]*$/;
|
|
7
8
|
|
|
8
9
|
export function defineKitBizComponent(def: KitBizDefinition): KitBizDefinition {
|
|
9
10
|
if (!KIND.test(def.kind)) {
|
|
10
|
-
|
|
11
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}`, `业务组件名必须是 PascalCase,收到 "${def.kind}"`, '改成大写字母开头的驼峰名,如 OrderBoard');
|
|
11
12
|
}
|
|
12
13
|
const roles = Object.entries(def.roles);
|
|
13
14
|
if (roles.length === 0 || !roles.some(([, r]) => r.required)) {
|
|
14
|
-
|
|
15
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}.roles`, `业务组件 ${def.kind} 至少要有一个必填的对象角色槽`, 'roles 里至少有一个 required: true 的角色');
|
|
15
16
|
}
|
|
16
17
|
if (new Set(def.areas).size !== def.areas.length) {
|
|
17
|
-
|
|
18
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}.areas`, `业务组件 ${def.kind} 的 areas 有重名`, 'areas 里每个区域名只写一次');
|
|
18
19
|
}
|
|
19
20
|
if (typeof def.compile !== 'function') {
|
|
20
|
-
|
|
21
|
+
kitFail('KIT-COMP-002', `bizComponents.${def.kind}.compile`, `业务组件 ${def.kind} 缺 compile()`, '提供 compile(input, ctx) 返回片段');
|
|
21
22
|
}
|
|
22
23
|
return def;
|
|
23
24
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// 对象角色槽 target(必填):{ schema, behavior: { write }, title? }——导入目标:字段字典就是映射目标(rules.required 的字段为必映射),
|
|
4
4
|
// write 是逐行新增的写接口;不写 view(界面由模板写死)
|
|
5
|
-
// job(可选):只读展示对象,放在结果步里,常用 AsyncResultPanel
|
|
5
|
+
// job(可选):只读展示对象,放在结果步里,常用 AsyncResultPanel 接服务端的后台任务
|
|
6
6
|
// 上传 Upload 选一个 CSV(首行表头),浏览器内解析,不上传原文件
|
|
7
7
|
// 映射 FieldMapper:目标字段 <- 文件列;表头与字段 key / 名称相同的自动配上
|
|
8
8
|
// 预览校验 逐行按目标字典(rules)校验,问题行置顶并标红,可下载问题行报告;有问题的行不导入
|
|
@@ -15,10 +15,12 @@ import type { KitFieldSchema, KitObject } from '../../object-renderer/types';
|
|
|
15
15
|
import type { KitFragment } from '../../compile/fragment';
|
|
16
16
|
import type { KitBizContext, KitBizInput } from '../types';
|
|
17
17
|
import { kitText, type KitTextKey } from '../../i18n/kit-text';
|
|
18
|
+
import { finishBizCompile, validateBizAreaClass } from '../shared/compile-helpers';
|
|
18
19
|
import { KIT_IMPORT_EVENTS, KIT_IMPORT_MIRRORS, KIT_IMPORT_STEPS, type KitImportTarget } from './hub';
|
|
20
|
+
import { ImportWizard } from './index';
|
|
19
21
|
import {
|
|
20
|
-
classesIn,
|
|
21
|
-
type
|
|
22
|
+
classesIn, isRec, mirrorPath, newParts, semanticPipe, sortMirrors,
|
|
23
|
+
type Rec,
|
|
22
24
|
} from '../link/shared';
|
|
23
25
|
import { emitReadOnlyMember, templateObjectName } from '../page-templates/shared';
|
|
24
26
|
import {
|
|
@@ -29,17 +31,6 @@ export function importWizardObjectName(pageId: string, role: string): string {
|
|
|
29
31
|
return templateObjectName(pageId, role);
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
function finish(out: Parts, html: string): KitFragment {
|
|
33
|
-
return {
|
|
34
|
-
html,
|
|
35
|
-
ui: { data: out.data, scopes: out.scopes as unknown as Record<string, unknown>, show: out.show },
|
|
36
|
-
events: out.events,
|
|
37
|
-
components: [...out.components].sort(),
|
|
38
|
-
candidates: [...out.candidates].sort(),
|
|
39
|
-
diagnostics: dedupeDiagnostics(out.diagnostics),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
34
|
function requiredOf(field: KitFieldSchema): boolean {
|
|
44
35
|
const rules = (field as unknown as { rules?: unknown }).rules;
|
|
45
36
|
return Array.isArray(rules) && rules.some((r) => isRec(r) && r.required === true);
|
|
@@ -53,7 +44,7 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
53
44
|
const rawJob = input.objects.job;
|
|
54
45
|
if (!isRec(rawTarget) || !isRec(rawTarget.schema) || Object.keys(rawTarget.schema).length === 0) {
|
|
55
46
|
fail('KIT-BIZ-001', 'ImportWizard 缺少必填对象角色槽 target(需含非空 schema:导入字段字典)', 'product.objects.target');
|
|
56
|
-
return
|
|
47
|
+
return finishBizCompile(out, '');
|
|
57
48
|
}
|
|
58
49
|
if (!isRec(rawTarget.behavior) || (rawTarget.behavior as Rec).write === undefined) {
|
|
59
50
|
fail('KIT-BIZ-001', 'ImportWizard 的 target 需含 behavior.write(逐行新增的写接口)', 'product.objects.target.behavior.write');
|
|
@@ -64,12 +55,8 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
64
55
|
if ((rawTarget.behavior as Rec)[k] !== undefined) fail('KIT-BIZ-003', `ImportWizard 的 target 不支持 behavior.${k}`, `product.objects.target.behavior.${k}`);
|
|
65
56
|
}
|
|
66
57
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fail('KIT-PAGE-001', `areaClass 里的区域名 "${key}" 不在 ImportWizard 的区域闭集 ${IMPORT_WIZARD_AREAS.join(' / ')} 内`, `product.areaClass.${key}`);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (out.diagnostics.length > 0) return finish(out, '');
|
|
58
|
+
validateBizAreaClass(input, 'ImportWizard', IMPORT_WIZARD_AREAS, out.diagnostics);
|
|
59
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
73
60
|
|
|
74
61
|
const schema = rawTarget.schema as Record<string, KitFieldSchema>;
|
|
75
62
|
const targets: KitImportTarget[] = [];
|
|
@@ -84,7 +71,7 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
84
71
|
}
|
|
85
72
|
if (targets.length === 0) {
|
|
86
73
|
fail('KIT-BIZ-003', 'ImportWizard 的 target.schema 里没有可导入的字段(permission 不能全是 r)', 'product.objects.target.schema');
|
|
87
|
-
return
|
|
74
|
+
return finishBizCompile(out, '');
|
|
88
75
|
}
|
|
89
76
|
|
|
90
77
|
const ids = importWizardIds(ctx.pageId);
|
|
@@ -112,11 +99,15 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
112
99
|
let job = '';
|
|
113
100
|
if (rawJob !== undefined) {
|
|
114
101
|
const m = emitReadOnlyMember(out, rawJob, {
|
|
115
|
-
object: importWizardObjectName(ctx.pageId, 'job'),
|
|
102
|
+
object: importWizardObjectName(ctx.pageId, 'job'),
|
|
103
|
+
path: 'product.objects.job',
|
|
104
|
+
roleName: 'job',
|
|
105
|
+
roleDef: ImportWizard.roles.job,
|
|
106
|
+
ctx,
|
|
116
107
|
});
|
|
117
108
|
job = m?.html ?? '';
|
|
118
109
|
}
|
|
119
|
-
if (out.diagnostics.length > 0) return
|
|
110
|
+
if (out.diagnostics.length > 0) return finishBizCompile(out, '');
|
|
120
111
|
|
|
121
112
|
// ---- 链接作用域:focus 归 KitImportHub
|
|
122
113
|
const mirrors: SomaScopeMirrorDecl[] = [];
|
|
@@ -124,7 +115,7 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
124
115
|
for (let i = 0; i < KIT_IMPORT_STEPS; i += 1) { add(M.at(i)); add(M.past(i)); add(M.fut(i)); }
|
|
125
116
|
for (const x of [
|
|
126
117
|
M.files, M.parseError, M.fileInfo, M.upReady, M.upBlocked, M.mapData, M.mapReady, M.mapBlocked, M.summary, M.preview,
|
|
127
|
-
M.hasErrors, M.commitReady, M.commitBlocked, M.busy, M.notBusy, M.result,
|
|
118
|
+
M.hasErrors, M.commitReady, M.commitBlocked, M.cancelReady, M.cancelBlocked, M.busy, M.notBusy, M.result,
|
|
128
119
|
]) add(x);
|
|
129
120
|
out.scopes[link] = {
|
|
130
121
|
id: link,
|
|
@@ -149,6 +140,8 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
149
140
|
out.show[ids.btnGate('pre_download')] = { when: at(M.hasErrors.key) };
|
|
150
141
|
out.show[ids.btnGate('pre_commit')] = { when: at(M.commitReady.key) };
|
|
151
142
|
out.show[ids.btnGate('pre_commit', true)] = { when: at(M.commitBlocked.key) };
|
|
143
|
+
out.show[ids.btnGate('cancel')] = { when: at(M.cancelReady.key) };
|
|
144
|
+
out.show[ids.btnGate('cancel', true)] = { when: at(M.cancelBlocked.key) };
|
|
152
145
|
|
|
153
146
|
// ---- 各步组件与按钮
|
|
154
147
|
const T = (key: KitTextKey): string => kitText(key, undefined, ctx.locale);
|
|
@@ -189,6 +182,9 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
189
182
|
wire(ids.btn('pre_commit'), KIT_IMPORT_EVENTS.commit);
|
|
190
183
|
|
|
191
184
|
out.show[`${ids.progress}_text`] = { props: { value: at(M.summary.key), size: 'sm' } };
|
|
185
|
+
btn(ids.btn('cancel'), T('soma.kit.cancel'), 'neutral');
|
|
186
|
+
btn(ids.btn('cancel', true), T('soma.kit.cancel'), 'neutral', true);
|
|
187
|
+
wire(ids.btn('cancel'), KIT_IMPORT_EVENTS.cancel);
|
|
192
188
|
out.show[ids.result] = { props: { data: at(M.result.key) } };
|
|
193
189
|
out.events[`${ids.result}.action`] = semanticPipe(link, KIT_IMPORT_EVENTS.result);
|
|
194
190
|
|
|
@@ -200,5 +196,5 @@ export function compileImportWizard(input: KitBizInput, ctx: KitBizContext): Kit
|
|
|
200
196
|
const html = importWizardHtml(ids, { title, job }, areaClass, input.class, ctx.locale);
|
|
201
197
|
for (const c of classesIn(html)) out.candidates.add(c);
|
|
202
198
|
for (const c of Object.values(IMPORT_WIZARD_CLASS)) for (const t of c.split(/\s+/)) if (t !== '') out.candidates.add(t);
|
|
203
|
-
return
|
|
199
|
+
return finishBizCompile(out, html);
|
|
204
200
|
}
|