soma-kit 0.0.0-stage → 0.1.0

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.
Files changed (353) hide show
  1. package/README.md +539 -2
  2. package/bin/soma-kit.mjs +27 -0
  3. package/package.json +66 -4
  4. package/packs/ai/agent-run-card.ts +64 -0
  5. package/packs/ai/evaluation-card.ts +51 -0
  6. package/packs/ai/guardrail-policy-card.ts +48 -0
  7. package/packs/ai/index.ts +31 -0
  8. package/packs/ai/model-card.ts +55 -0
  9. package/packs/ai/model-routing-card.ts +49 -0
  10. package/packs/ai/prompt-template-card.ts +49 -0
  11. package/packs/ai/texts.ts +19 -0
  12. package/packs/commerce/address-card.ts +58 -0
  13. package/packs/commerce/coupon-card.ts +64 -0
  14. package/packs/commerce/index.ts +25 -0
  15. package/packs/commerce/order-card.ts +60 -0
  16. package/packs/commerce/purchase-order-card.ts +74 -0
  17. package/packs/commerce/texts.ts +14 -0
  18. package/packs/finance/index.ts +30 -0
  19. package/packs/finance/invoice-summary-card.ts +48 -0
  20. package/packs/finance/reconcile-board.ts +450 -0
  21. package/packs/finance/reconcile-case-card.ts +70 -0
  22. package/packs/finance/reconcile-desk/compile.ts +208 -0
  23. package/packs/finance/reconcile-desk/index.ts +20 -0
  24. package/packs/finance/reconcile-desk/shell.ts +27 -0
  25. package/packs/finance/texts.ts +21 -0
  26. package/packs/ops/change-window-card.ts +54 -0
  27. package/packs/ops/dependency-status-card.ts +50 -0
  28. package/packs/ops/error-budget-card.ts +60 -0
  29. package/packs/ops/execution-task-runner.ts +61 -0
  30. package/packs/ops/index.ts +36 -0
  31. package/packs/ops/integration-status-card.ts +45 -0
  32. package/packs/ops/release-readiness-card.ts +63 -0
  33. package/packs/ops/runbook-execution-card.ts +81 -0
  34. package/packs/ops/texts.ts +21 -0
  35. package/packs/security/control-evidence-card.ts +54 -0
  36. package/packs/security/finding-card.ts +96 -0
  37. package/packs/security/index.ts +29 -0
  38. package/packs/security/texts.ts +31 -0
  39. package/packs/shared/card-util.ts +60 -0
  40. package/packs/shared/wrap.ts +13 -0
  41. package/spec/generated/kit-app.schema.json +84 -0
  42. package/spec/generated/kit-page.schema.json +2766 -0
  43. package/spec/kit-grammar.json +1358 -0
  44. package/spec/kit-grammar.schema.json +716 -0
  45. package/src/app/app-config.ts +108 -0
  46. package/src/app/compose-apps.ts +139 -0
  47. package/src/app/define-kit-actions.ts +89 -0
  48. package/src/app/define-kit-app.ts +362 -0
  49. package/src/app/define-kit-pack.ts +114 -0
  50. package/src/app/envelope.ts +117 -0
  51. package/src/app/index.ts +50 -0
  52. package/src/app/notify-renderer.ts +114 -0
  53. package/src/app/paged-list-adapter.ts +246 -0
  54. package/src/app/server-pages.ts +303 -0
  55. package/src/app/server.ts +244 -0
  56. package/src/app/submit.types.ts +87 -0
  57. package/src/base/action-busy.ts +159 -0
  58. package/src/base/action-gate.ts +267 -0
  59. package/src/base/action-status.ts +31 -0
  60. package/src/base/alert.ts +136 -0
  61. package/src/base/avatar.ts +271 -0
  62. package/src/base/button.ts +139 -0
  63. package/src/base/cascader.ts +523 -0
  64. package/src/base/check-core.ts +214 -0
  65. package/src/base/checkbox.ts +35 -0
  66. package/src/base/choice.ts +183 -0
  67. package/src/base/color-picker.ts +316 -0
  68. package/src/base/combobox.ts +61 -0
  69. package/src/base/command-palette.ts +371 -0
  70. package/src/base/context-menu.ts +103 -0
  71. package/src/base/countdown.ts +168 -0
  72. package/src/base/date-range.ts +444 -0
  73. package/src/base/date.ts +899 -0
  74. package/src/base/divider.ts +156 -0
  75. package/src/base/fab.ts +192 -0
  76. package/src/base/icons.ts +106 -0
  77. package/src/base/image.ts +177 -0
  78. package/src/base/index.ts +214 -0
  79. package/src/base/input.ts +316 -0
  80. package/src/base/kbd.ts +99 -0
  81. package/src/base/link.ts +167 -0
  82. package/src/base/listbox-core.ts +965 -0
  83. package/src/base/mentions.ts +323 -0
  84. package/src/base/menu-button.ts +240 -0
  85. package/src/base/menu-core.ts +341 -0
  86. package/src/base/month-grid.ts +171 -0
  87. package/src/base/motion/aura.ts +94 -0
  88. package/src/base/motion/hover-3d.ts +154 -0
  89. package/src/base/motion/hover-gallery.ts +185 -0
  90. package/src/base/motion/index.ts +27 -0
  91. package/src/base/motion/limits.ts +75 -0
  92. package/src/base/motion/marquee.ts +157 -0
  93. package/src/base/motion/text-rotate.ts +195 -0
  94. package/src/base/number.ts +121 -0
  95. package/src/base/otp.ts +259 -0
  96. package/src/base/permission-gate.ts +99 -0
  97. package/src/base/popover.ts +352 -0
  98. package/src/base/popup.ts +542 -0
  99. package/src/base/portal-core.ts +297 -0
  100. package/src/base/price-text.ts +126 -0
  101. package/src/base/progress.ts +216 -0
  102. package/src/base/qr-code.ts +446 -0
  103. package/src/base/qty-stepper.ts +241 -0
  104. package/src/base/radio.ts +33 -0
  105. package/src/base/range.ts +444 -0
  106. package/src/base/rating.ts +249 -0
  107. package/src/base/segmented.ts +286 -0
  108. package/src/base/select.ts +57 -0
  109. package/src/base/shared.ts +708 -0
  110. package/src/base/swap.ts +86 -0
  111. package/src/base/switch.ts +111 -0
  112. package/src/base/tag-input.ts +464 -0
  113. package/src/base/tag.ts +250 -0
  114. package/src/base/text.ts +126 -0
  115. package/src/base/textarea.ts +129 -0
  116. package/src/base/time-picker.ts +606 -0
  117. package/src/base/tree-select.ts +629 -0
  118. package/src/base/upload.ts +548 -0
  119. package/src/base/virtual-list.ts +286 -0
  120. package/src/biz/approval-desk/compile.ts +179 -0
  121. package/src/biz/approval-desk/index.ts +21 -0
  122. package/src/biz/approval-desk/shell.ts +50 -0
  123. package/src/biz/auth-panel/compile.ts +196 -0
  124. package/src/biz/auth-panel/index.ts +24 -0
  125. package/src/biz/auth-panel/shell.ts +46 -0
  126. package/src/biz/category-crud/compile.ts +173 -0
  127. package/src/biz/category-crud/index.ts +19 -0
  128. package/src/biz/category-crud/shell.ts +29 -0
  129. package/src/biz/checkout-page/compile.ts +111 -0
  130. package/src/biz/checkout-page/index.ts +20 -0
  131. package/src/biz/checkout-page/shell.ts +50 -0
  132. package/src/biz/compose.ts +313 -0
  133. package/src/biz/data-components.ts +26 -0
  134. package/src/biz/define.ts +23 -0
  135. package/src/biz/import-wizard/compile.ts +204 -0
  136. package/src/biz/import-wizard/hub.ts +540 -0
  137. package/src/biz/import-wizard/index.ts +24 -0
  138. package/src/biz/import-wizard/shell.ts +161 -0
  139. package/src/biz/index.ts +80 -0
  140. package/src/biz/landing-page/compile.ts +67 -0
  141. package/src/biz/landing-page/index.ts +20 -0
  142. package/src/biz/landing-page/shell.ts +48 -0
  143. package/src/biz/link/hub.ts +255 -0
  144. package/src/biz/link/shared.ts +493 -0
  145. package/src/biz/master-sub/compile.ts +232 -0
  146. package/src/biz/master-sub/index.ts +20 -0
  147. package/src/biz/master-sub/shell.ts +56 -0
  148. package/src/biz/multi-board/compile.ts +234 -0
  149. package/src/biz/multi-board/index.ts +19 -0
  150. package/src/biz/multi-board/shell.ts +70 -0
  151. package/src/biz/names.ts +30 -0
  152. package/src/biz/notification-center/compile.ts +138 -0
  153. package/src/biz/notification-center/index.ts +29 -0
  154. package/src/biz/notification-center/shell.ts +42 -0
  155. package/src/biz/page-templates/result-page/compile.ts +46 -0
  156. package/src/biz/page-templates/result-page/index.ts +19 -0
  157. package/src/biz/page-templates/result-page/shell.ts +31 -0
  158. package/src/biz/page-templates/shared.ts +121 -0
  159. package/src/biz/page-templates/sign-in-page/compile.ts +176 -0
  160. package/src/biz/page-templates/sign-in-page/index.ts +18 -0
  161. package/src/biz/page-templates/sign-in-page/shell.ts +116 -0
  162. package/src/biz/record-detail/compile.ts +290 -0
  163. package/src/biz/record-detail/index.ts +22 -0
  164. package/src/biz/record-detail/shell.ts +64 -0
  165. package/src/biz/settings-center/compile.ts +100 -0
  166. package/src/biz/settings-center/index.ts +18 -0
  167. package/src/biz/settings-center/shell.ts +51 -0
  168. package/src/biz/shared/action-host.ts +469 -0
  169. package/src/biz/shared/coordinator.ts +516 -0
  170. package/src/biz/shared/index.ts +9 -0
  171. package/src/biz/shared/pipes.ts +58 -0
  172. package/src/biz/shared/runtime-hub.ts +112 -0
  173. package/src/biz/shared/step-values.ts +25 -0
  174. package/src/biz/single-form/compile.ts +146 -0
  175. package/src/biz/single-form/index.ts +18 -0
  176. package/src/biz/single-form/shell.ts +38 -0
  177. package/src/biz/standard-crud/bridge.ts +11 -0
  178. package/src/biz/standard-crud/compile.ts +546 -0
  179. package/src/biz/standard-crud/index.ts +18 -0
  180. package/src/biz/standard-crud/shell.ts +157 -0
  181. package/src/biz/step-form/compile.ts +400 -0
  182. package/src/biz/step-form/hub.ts +412 -0
  183. package/src/biz/step-form/index.ts +23 -0
  184. package/src/biz/step-form/shell.ts +96 -0
  185. package/src/biz/step-form/steps-ref.ts +112 -0
  186. package/src/biz/types.ts +96 -0
  187. package/src/cli/kit-cli.ts +102 -0
  188. package/src/compile/action-host-attach.ts +76 -0
  189. package/src/compile/compile-page.ts +472 -0
  190. package/src/compile/component-candidates.ts +147 -0
  191. package/src/compile/fragment.ts +104 -0
  192. package/src/compile/hints.ts +255 -0
  193. package/src/compile/index.ts +16 -0
  194. package/src/compile/locate.ts +166 -0
  195. package/src/compile/page-params.ts +80 -0
  196. package/src/compile/parse.ts +355 -0
  197. package/src/compile/redirect.ts +90 -0
  198. package/src/compile/registry.ts +30 -0
  199. package/src/compile/remove-guard.ts +99 -0
  200. package/src/compile/styles.ts +244 -0
  201. package/src/compile/types.ts +106 -0
  202. package/src/data/amount-breakdown.ts +132 -0
  203. package/src/data/anchor-nav.ts +225 -0
  204. package/src/data/approval-flow.ts +269 -0
  205. package/src/data/assignment-picker.ts +652 -0
  206. package/src/data/async-result-panel.ts +308 -0
  207. package/src/data/breadcrumbs.ts +197 -0
  208. package/src/data/calendar.ts +363 -0
  209. package/src/data/carousel.ts +408 -0
  210. package/src/data/chart.ts +726 -0
  211. package/src/data/checklist.ts +215 -0
  212. package/src/data/code-view.ts +415 -0
  213. package/src/data/comment-thread.ts +342 -0
  214. package/src/data/confirm-dialog.ts +144 -0
  215. package/src/data/context-menu.ts +216 -0
  216. package/src/data/d9-limits.ts +42 -0
  217. package/src/data/d9-util.ts +81 -0
  218. package/src/data/diff.ts +239 -0
  219. package/src/data/display-util.ts +135 -0
  220. package/src/data/dock.ts +152 -0
  221. package/src/data/embed.ts +200 -0
  222. package/src/data/field-mapper.ts +544 -0
  223. package/src/data/flow-editor-contract.ts +41 -0
  224. package/src/data/flow-editor.ts +2622 -0
  225. package/src/data/flow-remote-options.ts +257 -0
  226. package/src/data/footer.ts +157 -0
  227. package/src/data/form-draft-registry.ts +76 -0
  228. package/src/data/gantt.ts +430 -0
  229. package/src/data/hero.ts +149 -0
  230. package/src/data/image-viewer.ts +333 -0
  231. package/src/data/index.ts +268 -0
  232. package/src/data/item-list.ts +335 -0
  233. package/src/data/kanban.ts +667 -0
  234. package/src/data/media-grid.ts +246 -0
  235. package/src/data/mega-menu.ts +257 -0
  236. package/src/data/menu-dom.ts +169 -0
  237. package/src/data/menu.ts +464 -0
  238. package/src/data/mockup.ts +176 -0
  239. package/src/data/modal-dialog.ts +182 -0
  240. package/src/data/navbar.ts +292 -0
  241. package/src/data/object-form.ts +1981 -0
  242. package/src/data/options-bus.ts +24 -0
  243. package/src/data/outcome-watch.ts +40 -0
  244. package/src/data/overlay-portal.ts +6 -0
  245. package/src/data/pager.ts +473 -0
  246. package/src/data/permission-matrix.ts +432 -0
  247. package/src/data/permission-tree.ts +916 -0
  248. package/src/data/pricing-table.ts +269 -0
  249. package/src/data/prompt-dialog.ts +235 -0
  250. package/src/data/reaction-bar.ts +236 -0
  251. package/src/data/record-card.ts +413 -0
  252. package/src/data/record-picker.ts +489 -0
  253. package/src/data/redirect.ts +109 -0
  254. package/src/data/remote-options.ts +54 -0
  255. package/src/data/request-console.ts +399 -0
  256. package/src/data/resident.ts +58 -0
  257. package/src/data/result-panel.ts +160 -0
  258. package/src/data/rich-text.ts +626 -0
  259. package/src/data/row-editor.ts +1066 -0
  260. package/src/data/rule-builder.ts +1137 -0
  261. package/src/data/shape-util.ts +221 -0
  262. package/src/data/staged-rows.ts +69 -0
  263. package/src/data/stat-group.ts +231 -0
  264. package/src/data/static-lazy.ts +63 -0
  265. package/src/data/static-registry.ts +227 -0
  266. package/src/data/steps.ts +195 -0
  267. package/src/data/survey.ts +455 -0
  268. package/src/data/system-switcher.ts +243 -0
  269. package/src/data/timeline.ts +204 -0
  270. package/src/data/tour-guide.ts +392 -0
  271. package/src/data/transfer.ts +597 -0
  272. package/src/data/tree-check.ts +30 -0
  273. package/src/data/tree-table.ts +674 -0
  274. package/src/data/tree.ts +656 -0
  275. package/src/data/trend-line.ts +147 -0
  276. package/src/data/virtual-rows.ts +556 -0
  277. package/src/data/watermark.ts +140 -0
  278. package/src/data/wrap.ts +267 -0
  279. package/src/data/wrapped-candidates.ts +96 -0
  280. package/src/frames/blank-frame.ts +19 -0
  281. package/src/frames/index.ts +44 -0
  282. package/src/frames/page-bar.ts +185 -0
  283. package/src/frames/page-header.ts +185 -0
  284. package/src/frames/page-status.ts +54 -0
  285. package/src/frames/resize-handle.ts +147 -0
  286. package/src/frames/shared.ts +242 -0
  287. package/src/frames/single-frame.ts +16 -0
  288. package/src/frames/split-frame/index.ts +4 -0
  289. package/src/frames/split-frame/shell.ts +219 -0
  290. package/src/frames/split-frame/span.ts +64 -0
  291. package/src/frames/split-frame/wiring.ts +164 -0
  292. package/src/frames/tabs-frame/index.ts +3 -0
  293. package/src/frames/tabs-frame/shell.ts +112 -0
  294. package/src/frames/tabs-frame/wiring.ts +69 -0
  295. package/src/frames/top-main-frame.ts +20 -0
  296. package/src/frames/types.ts +72 -0
  297. package/src/frames/workspace-frame/extras.ts +197 -0
  298. package/src/frames/workspace-frame/index.ts +13 -0
  299. package/src/frames/workspace-frame/shell.ts +282 -0
  300. package/src/frames/workspace-frame/state.ts +152 -0
  301. package/src/frames/workspace-frame/view.ts +1013 -0
  302. package/src/generated/kit-grammar-runtime.ts +2822 -0
  303. package/src/generated/page-origin.ts +57 -0
  304. package/src/i18n/index.ts +22 -0
  305. package/src/i18n/kit-text.ts +692 -0
  306. package/src/i18n/resolve-text-refs.ts +128 -0
  307. package/src/index.ts +6 -0
  308. package/src/object-renderer/action-gate.ts +216 -0
  309. package/src/object-renderer/adopt-gate.ts +333 -0
  310. package/src/object-renderer/arrange.ts +411 -0
  311. package/src/object-renderer/candidates.ts +68 -0
  312. package/src/object-renderer/collapse-wiring.ts +99 -0
  313. package/src/object-renderer/collection-expand.ts +185 -0
  314. package/src/object-renderer/collection-parts.ts +653 -0
  315. package/src/object-renderer/collection-table.ts +503 -0
  316. package/src/object-renderer/collection.ts +628 -0
  317. package/src/object-renderer/compile-data.ts +549 -0
  318. package/src/object-renderer/defaults.ts +252 -0
  319. package/src/object-renderer/display-checks.ts +153 -0
  320. package/src/object-renderer/emit-events.ts +498 -0
  321. package/src/object-renderer/emit-object.ts +98 -0
  322. package/src/object-renderer/emit-static.ts +1036 -0
  323. package/src/object-renderer/field-policy.ts +89 -0
  324. package/src/object-renderer/field-value.ts +581 -0
  325. package/src/object-renderer/form-detail.ts +116 -0
  326. package/src/object-renderer/index.ts +13 -0
  327. package/src/object-renderer/linkage.ts +371 -0
  328. package/src/object-renderer/merge-class.ts +126 -0
  329. package/src/object-renderer/mode.ts +25 -0
  330. package/src/object-renderer/outcome-draft.ts +61 -0
  331. package/src/object-renderer/parts.ts +136 -0
  332. package/src/object-renderer/pick-component.ts +36 -0
  333. package/src/object-renderer/render-object.ts +724 -0
  334. package/src/object-renderer/request-actions.ts +581 -0
  335. package/src/object-renderer/skeleton.ts +101 -0
  336. package/src/object-renderer/table-actions.ts +438 -0
  337. package/src/object-renderer/table-summary.ts +105 -0
  338. package/src/object-renderer/table-tools.ts +1072 -0
  339. package/src/object-renderer/types.ts +936 -0
  340. package/src/page-target/ai-surface.ts +154 -0
  341. package/src/page-target/compile.ts +354 -0
  342. package/src/page-target/drift.ts +186 -0
  343. package/src/page-target/index.ts +25 -0
  344. package/src/page-target/intent-map.ts +137 -0
  345. package/src/page-target/intent-schema.ts +711 -0
  346. package/src/page-target/origin.ts +17 -0
  347. package/src/page-target/target.ts +450 -0
  348. package/src/page-target/writer-policy.ts +315 -0
  349. package/src/theme/block-theme.ts +202 -0
  350. package/src/theme/kit-theme-text.ts +2 -0
  351. package/src/theme/kit-theme.css +275 -0
  352. package/src/theme/kit-theme.tpl +275 -0
  353. package/src/theme/theme-tokens.ts +135 -0
@@ -0,0 +1,63 @@
1
+ // OpsReleaseReadinessCard:发布就绪卡(accept: single)。包一层内置 Checklist。
2
+ //
3
+ // 数据:{ release, version?, status?, tone?, items: [{ id, label, done?, status?, note? }] }(键名可由 map 改写)。
4
+ // 呈现:标题 =「发布名 版本」,检查项交给 Checklist(done / blocked / pending,blocked 显式写原因)。
5
+ // 结论位:数据给了 status 就用它;没给时按固定规则取——有 blocked 条目 -> 「已阻塞」(danger),全部 done -> 「可发布」(success),否则「待完成」(warning)。
6
+ // 文案可由 blocked_text / ready_text / pending_text 改。勾选抛 toggle / change,底部动作 `actions` 抛 action { key };`readonly` 为真时只展示。
7
+
8
+ import type { SomaComponentDefinition } from 'soma-core';
9
+ import { createChecklist, checkItemsOf } from '../../src/data/checklist';
10
+ import { list } from '../shared/card-util';
11
+ import { mapKeys, rec, tone, txt, wrapBuiltin, type PackProps } from '../shared/wrap';
12
+ import { packLabel } from '../shared/card-util';
13
+ import './texts';
14
+
15
+ const L = (p: PackProps, key: string): string => packLabel('ops.release_readiness', p, key);
16
+
17
+ export const OPS_RELEASE_DEFAULT_MAP = Object.freeze({
18
+ release: 'release', version: 'version', status: 'status', tone: 'tone', items: 'items',
19
+ });
20
+
21
+ export function releaseReadinessCardProps(p: PackProps): PackProps {
22
+ const m = mapKeys(OPS_RELEASE_DEFAULT_MAP, p.map);
23
+ const d = rec(p.data);
24
+ const states = checkItemsOf(d[m.items], p.item_map, txt(p.no_reason_text)).map((i) => i.status);
25
+ const given = txt(d[m.status]);
26
+ let status = given;
27
+ let t = tone(d[m.tone], 'neutral');
28
+ if (given === '') {
29
+ if (states.includes('blocked')) { status = txt(p.blocked_text); t = 'danger'; }
30
+ else if (states.length > 0 && states.every((s) => s === 'done')) { status = L(p, 'ready_text'); t = 'success'; }
31
+ else { status = L(p, 'pending_text'); t = 'warning'; }
32
+ }
33
+ return {
34
+ data: {
35
+ title: [txt(d[m.release]), txt(d[m.version])].filter((s) => s !== '').join(' '),
36
+ status,
37
+ tone: t,
38
+ items: list(d[m.items]),
39
+ actions: list(p.actions),
40
+ },
41
+ map: {},
42
+ item_map: rec(p.item_map),
43
+ readonly: p.readonly === true || p.readonly === 'true',
44
+ no_reason_text: txt(p.no_reason_text),
45
+ blocked_text: txt(p.blocked_text),
46
+ empty_text: txt(p.empty_text),
47
+ class: txt(p.class),
48
+ };
49
+ }
50
+
51
+ export function createOpsReleaseReadinessCard(): SomaComponentDefinition {
52
+ return wrapBuiltin(createChecklist(), {
53
+ name: 'OpsReleaseReadinessCard',
54
+ props: {
55
+ data: { type: 'object', default: {}, desc: '一次发布 { release, version?, status?, tone?, items[{ id, label, done?, status?, note? }] }' },
56
+ map: { type: 'object', default: {}, desc: '键名对照:release / version / status / tone / items' },
57
+ actions: { type: 'array', default: [], desc: '底部动作 [{ key, label, tone?, disabled? }],点击抛 action { key }' },
58
+ ready_text: { type: 'string', default: '', desc: '全部完成时的结论文字;空取包词条(随页面语言)' },
59
+ pending_text: { type: 'string', default: '', desc: '尚有未完成项时的结论文字;空取包词条(随页面语言)' },
60
+ },
61
+ adapt: releaseReadinessCardProps,
62
+ });
63
+ }
@@ -0,0 +1,81 @@
1
+ // OpsRunbookExecutionCard:Runbook 执行卡(accept: single)。包一层内置 ApprovalFlow(沿用其纵向步骤形态)。
2
+ //
3
+ // 数据:{ title, operator?, status?, steps: [{ id, name, executor?, status, time?, comment?, reason?, actions? }] }(键名可由 map 改写)。
4
+ // 步骤状态按固定表映射到 ApprovalFlow 的八档:pending -> pending,running -> current,done / success -> approved,failed -> rejected,
5
+ // skipped / blocked / returned / withdrawn 原样,其余一律 pending。步骤动作 `actions` 抛 step_action { key, step },底部动作 `actions` 抛 action { key }。
6
+ // 只展示并上抛意图,执行与重试由页面处理。
7
+
8
+ import type { SomaComponentDefinition } from 'soma-core';
9
+ import { createApprovalFlow } from '../../src/data/approval-flow';
10
+ import { list } from '../shared/card-util';
11
+ import { mapKeys, rec, txt, wrapBuiltin, type PackProps } from '../shared/wrap';
12
+ import { packLabel } from '../shared/card-util';
13
+ import './texts';
14
+
15
+ const L = (p: PackProps, key: string): string => packLabel('ops.runbook_execution', p, key);
16
+
17
+ export const OPS_RUNBOOK_DEFAULT_MAP = Object.freeze({
18
+ title: 'title', operator: 'operator', status: 'status', steps: 'steps',
19
+ });
20
+ export const OPS_RUNBOOK_STEP_DEFAULT_MAP = Object.freeze({
21
+ id: 'id', name: 'name', executor: 'executor', status: 'status', time: 'time', comment: 'comment', reason: 'reason', actions: 'actions',
22
+ });
23
+
24
+ const STATUS_TABLE: Readonly<Record<string, string>> = Object.freeze({
25
+ pending: 'pending', running: 'current', done: 'approved', success: 'approved', failed: 'rejected',
26
+ skipped: 'skipped', blocked: 'blocked', returned: 'returned', withdrawn: 'withdrawn',
27
+ });
28
+
29
+ export function runbookStatusOf(raw: unknown): string {
30
+ return STATUS_TABLE[txt(raw)] ?? 'pending';
31
+ }
32
+
33
+ export function runbookExecutionCardProps(p: PackProps): PackProps {
34
+ const m = mapKeys(OPS_RUNBOOK_DEFAULT_MAP, p.map);
35
+ const sm = mapKeys(OPS_RUNBOOK_STEP_DEFAULT_MAP, p.step_map);
36
+ const d = rec(p.data);
37
+ const steps = list(d[m.steps]).map((s) => ({
38
+ id: s[sm.id],
39
+ name: s[sm.name],
40
+ approver: s[sm.executor],
41
+ status: runbookStatusOf(s[sm.status]),
42
+ time: s[sm.time],
43
+ comment: s[sm.comment],
44
+ reason: s[sm.reason],
45
+ actions: s[sm.actions],
46
+ }));
47
+ return {
48
+ data: {
49
+ title: txt(d[m.title]),
50
+ applicant: txt(d[m.operator]),
51
+ status: txt(d[m.status]),
52
+ steps,
53
+ actions: list(p.actions),
54
+ },
55
+ map: {},
56
+ step_map: {},
57
+ selectable: p.selectable === true || p.selectable === 'true',
58
+ labels: rec(p.labels),
59
+ applicant_label: L(p, 'operator_label'),
60
+ no_reason_text: txt(p.no_reason_text),
61
+ time_format: txt(p.time_format),
62
+ locale: txt(p.locale),
63
+ empty_text: L(p, 'empty_text'),
64
+ class: txt(p.class),
65
+ };
66
+ }
67
+
68
+ export function createOpsRunbookExecutionCard(): SomaComponentDefinition {
69
+ return wrapBuiltin(createApprovalFlow(), {
70
+ name: 'OpsRunbookExecutionCard',
71
+ props: {
72
+ data: { type: 'object', default: {}, desc: '一次 Runbook 执行 { title, operator?, status?, steps[{ id, name, executor?, status, time?, comment?, reason?, actions? }] }' },
73
+ map: { type: 'object', default: {}, desc: '键名对照:title / operator / status / steps' },
74
+ step_map: { type: 'object', default: {}, desc: '步骤层键名对照:id / name / executor / status / time / comment / reason / actions' },
75
+ actions: { type: 'array', default: [], desc: '底部动作 [{ key, label, tone?, disabled? }],点击抛 action { key }' },
76
+ operator_label: { type: 'string', default: '', desc: '执行人前缀文案;空取包词条(随页面语言)' },
77
+ empty_text: { type: 'string', default: '', desc: '没有步骤时的文案;空取包词条(随页面语言)' },
78
+ },
79
+ adapt: runbookExecutionCardProps,
80
+ });
81
+ }
@@ -0,0 +1,21 @@
1
+ // 运维包词条表(zh-CN / en):契约默认文案为空串,空串时回退到这里。键形 pack.<包>.<卡片>.<prop 名>。
2
+ import { defineKitPackTexts } from '../../src/i18n/kit-text';
3
+
4
+ defineKitPackTexts({
5
+ 'pack.ops.change_window.window_label': { 'zh-CN': '变更窗口', en: 'Change window' },
6
+ 'pack.ops.change_window.done_text': { 'zh-CN': '已完成', en: 'Done' },
7
+ 'pack.ops.change_window.pending_text': { 'zh-CN': '未完成', en: 'Not done' },
8
+ 'pack.ops.error_budget.slo_label': { 'zh-CN': '目标 SLO', en: 'SLO target' },
9
+ 'pack.ops.error_budget.consumed_label': { 'zh-CN': '已消耗', en: 'Consumed' },
10
+ 'pack.ops.error_budget.remaining_label': { 'zh-CN': '剩余', en: 'Remaining' },
11
+ 'pack.ops.error_budget.incidents_label': { 'zh-CN': '事件数', en: 'Incidents' },
12
+ 'pack.ops.release_readiness.ready_text': { 'zh-CN': '可发布', en: 'Ready to release' },
13
+ 'pack.ops.release_readiness.pending_text': { 'zh-CN': '待完成', en: 'Pending' },
14
+ 'pack.ops.execution_task_runner.started_label': { 'zh-CN': '开始时间', en: 'Started' },
15
+ 'pack.ops.dependency_status.version_label': { 'zh-CN': '版本', en: 'Version' },
16
+ 'pack.ops.dependency_status.latency_label': { 'zh-CN': '延迟', en: 'Latency' },
17
+ 'pack.ops.dependency_status.checked_label': { 'zh-CN': '最近检查', en: 'Last checked' },
18
+ 'pack.ops.integration_status.sync_label': { 'zh-CN': '最近同步', en: 'Last sync' },
19
+ 'pack.ops.runbook_execution.operator_label': { 'zh-CN': '执行人', en: 'Operator' },
20
+ 'pack.ops.runbook_execution.empty_text': { 'zh-CN': '暂无执行步骤', en: 'No steps yet' },
21
+ });
@@ -0,0 +1,54 @@
1
+ // SecurityControlEvidenceCard:控制证据卡(accept: single)。包一层内置 Checklist。
2
+ //
3
+ // 数据:{ control, source?, period_start?, period_end?, conclusion?, tone?, items?: [{ id, label, done?, status?, note? }] }(键名可由 map 改写)。
4
+ // 呈现:标题 =「控制项 · 来源 · 覆盖期」(给了的部分用「 · 」连接,覆盖期是「起 ~ 止」原样),结论位 = conclusion;
5
+ // 证据条目交给 Checklist(done / blocked / pending,blocked 显式写原因)。默认只读(`readonly` 缺省 true),底部动作 `actions` 抛 action { key }。
6
+
7
+ import type { SomaComponentDefinition } from 'soma-core';
8
+ import { createChecklist } from '../../src/data/checklist';
9
+ import { list } from '../shared/card-util';
10
+ import { mapKeys, rec, txt, wrapBuiltin, type PackProps } from '../shared/wrap';
11
+ import { packLabel } from '../shared/card-util';
12
+ import './texts';
13
+
14
+ export const SECURITY_EVIDENCE_DEFAULT_MAP = Object.freeze({
15
+ control: 'control', source: 'source', period_start: 'period_start', period_end: 'period_end', conclusion: 'conclusion', tone: 'tone', items: 'items',
16
+ });
17
+
18
+ export function controlEvidenceCardProps(p: PackProps): PackProps {
19
+ const m = mapKeys(SECURITY_EVIDENCE_DEFAULT_MAP, p.map);
20
+ const d = rec(p.data);
21
+ const from = txt(d[m.period_start]);
22
+ const to = txt(d[m.period_end]);
23
+ const period = from !== '' || to !== '' ? [from, to].filter((s) => s !== '').join(' ~ ') : '';
24
+ return {
25
+ data: {
26
+ title: [txt(d[m.control]), txt(d[m.source]), period].filter((s) => s !== '').join(' · '),
27
+ status: txt(d[m.conclusion]),
28
+ tone: d[m.tone],
29
+ items: list(d[m.items]),
30
+ actions: list(p.actions),
31
+ },
32
+ map: {},
33
+ item_map: rec(p.item_map),
34
+ readonly: p.readonly !== false && p.readonly !== 'false',
35
+ no_reason_text: txt(p.no_reason_text),
36
+ blocked_text: txt(p.blocked_text),
37
+ empty_text: packLabel('security.control_evidence', p, 'empty_text'),
38
+ class: txt(p.class),
39
+ };
40
+ }
41
+
42
+ export function createSecurityControlEvidenceCard(): SomaComponentDefinition {
43
+ return wrapBuiltin(createChecklist(), {
44
+ name: 'SecurityControlEvidenceCard',
45
+ props: {
46
+ data: { type: 'object', default: {}, desc: '一项控制的证据 { control, source?, period_start?, period_end?, conclusion?, tone?, items?[{ id, label, done?, status?, note? }] }' },
47
+ map: { type: 'object', default: {}, desc: '键名对照:control / source / period_start / period_end / conclusion / tone / items' },
48
+ actions: { type: 'array', default: [], desc: '底部动作 [{ key, label, tone?, disabled? }],点击抛 action { key }' },
49
+ readonly: { type: 'boolean', default: true, desc: '只展示,不可勾选(证据默认只读)' },
50
+ empty_text: { type: 'string', default: '', desc: '没有证据条目时的文案;空取包词条(随页面语言)' },
51
+ },
52
+ adapt: controlEvidenceCardProps,
53
+ });
54
+ }
@@ -0,0 +1,96 @@
1
+ // FindingCard 壳:合规 / 安全「发现类」卡共用的一份实现,包一层内置 RecordCard(accept: single)。
2
+ // 对外是四个组件名(同一壳、不同默认文案):
3
+ // SecurityAccessReviewCard(权限复核)、SecurityRiskFindingCard(风险发现)、SecurityFindingCard(安全发现)、
4
+ // SecurityVulnerabilityRemediationCard(漏洞整改)。
5
+ //
6
+ // 数据:{ id?, title, severity?, status?, tone?, asset?, owner?, found_at?, due_at?, summary?, tags?: string[] }(键名可由 map 改写)。
7
+ // 呈现:标题 = title,副标题 = id,状态位 = status;事实 = 对象 / 负责人 / 发现时间 / 期限 / 说明(标签文案随四种默认值不同,页面可用 *_label 覆盖);
8
+ // 标签 = 严重度(severity 原样)在前,tags 在后;左侧语气色细条。
9
+ // 语气:数据给了 tone 就用它;否则按严重度固定表——critical / high -> danger,medium -> warning,low -> info,其他 neutral。
10
+ // 动作位 `actions` 抛 action { key },`selectable` 抛 select { item }。
11
+
12
+ import type { SomaComponentDefinition } from 'soma-core';
13
+ import { createRecordCard } from '../../src/data/record-card';
14
+ import { list, packLabel, pushFact, recordCardProps, strList } from '../shared/card-util';
15
+ import './texts';
16
+ import { mapKeys, rec, tone, txt, wrapBuiltin, type PackProps } from '../shared/wrap';
17
+
18
+ export const SECURITY_FINDING_DEFAULT_MAP = Object.freeze({
19
+ id: 'id', title: 'title', severity: 'severity', status: 'status', tone: 'tone', asset: 'asset', owner: 'owner',
20
+ found_at: 'found_at', due_at: 'due_at', summary: 'summary', tags: 'tags',
21
+ });
22
+
23
+ const SEVERITY_TONE: Readonly<Record<string, string>> = Object.freeze({
24
+ critical: 'danger', high: 'danger', medium: 'warning', low: 'info',
25
+ });
26
+
27
+ export function findingToneOf(severity: unknown, given: unknown): string {
28
+ return tone(given, SEVERITY_TONE[txt(severity).toLowerCase()] ?? 'neutral');
29
+ }
30
+
31
+ /** 四个组件名 -> 词条卡片段(pack.security.<段>.<prop 名>) */
32
+ const FINDING_TEXT_SCOPE: Readonly<Record<string, string>> = Object.freeze({
33
+ SecurityAccessReviewCard: 'security.access_review',
34
+ SecurityRiskFindingCard: 'security.risk_finding',
35
+ SecurityFindingCard: 'security.finding',
36
+ SecurityVulnerabilityRemediationCard: 'security.vulnerability_remediation',
37
+ });
38
+
39
+ /** scope 缺省按「安全发现」那一套文案 */
40
+ export function findingCardProps(p: PackProps, scope = 'security.finding'): PackProps {
41
+ const m = mapKeys(SECURITY_FINDING_DEFAULT_MAP, p.map);
42
+ const d = rec(p.data);
43
+ const severity = txt(d[m.severity]);
44
+ const facts: PackProps[] = [];
45
+ pushFact(facts, packLabel(scope, p, 'asset_label'), d[m.asset]);
46
+ pushFact(facts, packLabel(scope, p, 'owner_label'), d[m.owner]);
47
+ pushFact(facts, packLabel(scope, p, 'found_label'), d[m.found_at]);
48
+ pushFact(facts, packLabel(scope, p, 'due_label'), d[m.due_at]);
49
+ pushFact(facts, packLabel(scope, p, 'summary_label'), d[m.summary]);
50
+ return recordCardProps(p, {
51
+ title: txt(d[m.title]),
52
+ subtitle: txt(d[m.id]),
53
+ status: txt(d[m.status]),
54
+ tone: findingToneOf(severity, d[m.tone]),
55
+ facts,
56
+ tags: [...(severity !== '' ? [severity] : []), ...strList(d[m.tags])],
57
+ actions: list(p.actions),
58
+ }, true);
59
+ }
60
+
61
+ export interface FindingLabels {
62
+ asset: string;
63
+ owner: string;
64
+ found: string;
65
+ due: string;
66
+ summary: string;
67
+ desc: string;
68
+ }
69
+
70
+ /** 四个组件名对应的默认文案与说明(同一壳,只有这里不同) */
71
+ export const SECURITY_FINDING_KINDS = Object.freeze({
72
+ SecurityAccessReviewCard: { asset: '复核对象', owner: '复核人', found: '发起时间', due: '复核期限', summary: '复核说明', desc: '权限复核卡:对象 / 复核人 / 期限' },
73
+ SecurityRiskFindingCard: { asset: '风险对象', owner: '责任人', found: '识别时间', due: '处置期限', summary: '风险说明', desc: '风险发现卡:对象 / 责任人 / 期限' },
74
+ SecurityFindingCard: { asset: '受影响资产', owner: '负责人', found: '发现时间', due: '处置期限', summary: '说明', desc: '安全发现卡:资产 / 负责人 / 期限' },
75
+ SecurityVulnerabilityRemediationCard: { asset: '受影响组件', owner: '整改负责人', found: '披露时间', due: '整改期限', summary: '整改措施', desc: '漏洞整改卡:组件 / 负责人 / 整改期限' },
76
+ } satisfies Record<string, FindingLabels>);
77
+
78
+ export type SecurityFindingKind = keyof typeof SECURITY_FINDING_KINDS;
79
+
80
+ export function createSecurityFindingCard(name: SecurityFindingKind): SomaComponentDefinition {
81
+ const l = SECURITY_FINDING_KINDS[name];
82
+ return wrapBuiltin(createRecordCard(), {
83
+ name,
84
+ props: {
85
+ data: { type: 'object', default: {}, desc: '一条发现 { id?, title, severity?, status?, tone?, asset?, owner?, found_at?, due_at?, summary?, tags? }' },
86
+ map: { type: 'object', default: {}, desc: '键名对照:id / title / severity / status / tone / asset / owner / found_at / due_at / summary / tags' },
87
+ actions: { type: 'array', default: [], desc: '底部动作 [{ key, label, tone?, disabled? }],点击抛 action { key }' },
88
+ asset_label: { type: 'string', default: '', desc: `对象事实行的标签;空取包词条(随页面语言,默认「${l.asset}」)` },
89
+ owner_label: { type: 'string', default: '', desc: `负责人事实行的标签;空取包词条(随页面语言,默认「${l.owner}」)` },
90
+ found_label: { type: 'string', default: '', desc: `发现时间事实行的标签;空取包词条(随页面语言,默认「${l.found}」)` },
91
+ due_label: { type: 'string', default: '', desc: `期限事实行的标签;空取包词条(随页面语言,默认「${l.due}」)` },
92
+ summary_label: { type: 'string', default: '', desc: `说明事实行的标签;空取包词条(随页面语言,默认「${l.summary}」)` },
93
+ },
94
+ adapt: (p: PackProps) => findingCardProps(p, FINDING_TEXT_SCOPE[name] ?? 'security.finding'),
95
+ });
96
+ }
@@ -0,0 +1,29 @@
1
+ // 合规 / 安全领域包:权限复核、风险发现、安全发现、漏洞整改(四张共用 FindingCard 壳)+ 控制证据。
2
+ // 五张卡都是包一层内置件(RecordCard / Checklist)的写死形状数据组件(accept: single),不另写底层交互。
3
+ // 应用登记:`defineKitApp({ packs: [securityPack] })`。
4
+
5
+ import { defineKitPack } from '../../src/app/define-kit-pack';
6
+ import { createSecurityControlEvidenceCard } from './control-evidence-card';
7
+ import { createSecurityFindingCard, SECURITY_FINDING_KINDS } from './finding-card';
8
+
9
+ export {
10
+ createSecurityFindingCard, findingCardProps, findingToneOf, SECURITY_FINDING_DEFAULT_MAP, SECURITY_FINDING_KINDS,
11
+ } from './finding-card';
12
+ export type { SecurityFindingKind, FindingLabels } from './finding-card';
13
+ export { createSecurityControlEvidenceCard, controlEvidenceCardProps, SECURITY_EVIDENCE_DEFAULT_MAP } from './control-evidence-card';
14
+
15
+ export const securityPack = defineKitPack({
16
+ name: 'security',
17
+ staticComponents: {
18
+ SecurityAccessReviewCard: { define: () => createSecurityFindingCard('SecurityAccessReviewCard'), accept: 'single', desc: SECURITY_FINDING_KINDS.SecurityAccessReviewCard.desc },
19
+ SecurityRiskFindingCard: { define: () => createSecurityFindingCard('SecurityRiskFindingCard'), accept: 'single', desc: SECURITY_FINDING_KINDS.SecurityRiskFindingCard.desc },
20
+ SecurityFindingCard: { define: () => createSecurityFindingCard('SecurityFindingCard'), accept: 'single', desc: SECURITY_FINDING_KINDS.SecurityFindingCard.desc },
21
+ SecurityVulnerabilityRemediationCard: {
22
+ define: () => createSecurityFindingCard('SecurityVulnerabilityRemediationCard'),
23
+ accept: 'single',
24
+ desc: SECURITY_FINDING_KINDS.SecurityVulnerabilityRemediationCard.desc,
25
+ },
26
+ SecurityControlEvidenceCard: { define: createSecurityControlEvidenceCard, accept: 'single', desc: '控制证据卡:控制项 / 来源 / 覆盖期 / 证据清单' },
27
+ },
28
+ // 每张卡都 wrapBuiltin 内置件(RecordCard / Checklist):底层类随包装元数据按页并入,不再整包并入每页
29
+ });
@@ -0,0 +1,31 @@
1
+ // 安全包词条表(zh-CN / en):契约默认文案为空串,空串时回退到这里。键形 pack.<包>.<卡片>.<prop 名>。
2
+ // 发现类卡共用一个壳、四个组件名,默认文案按组件名分表(卡片段 = 组件名的 snake 形)。
3
+ import { defineKitPackTexts } from '../../src/i18n/kit-text';
4
+
5
+ defineKitPackTexts({
6
+ 'pack.security.control_evidence.empty_text': { 'zh-CN': '暂无证据', en: 'No evidence yet' },
7
+
8
+ 'pack.security.access_review.asset_label': { 'zh-CN': '复核对象', en: 'Review target' },
9
+ 'pack.security.access_review.owner_label': { 'zh-CN': '复核人', en: 'Reviewer' },
10
+ 'pack.security.access_review.found_label': { 'zh-CN': '发起时间', en: 'Initiated' },
11
+ 'pack.security.access_review.due_label': { 'zh-CN': '复核期限', en: 'Review due' },
12
+ 'pack.security.access_review.summary_label': { 'zh-CN': '复核说明', en: 'Review notes' },
13
+
14
+ 'pack.security.risk_finding.asset_label': { 'zh-CN': '风险对象', en: 'Risk target' },
15
+ 'pack.security.risk_finding.owner_label': { 'zh-CN': '责任人', en: 'Owner' },
16
+ 'pack.security.risk_finding.found_label': { 'zh-CN': '识别时间', en: 'Identified' },
17
+ 'pack.security.risk_finding.due_label': { 'zh-CN': '处置期限', en: 'Remediation due' },
18
+ 'pack.security.risk_finding.summary_label': { 'zh-CN': '风险说明', en: 'Risk notes' },
19
+
20
+ 'pack.security.finding.asset_label': { 'zh-CN': '受影响资产', en: 'Affected asset' },
21
+ 'pack.security.finding.owner_label': { 'zh-CN': '负责人', en: 'Owner' },
22
+ 'pack.security.finding.found_label': { 'zh-CN': '发现时间', en: 'Found' },
23
+ 'pack.security.finding.due_label': { 'zh-CN': '处置期限', en: 'Remediation due' },
24
+ 'pack.security.finding.summary_label': { 'zh-CN': '说明', en: 'Summary' },
25
+
26
+ 'pack.security.vulnerability_remediation.asset_label': { 'zh-CN': '受影响组件', en: 'Affected component' },
27
+ 'pack.security.vulnerability_remediation.owner_label': { 'zh-CN': '整改负责人', en: 'Remediation owner' },
28
+ 'pack.security.vulnerability_remediation.found_label': { 'zh-CN': '披露时间', en: 'Disclosed' },
29
+ 'pack.security.vulnerability_remediation.due_label': { 'zh-CN': '整改期限', en: 'Fix due' },
30
+ 'pack.security.vulnerability_remediation.summary_label': { 'zh-CN': '整改措施', en: 'Remediation' },
31
+ });
@@ -0,0 +1,60 @@
1
+ // 领域包的卡片适配小件:事实行、进度换算、RecordCard 通用外层 props。全部是纯函数。
2
+
3
+ import { list, txt, type PackProps } from './wrap';
4
+ import { kitPackText } from '../../src/i18n/kit-text';
5
+
6
+ /** 值是否算「给了」:undefined / null / 空串视为没给 */
7
+ export function has(raw: unknown): boolean {
8
+ return raw !== undefined && raw !== null && raw !== '';
9
+ }
10
+
11
+ export function numOf(raw: unknown): number | null {
12
+ if (!has(raw)) return null;
13
+ const n = typeof raw === 'number' ? raw : Number(raw);
14
+ return Number.isFinite(n) ? n : null;
15
+ }
16
+
17
+ /** 字符串数组:数组元素转文本并丢弃空串;不是数组返回空数组 */
18
+ export function strList(raw: unknown): string[] {
19
+ return Array.isArray(raw) ? raw.map((v) => txt(v)).filter((s) => s !== '') : [];
20
+ }
21
+
22
+ /** 给了值才追加一行事实 */
23
+ export function pushFact(facts: PackProps[], label: unknown, value: unknown, format = ''): void {
24
+ if (!has(value)) return;
25
+ facts.push(format !== '' ? { label: txt(label), value, format } : { label: txt(label), value });
26
+ }
27
+
28
+ /** 百分比换算(展示用,夹在 0–100);total 不大于 0 返回 undefined */
29
+ export function percentOf(part: number, total: number): number | undefined {
30
+ if (!(total > 0)) return undefined;
31
+ return Math.min(100, Math.max(0, (part / total) * 100));
32
+ }
33
+
34
+ export function bool(raw: unknown): boolean {
35
+ return raw === true || raw === 'true';
36
+ }
37
+
38
+ /** 卡片数据 -> 内置 RecordCard 的完整 props(data 已是 RecordCard 形状,map / fields 置空) */
39
+ export function recordCardProps(p: PackProps, data: PackProps, rail = false): PackProps {
40
+ return {
41
+ data,
42
+ map: {},
43
+ fields: [],
44
+ rail,
45
+ selectable: bool(p.selectable),
46
+ locale: txt(p.locale),
47
+ class: txt(p.class),
48
+ };
49
+ }
50
+
51
+ export { list };
52
+
53
+ /**
54
+ * 领域包默认文案:页面给了 prop 就用页面的;没给(契约默认值是空串)回退到该包登记的词条
55
+ * `pack.<scope>.<prop 名>`(scope = `<包>.<卡片>`),语言取自 prop `locale`(空 = zh-CN)。
56
+ */
57
+ export function packLabel(scope: string, p: PackProps, key: string): string {
58
+ const own = txt(p[key]);
59
+ return own !== '' ? own : kitPackText(`pack.${scope}.${key}`, txt(p.locale));
60
+ }
@@ -0,0 +1,13 @@
1
+ // 领域包共用:直接复用 soma-kit/src/data/wrap 的唯一实现(避免平行实现)。
2
+ export {
3
+ wrapBuiltin,
4
+ wrapKitDataComponent,
5
+ rec,
6
+ txt,
7
+ mapKeys,
8
+ list,
9
+ tone,
10
+ type PackProps,
11
+ type WrapOptions,
12
+ type WrapDataOptions,
13
+ } from '../../src/data/wrap';
@@ -0,0 +1,84 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "soma-kit/kit-app.schema.json",
4
+ "title": "soma-kit 应用配置(kit.app.yaml)",
5
+ "description": "键闭集对应 src/app/app-config.ts;勿手改,重新生成:npm run schema:build -w soma-kit",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "style": {
10
+ "type": "string",
11
+ "description": "主题头文件路径(相对应用根);缺省用内置 kit-theme.css"
12
+ },
13
+ "envelope": {
14
+ "type": "object",
15
+ "additionalProperties": false,
16
+ "description": "业务信封约定:failWhen 命中即业务失败(编进 core 的 failWhen);messagePath 失败文案位置;dataPath 成功数据位置",
17
+ "properties": {
18
+ "failWhen": {
19
+ "type": "object",
20
+ "description": "闭集谓词 { field, op, value } 或 all_of / any_of / none_of"
21
+ },
22
+ "messagePath": {
23
+ "type": "string",
24
+ "description": "失败时业务文案在响应里的点路径(须与 failWhen 一起写)"
25
+ },
26
+ "dataPath": {
27
+ "type": "string",
28
+ "description": "成功时数据在响应里的点路径(缺省不拆)"
29
+ }
30
+ }
31
+ },
32
+ "theme": {
33
+ "type": "object",
34
+ "additionalProperties": false,
35
+ "description": "主题声明,交 soma-foundation 求解令牌",
36
+ "properties": {
37
+ "palette_scheme": {
38
+ "type": "string"
39
+ },
40
+ "font_scheme": {
41
+ "type": "string"
42
+ },
43
+ "color": {
44
+ "type": "string"
45
+ },
46
+ "mode": {
47
+ "type": "string"
48
+ }
49
+ }
50
+ },
51
+ "baseComponents": {
52
+ "type": "object",
53
+ "description": "应用扩展的基础组件:App 开头的名字 -> 说明",
54
+ "propertyNames": {
55
+ "pattern": "^App[A-Z][A-Za-z0-9]*$"
56
+ },
57
+ "additionalProperties": {
58
+ "type": "string"
59
+ }
60
+ },
61
+ "staticObjectComponents": {
62
+ "type": "object",
63
+ "description": "应用扩展的写死形状数据组件:App 开头的名字 -> { accept, desc }",
64
+ "propertyNames": {
65
+ "pattern": "^App[A-Z][A-Za-z0-9]*$"
66
+ },
67
+ "additionalProperties": {
68
+ "type": "object",
69
+ "additionalProperties": false,
70
+ "properties": {
71
+ "accept": {
72
+ "enum": [
73
+ "single",
74
+ "list"
75
+ ]
76
+ },
77
+ "desc": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }