soma-core 1.4.2 → 1.5.1

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 (216) hide show
  1. package/bin/component.cjs +240 -0
  2. package/bin/eject.cjs +174 -0
  3. package/bin/migrate.cjs +362 -0
  4. package/core/build/blocks/block-compile.ts +143 -17
  5. package/core/build/blocks/migrate-flat.ts +118 -25
  6. package/core/build/compiler/page-declaration-compiler.ts +149 -5
  7. package/core/build/compiler/route-builder.ts +0 -4
  8. package/core/build/compiler/soma-precompile.js +431 -26
  9. package/core/build/component/component-graph.ts +28 -105
  10. package/core/build/component/package-loader.ts +18 -4
  11. package/core/build/eject/component-eject.ts +8 -2
  12. package/core/build/layout/constraint-solver.ts +131 -16
  13. package/core/build/layout/css-emitter.ts +29 -10
  14. package/core/build/ooui/artifact/artifact.types.ts +275 -0
  15. package/core/build/ooui/artifact/emit-artifact.ts +269 -0
  16. package/core/build/ooui/artifact/emit-html.ts +204 -0
  17. package/core/build/ooui/artifact/index.ts +53 -0
  18. package/core/build/ooui/artifact/spatial-tree.ts +268 -0
  19. package/core/build/ooui/artifact/utility-class.ts +83 -0
  20. package/core/build/ooui/composition/candidate.types.ts +323 -0
  21. package/core/build/ooui/composition/control-model.ts +114 -0
  22. package/core/build/ooui/composition/registry.ts +520 -0
  23. package/core/build/ooui/composition/select.ts +232 -0
  24. package/core/build/ooui/diagnostics/codes.ts +230 -0
  25. package/core/build/ooui/diagnostics/error.ts +235 -0
  26. package/core/build/ooui/diagnostics/format.ts +106 -0
  27. package/core/build/ooui/diagnostics/index.ts +62 -0
  28. package/core/build/ooui/diagnostics/issue.types.ts +112 -0
  29. package/core/build/ooui/engine-slot.ts +184 -0
  30. package/core/build/ooui/index.ts +1427 -0
  31. package/core/build/ooui/intent/derive-intent.ts +450 -0
  32. package/core/build/ooui/intent/field-rules.ts +330 -0
  33. package/core/build/ooui/intent/intent.types.ts +476 -0
  34. package/core/build/ooui/intent/verb-events.ts +285 -0
  35. package/core/build/ooui/page/budget.ts +503 -0
  36. package/core/build/ooui/page/compose-page.ts +736 -0
  37. package/core/build/ooui/page/index.ts +66 -0
  38. package/core/build/ooui/page/page.types.ts +402 -0
  39. package/core/build/ooui/page/region-row.ts +241 -0
  40. package/core/build/ooui/semantic/expand-page-surface.ts +180 -0
  41. package/core/build/ooui/semantic/kernel.types.ts +187 -0
  42. package/core/build/ooui/semantic/normalize.ts +784 -0
  43. package/core/build/ooui/semantic/origin.types.ts +211 -0
  44. package/core/build/ooui/semantic/role-alias.ts +154 -0
  45. package/core/build/ooui/semantic/shorthand.ts +233 -0
  46. package/core/build/ooui/semantic/surface.types.ts +78 -0
  47. package/core/build/ooui/semantic/validate-request.ts +267 -0
  48. package/core/build/ooui/spatial/emit-utility.ts +480 -0
  49. package/core/build/ooui/spatial/ir.types.ts +443 -0
  50. package/core/build/ooui/spatial/registry.ts +565 -0
  51. package/core/build/ooui/spatial/solve.ts +769 -0
  52. package/core/build/ooui/spatial/utility.types.ts +242 -0
  53. package/core/build/ooui/trace/index.ts +40 -0
  54. package/core/build/ooui/trace/render.ts +190 -0
  55. package/core/build/ooui/trace/source.types.ts +69 -0
  56. package/core/build/ooui/trace/trace.types.ts +326 -0
  57. package/core/client/component/component-expander.ts +18 -3
  58. package/core/client/component/component-manager.ts +4 -0
  59. package/core/client/component/example-blocks.ts +1 -7
  60. package/core/client/component/theme-component-tokens.ts +12 -15
  61. package/core/client/component/verify-pack.ts +43 -0
  62. package/core/client/data/data-object-resolver.ts +27 -8
  63. package/core/client/diagnostics/telemetry-context.ts +0 -4
  64. package/core/client/engine/asset-resolver.ts +0 -1
  65. package/core/client/engine/event-engine.ts +7 -3
  66. package/core/client/engine/soma-bootstrap.ts +292 -34
  67. package/core/client/engine/style-binder.ts +0 -1
  68. package/core/client/infra/http/IHttpClient.ts +0 -6
  69. package/core/client/infra/http/SomaHttpService.ts +4 -1
  70. package/core/client/infra/notify/DomNotifyService.ts +1 -1
  71. package/core/client/infra/router/router-path.ts +0 -6
  72. package/core/client/parser/annotation-extractor.ts +1 -1
  73. package/core/client/parser/blocks/namespace.ts +30 -5
  74. package/core/client/parser/blocks/page-parser.ts +44 -1
  75. package/core/client/parser/blocks/use-parser.ts +266 -46
  76. package/core/client/parser/data-config-parser.ts +71 -3
  77. package/core/client/parser/layout-parser.ts +4 -3
  78. package/core/client/parser/reaction-parser.ts +0 -1
  79. package/core/client/parser/ui-config-parser.ts +212 -74
  80. package/core/client/theme/scene-tokens.ts +9 -3
  81. package/core/client/theme/theme-axes.ts +74 -16
  82. package/core/client/theme/theme-engine.ts +341 -70
  83. package/core/client/theme/tone-solver.ts +9 -8
  84. package/core/index.ts +24 -5
  85. package/core/server/api/load-host-service.ts +8 -2
  86. package/core/server/declaration-safety.ts +11 -0
  87. package/core/server/host/page-response-request.ts +0 -2
  88. package/core/server/host/published-page-artifact-cache.ts +244 -0
  89. package/core/server/host/published-page-assets.ts +44 -5
  90. package/core/server/mock/node/cli.mjs +0 -1
  91. package/core/server/mock/node/schema-generator.mjs +0 -1
  92. package/core/server/ooui.ts +34 -0
  93. package/core/server/page-assets.ts +8 -0
  94. package/core/server/page-declaration.ts +18 -0
  95. package/core/server/registry/asset-store.ts +327 -0
  96. package/core/server/registry/declaration-precompiler.ts +49 -6
  97. package/core/server/registry/index.ts +47 -1
  98. package/core/server/registry/page-registry-repository.ts +6 -2
  99. package/core/server/registry/page-registry-store.ts +133 -19
  100. package/core/server/registry/publish-asset-pin.ts +557 -0
  101. package/core/server/registry/services/pages/List.ts +15 -3
  102. package/core/server/registry/validation/compile-gate.ts +180 -8
  103. package/core/server/registry/validation/declaration-safety-scan.ts +113 -23
  104. package/core/shared/component/derive-sample.ts +201 -16
  105. package/core/shared/component/field-lines.ts +98 -8
  106. package/core/shared/container-breakpoints.ts +46 -0
  107. package/core/shared/object-semantics.ts +240 -0
  108. package/core/shared/ooui-declaration.ts +235 -0
  109. package/core/shared/types/component-contract.types.ts +7 -6
  110. package/core/shared/types/data-config.types.ts +95 -0
  111. package/core/shared/types/domain.types.ts +0 -24
  112. package/core/shared/types/engine.types.ts +0 -5
  113. package/core/shared/types/layout-constraint.types.ts +16 -0
  114. package/core/shared/types/ui-config.types.ts +163 -13
  115. package/dist/cli/soma.js +24 -11
  116. package/dist/core/index.cjs +1829 -1028
  117. package/dist/types/build/blocks/block-compile.d.ts +16 -1
  118. package/dist/types/build/blocks/migrate-flat.d.ts +17 -0
  119. package/dist/types/build/compiler/page-declaration-compiler.d.ts +46 -0
  120. package/dist/types/build/compiler/route-builder.d.ts +0 -1
  121. package/dist/types/build/component/component-graph.d.ts +17 -53
  122. package/dist/types/build/component/package-loader.d.ts +8 -1
  123. package/dist/types/build/layout/constraint-solver.d.ts +46 -4
  124. package/dist/types/build/ooui/artifact/artifact.types.d.ts +180 -0
  125. package/dist/types/build/ooui/artifact/emit-artifact.d.ts +58 -0
  126. package/dist/types/build/ooui/artifact/emit-html.d.ts +53 -0
  127. package/dist/types/build/ooui/artifact/index.d.ts +5 -0
  128. package/dist/types/build/ooui/artifact/spatial-tree.d.ts +48 -0
  129. package/dist/types/build/ooui/artifact/utility-class.d.ts +46 -0
  130. package/dist/types/build/ooui/composition/candidate.types.d.ts +206 -0
  131. package/dist/types/build/ooui/composition/control-model.d.ts +37 -0
  132. package/dist/types/build/ooui/composition/registry.d.ts +66 -0
  133. package/dist/types/build/ooui/composition/select.d.ts +63 -0
  134. package/dist/types/build/ooui/diagnostics/codes.d.ts +28 -0
  135. package/dist/types/build/ooui/diagnostics/error.d.ts +135 -0
  136. package/dist/types/build/ooui/diagnostics/format.d.ts +51 -0
  137. package/dist/types/build/ooui/diagnostics/index.d.ts +25 -0
  138. package/dist/types/build/ooui/diagnostics/issue.types.d.ts +56 -0
  139. package/dist/types/build/ooui/engine-slot.d.ts +41 -0
  140. package/dist/types/build/ooui/index.d.ts +286 -0
  141. package/dist/types/build/ooui/intent/derive-intent.d.ts +32 -0
  142. package/dist/types/build/ooui/intent/field-rules.d.ts +99 -0
  143. package/dist/types/build/ooui/intent/intent.types.d.ts +318 -0
  144. package/dist/types/build/ooui/intent/verb-events.d.ts +70 -0
  145. package/dist/types/build/ooui/page/budget.d.ts +28 -0
  146. package/dist/types/build/ooui/page/compose-page.d.ts +41 -0
  147. package/dist/types/build/ooui/page/index.d.ts +4 -0
  148. package/dist/types/build/ooui/page/page.types.d.ts +264 -0
  149. package/dist/types/build/ooui/page/region-row.d.ts +16 -0
  150. package/dist/types/build/ooui/semantic/expand-page-surface.d.ts +33 -0
  151. package/dist/types/build/ooui/semantic/kernel.types.d.ts +125 -0
  152. package/dist/types/build/ooui/semantic/normalize.d.ts +45 -0
  153. package/dist/types/build/ooui/semantic/origin.types.d.ts +95 -0
  154. package/dist/types/build/ooui/semantic/role-alias.d.ts +35 -0
  155. package/dist/types/build/ooui/semantic/shorthand.d.ts +60 -0
  156. package/dist/types/build/ooui/semantic/surface.types.d.ts +16 -0
  157. package/dist/types/build/ooui/semantic/validate-request.d.ts +19 -0
  158. package/dist/types/build/ooui/spatial/emit-utility.d.ts +43 -0
  159. package/dist/types/build/ooui/spatial/ir.types.d.ts +280 -0
  160. package/dist/types/build/ooui/spatial/registry.d.ts +110 -0
  161. package/dist/types/build/ooui/spatial/solve.d.ts +42 -0
  162. package/dist/types/build/ooui/spatial/utility.types.d.ts +191 -0
  163. package/dist/types/build/ooui/trace/index.d.ts +3 -0
  164. package/dist/types/build/ooui/trace/render.d.ts +42 -0
  165. package/dist/types/build/ooui/trace/source.types.d.ts +25 -0
  166. package/dist/types/build/ooui/trace/trace.types.d.ts +143 -0
  167. package/dist/types/client/component/component-expander.d.ts +1 -0
  168. package/dist/types/client/component/example-blocks.d.ts +0 -2
  169. package/dist/types/client/component/theme-component-tokens.d.ts +8 -5
  170. package/dist/types/client/data/data-object-resolver.d.ts +10 -2
  171. package/dist/types/client/diagnostics/telemetry-context.d.ts +0 -1
  172. package/dist/types/client/engine/soma-bootstrap.d.ts +123 -10
  173. package/dist/types/client/infra/http/IHttpClient.d.ts +0 -5
  174. package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
  175. package/dist/types/client/infra/router/router-path.d.ts +0 -2
  176. package/dist/types/client/parser/blocks/namespace.d.ts +20 -0
  177. package/dist/types/client/parser/blocks/page-parser.d.ts +9 -0
  178. package/dist/types/client/parser/blocks/use-parser.d.ts +38 -4
  179. package/dist/types/client/parser/data-config-parser.d.ts +13 -0
  180. package/dist/types/client/parser/ui-config-parser.d.ts +1 -11
  181. package/dist/types/client/theme/scene-tokens.d.ts +9 -3
  182. package/dist/types/client/theme/theme-axes.d.ts +64 -1
  183. package/dist/types/client/theme/theme-engine.d.ts +13 -8
  184. package/dist/types/client/theme/tone-solver.d.ts +9 -5
  185. package/dist/types/index.d.ts +4 -6
  186. package/dist/types/server/declaration-safety.d.ts +7 -0
  187. package/dist/types/server/host/page-response-request.d.ts +0 -1
  188. package/dist/types/server/host/published-page-artifact-cache.d.ts +64 -0
  189. package/dist/types/server/ooui.d.ts +18 -0
  190. package/dist/types/server/page-assets.d.ts +7 -0
  191. package/dist/types/server/page-declaration.d.ts +14 -0
  192. package/dist/types/server/registry/asset-store.d.ts +112 -0
  193. package/dist/types/server/registry/declaration-precompiler.d.ts +23 -3
  194. package/dist/types/server/registry/index.d.ts +3 -1
  195. package/dist/types/server/registry/page-registry-store.d.ts +57 -4
  196. package/dist/types/server/registry/publish-asset-pin.d.ts +166 -0
  197. package/dist/types/server/registry/services/pages/List.d.ts +9 -3
  198. package/dist/types/server/registry/validation/compile-gate.d.ts +63 -0
  199. package/dist/types/shared/component/derive-sample.d.ts +14 -0
  200. package/dist/types/shared/container-breakpoints.d.ts +42 -0
  201. package/dist/types/shared/object-semantics.d.ts +42 -0
  202. package/dist/types/shared/ooui-declaration.d.ts +135 -0
  203. package/dist/types/shared/types/component-contract.types.d.ts +7 -6
  204. package/dist/types/shared/types/data-config.types.d.ts +86 -0
  205. package/dist/types/shared/types/domain.types.d.ts +0 -21
  206. package/dist/types/shared/types/engine.types.d.ts +0 -4
  207. package/dist/types/shared/types/layout-constraint.types.d.ts +1 -0
  208. package/dist/types/shared/types/ui-config.types.d.ts +157 -12
  209. package/next.config.js +106 -13
  210. package/package.json +29 -2
  211. package/core/client/host-bridge/index.ts +0 -27
  212. package/core/client/parser/yaml-loader.ts +0 -36
  213. package/core/shared/manifest/manifest-contract.ts +0 -12
  214. package/dist/types/client/host-bridge/index.d.ts +0 -9
  215. package/dist/types/client/parser/yaml-loader.d.ts +0 -21
  216. package/dist/types/shared/manifest/manifest-contract.d.ts +0 -4
@@ -3100,6 +3100,82 @@ var {
3100
3100
  safeDump
3101
3101
  } = yaml;
3102
3102
 
3103
+ // core/shared/types/layout-constraint.types.ts
3104
+ var SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1e3];
3105
+ var SIZING_SET = {
3106
+ fixed: true,
3107
+ hug: true,
3108
+ fill: true
3109
+ };
3110
+ var SOMA_LAYOUT_SIZINGS = Object.keys(SIZING_SET);
3111
+ var SOMA_LAYOUT_ALIGNS = [
3112
+ "start",
3113
+ "center",
3114
+ "end",
3115
+ "baseline",
3116
+ "space_between",
3117
+ "space_evenly",
3118
+ "space_around"
3119
+ ];
3120
+
3121
+ // core/shared/ooui-declaration.ts
3122
+ var SOMA_OOUI_ANCHOR_PATTERN = /^[A-Za-z_][A-Za-z0-9_-]*$/;
3123
+ var SOMA_OOUI_ANCHOR_GRAMMAR = "\u5B57\u6BCD\u6216\u4E0B\u5212\u7EBF\u5F00\u5934\uFF0C\u5176\u4F59\u53EF\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u4E0E _";
3124
+ var REQUEST_KEY_SET = {
3125
+ object: true,
3126
+ verb: true,
3127
+ focus: true,
3128
+ through: true,
3129
+ form: true,
3130
+ bound_to: true,
3131
+ layout: true
3132
+ };
3133
+ var SOMA_OOUI_REQUEST_KEYS = Object.keys(REQUEST_KEY_SET);
3134
+ var LAYOUT_VALUE_TYPES = {
3135
+ sizing: "string",
3136
+ width: "string",
3137
+ min: "string",
3138
+ max: "string",
3139
+ priority: "number"
3140
+ };
3141
+ var SOMA_OOUI_LAYOUT_KEYS = Object.keys(LAYOUT_VALUE_TYPES);
3142
+ var SOMA_OOUI_SIZINGS = SOMA_LAYOUT_SIZINGS;
3143
+ function isOouiSizing(value) {
3144
+ return typeof value === "string" && SOMA_OOUI_SIZINGS.includes(value);
3145
+ }
3146
+ function isOouiMap(value) {
3147
+ return value !== null && typeof value === "object" && !Array.isArray(value);
3148
+ }
3149
+ function isOouiText(value) {
3150
+ return typeof value === "string" && value.trim() !== "";
3151
+ }
3152
+ function isOouiFocus(value) {
3153
+ return Array.isArray(value) && value.length > 0 && value.every((item) => isOouiText(item));
3154
+ }
3155
+ var BINDING_KEY_SET = {
3156
+ region: true,
3157
+ as: true
3158
+ };
3159
+ var SOMA_OOUI_BINDING_KEYS = Object.keys(BINDING_KEY_SET);
3160
+ function findOouiBindingUnknownKey(binding) {
3161
+ return Object.keys(binding).find((key) => !SOMA_OOUI_BINDING_KEYS.includes(key));
3162
+ }
3163
+ function isOouiBinding(value) {
3164
+ return isOouiMap(value) && findOouiBindingUnknownKey(value) === void 0 && isOouiText(value.region) && isOouiText(value.as);
3165
+ }
3166
+ function findOouiLayoutProblem(layout) {
3167
+ for (const [key, value] of Object.entries(layout)) {
3168
+ if (!SOMA_OOUI_LAYOUT_KEYS.includes(key)) return { key, kind: "unknown-key" };
3169
+ const expected = LAYOUT_VALUE_TYPES[key];
3170
+ if (typeof value !== expected) return { key, kind: "value-type", expected };
3171
+ if (key === "sizing" && !isOouiSizing(value)) return { key, kind: "sizing-unknown" };
3172
+ }
3173
+ return void 0;
3174
+ }
3175
+ function isOouiLayout(value) {
3176
+ return isOouiMap(value) && findOouiLayoutProblem(value) === void 0;
3177
+ }
3178
+
3103
3179
  // core/shared/types/adaptive.types.ts
3104
3180
  var SOMA_ADAPTIVE_PROFILES = ["dashboard", "form", "list", "console"];
3105
3181
  var SOMA_ADAPTIVE_MAX_LADDER = 5;
@@ -3335,20 +3411,7 @@ function parseStateValue(raw, path, config, fail) {
3335
3411
  return state;
3336
3412
  }
3337
3413
 
3338
- // core/shared/types/layout-constraint.types.ts
3339
- var SOMA_LAYOUT_PRIORITIES = [250, 500, 750, 1e3];
3340
- var SOMA_LAYOUT_ALIGNS = [
3341
- "start",
3342
- "center",
3343
- "end",
3344
- "baseline",
3345
- "space_between",
3346
- "space_evenly",
3347
- "space_around"
3348
- ];
3349
-
3350
3414
  // core/client/parser/layout-parser.ts
3351
- var SIZINGS = /* @__PURE__ */ new Set(["fixed", "hug", "fill"]);
3352
3415
  var WRAPS = /* @__PURE__ */ new Set(["none", "below", "reel"]);
3353
3416
  var NODE_KEYS = /* @__PURE__ */ new Set(["sizing", "width", "min", "max", "priority"]);
3354
3417
  var SECTION_KEYS = /* @__PURE__ */ new Set(["gap", "wrap", "align", "container_name", "nodes"]);
@@ -3385,9 +3448,9 @@ function parseLayoutConstraint(input, deps) {
3385
3448
  }
3386
3449
  }
3387
3450
  const sizing = String(rawNode.sizing ?? "");
3388
- if (!SIZINGS.has(sizing)) {
3451
+ if (!SOMA_LAYOUT_SIZINGS.includes(sizing)) {
3389
3452
  fail(
3390
- `${at}.sizing \u53EA\u80FD\u662F ${[...SIZINGS].join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(rawNode.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"`,
3453
+ `${at}.sizing \u53EA\u80FD\u662F ${SOMA_LAYOUT_SIZINGS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(rawNode.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"`,
3391
3454
  `${at}.sizing`
3392
3455
  );
3393
3456
  }
@@ -3703,8 +3766,148 @@ function parseUiConfig(raw, options) {
3703
3766
  }
3704
3767
  config.layoutCss = raw.layout_css;
3705
3768
  }
3769
+ if ("ooui" in raw && raw.ooui !== void 0) {
3770
+ config.ooui = parseOouiSection(raw.ooui);
3771
+ }
3772
+ if ("ooui_artifact" in raw && raw.ooui_artifact !== void 0) {
3773
+ config.oouiArtifact = parseOouiArtifact(raw.ooui_artifact);
3774
+ }
3706
3775
  return config;
3707
3776
  }
3777
+ var OOUI_CSS_KEY_PATTERN = /^ooui:[0-9a-f]{8}$/;
3778
+ function parseOouiSection(raw) {
3779
+ if (!isOouiMap(raw)) {
3780
+ throw new SomaUiConfigError(
3781
+ "ooui \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { object: <data \u5BF9\u8C61\u540D>, verb: <\u52A8\u8BCD> } }",
3782
+ "ooui"
3783
+ );
3784
+ }
3785
+ const out = {};
3786
+ for (const [anchor, spec] of Object.entries(raw)) {
3787
+ const path = `ooui.${anchor}`;
3788
+ if (!SOMA_OOUI_ANCHOR_PATTERN.test(anchor)) {
3789
+ throw new SomaUiConfigError(
3790
+ `ooui \u7684\u952E\u5FC5\u987B\u662F\u951A\u70B9 id\uFF08data-soma-id\uFF0C${SOMA_OOUI_ANCHOR_GRAMMAR}\uFF09\uFF0C\u6536\u5230 "${anchor}"`,
3791
+ path
3792
+ );
3793
+ }
3794
+ if (!isOouiMap(spec)) {
3795
+ throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u5FC5\u987B\u662F\u6620\u5C04\uFF08\u81F3\u5C11\u542B object \u4E0E verb\uFF09", path);
3796
+ }
3797
+ for (const key of Object.keys(spec)) {
3798
+ if (!SOMA_OOUI_REQUEST_KEYS.includes(key)) {
3799
+ throw new SomaUiConfigError(
3800
+ `\u6F14\u7ECE\u8BF7\u6C42\u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_REQUEST_KEYS.join(" / ")}\uFF09`,
3801
+ `${path}.${key}`
3802
+ );
3803
+ }
3804
+ }
3805
+ const { object, verb, focus, through, form, bound_to: bound, layout } = spec;
3806
+ if (!isOouiText(object)) {
3807
+ throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u7F3A\u5C11 object\uFF08\u9875\u9762 data: \u6BB5\u91CC\u7684\u5BF9\u8C61\u540D\uFF09", `${path}.object`);
3808
+ }
3809
+ if (!isOouiText(verb)) {
3810
+ throw new SomaUiConfigError("\u6F14\u7ECE\u8BF7\u6C42\u7F3A\u5C11 verb\uFF08\u516B\u52A8\u8BCD\u4E4B\u4E00\uFF09", `${path}.verb`);
3811
+ }
3812
+ const declaration = { object, verb };
3813
+ if (focus !== void 0) {
3814
+ if (!isOouiFocus(focus)) {
3815
+ throw new SomaUiConfigError("focus \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\u6570\u7EC4\uFF08\u7701\u7565\u5B83\u624D\u8868\u793A\u5168\u90E8\u5B57\u6BB5\uFF09", `${path}.focus`);
3816
+ }
3817
+ declaration.focus = [...focus];
3818
+ }
3819
+ if (through !== void 0) {
3820
+ if (!isOouiText(through)) {
3821
+ throw new SomaUiConfigError("through \u5FC5\u987B\u662F\u5BF9\u8C61 relations \u91CC\u7684\u5173\u7CFB\u540D", `${path}.through`);
3822
+ }
3823
+ declaration.through = through;
3824
+ }
3825
+ if (form !== void 0) {
3826
+ if (!isOouiText(form)) {
3827
+ throw new SomaUiConfigError("form \u5FC5\u987B\u662F\u5F62\u6001\u540D\uFF08\u9003\u751F\u95E8\uFF0C\u7701\u7565\u5219\u7531\u52A8\u8BCD\u5206\u6D3E\uFF09", `${path}.form`);
3828
+ }
3829
+ declaration.form = form;
3830
+ }
3831
+ if (bound !== void 0) {
3832
+ const unknownKey = isOouiMap(bound) ? findOouiBindingUnknownKey(bound) : void 0;
3833
+ if (unknownKey !== void 0) {
3834
+ throw new SomaUiConfigError(
3835
+ `bound_to \u4E0D\u652F\u6301\u952E "${unknownKey}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_BINDING_KEYS.join(" / ")}\uFF09\u2014\u2014\u8054\u52A8\u53EA\u8BA4\u6E90\u533A\u57DF\u4E0E\u8BED\u4E49\u4E8B\u4EF6\u4E24\u9879\uFF0C\u591A\u5199\u7684\u952E\u4E0D\u4F1A\u88AB\u4EFB\u4F55\u4E00\u5C42\u8BFB\u5230`,
3836
+ `${path}.bound_to.${unknownKey}`
3837
+ );
3838
+ }
3839
+ if (!isOouiBinding(bound)) {
3840
+ throw new SomaUiConfigError(
3841
+ "bound_to \u5FC5\u987B\u662F { region, as } \u4E24\u9879\u4FF1\u5168\u7684\u6620\u5C04\uFF08region \u662F\u53E6\u4E00\u4E2A\u951A\u70B9\u540D\uFF0Cas \u662F\u8BED\u4E49\u4E8B\u4EF6\u540D\uFF09",
3842
+ `${path}.bound_to`
3843
+ );
3844
+ }
3845
+ declaration.bound_to = { region: bound.region, as: bound.as };
3846
+ }
3847
+ if (layout !== void 0) {
3848
+ if (!isOouiLayout(layout)) {
3849
+ const problem = isOouiMap(layout) ? findOouiLayoutProblem(layout) : void 0;
3850
+ throw new SomaUiConfigError(
3851
+ oouiLayoutProblemMessage(layout, problem),
3852
+ problem === void 0 ? `${path}.layout` : `${path}.layout.${problem.key}`
3853
+ );
3854
+ }
3855
+ declaration.layout = layout;
3856
+ }
3857
+ out[anchor] = declaration;
3858
+ }
3859
+ return out;
3860
+ }
3861
+ function oouiLayoutProblemMessage(layout, problem) {
3862
+ if (problem === void 0) return `layout \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u53EF\u7528\u952E\uFF1A${SOMA_OOUI_LAYOUT_KEYS.join(" / ")}\uFF09`;
3863
+ if (problem.kind === "unknown-key") {
3864
+ return `layout \u4E0D\u652F\u6301\u952E "${problem.key}"\uFF08\u53EF\u7528\uFF1A${SOMA_OOUI_LAYOUT_KEYS.join(" / ")}\uFF09`;
3865
+ }
3866
+ if (problem.kind === "sizing-unknown") {
3867
+ return `layout.sizing \u53EA\u80FD\u662F ${SOMA_OOUI_SIZINGS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(layout.sizing)}\uFF09\u2014\u2014fixed \u662F"\u5C31\u8FD9\u4E48\u5BBD"\uFF0Chug \u662F"\u5185\u5BB9\u591A\u5BBD\u6211\u591A\u5BBD"\uFF0Cfill \u662F"\u5269\u4E0B\u7684\u7ED9\u6211"\uFF1B\u7701\u7565\u5373 fill`;
3868
+ }
3869
+ return `layout.${problem.key} \u5FC5\u987B\u662F ${problem.expected === "number" ? "\u6570\u5B57" : "\u5B57\u7B26\u4E32"}`;
3870
+ }
3871
+ function parseOouiArtifact(raw) {
3872
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
3873
+ throw new SomaUiConfigError("ooui_artifact \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u6784\u5EFA\u671F\u6F14\u7ECE\u4EA7\u7269\uFF0C\u4E0D\u624B\u5199\uFF09", "ooui_artifact");
3874
+ }
3875
+ const entry = raw;
3876
+ if (entry.version !== 1) {
3877
+ throw new SomaUiConfigError(
3878
+ `ooui_artifact.version \u5FC5\u987B\u662F 1\uFF0C\u6536\u5230 ${JSON.stringify(entry.version)}\u2014\u2014\u7248\u672C\u5BF9\u4E0D\u4E0A\u7684\u4EA7\u7269\u6574\u4EFD\u4E0D\u53EF\u4FE1\uFF0C\u6309\u65E7\u5B57\u6BB5\u540D\u8BFB\u51FA\u6765\u7684\u754C\u9762\u662F\u8C01\u90FD\u6CA1\u8BBE\u8BA1\u8FC7\u7684\u6837\u5B50`,
3879
+ "ooui_artifact.version"
3880
+ );
3881
+ }
3882
+ if (!Array.isArray(entry.regions)) {
3883
+ throw new SomaUiConfigError("ooui_artifact.regions \u5FC5\u987B\u662F\u6570\u7EC4", "ooui_artifact.regions");
3884
+ }
3885
+ for (const [index, region] of entry.regions.entries()) {
3886
+ if (!region || typeof region !== "object" || Array.isArray(region) || typeof region.anchor !== "string") {
3887
+ throw new SomaUiConfigError("\u6BCF\u4E2A region \u5FC5\u987B\u662F\u6620\u5C04\u4E14\u5E26 anchor\uFF08\u951A\u70B9 id\uFF09", `ooui_artifact.regions[${index}]`);
3888
+ }
3889
+ }
3890
+ const artifact = {
3891
+ version: 1,
3892
+ regions: entry.regions
3893
+ };
3894
+ const hasCss = typeof entry.css === "string" && entry.css.trim() !== "";
3895
+ if (entry.css !== void 0 && typeof entry.css !== "string") {
3896
+ throw new SomaUiConfigError("ooui_artifact.css \u5FC5\u987B\u662F\u5B57\u7B26\u4E32", "ooui_artifact.css");
3897
+ }
3898
+ if (hasCss) {
3899
+ const key = entry.css_key;
3900
+ if (typeof key !== "string" || !OOUI_CSS_KEY_PATTERN.test(key)) {
3901
+ throw new SomaUiConfigError(
3902
+ `ooui_artifact.css \u5B58\u5728\u65F6\u5FC5\u987B\u5E26\u5185\u5BB9\u54C8\u5E0C\u952E css_key\uFF08\u5F62\u5982 ooui:0a1b2c3d\uFF09\uFF0C\u6536\u5230 ${JSON.stringify(key)}\u2014\u2014\u6837\u5F0F\u6CE8\u5165\u6CA1\u6709\u5185\u5BB9\u51B2\u7A81\u68C0\u6D4B\uFF0C\u8BED\u4E49\u540D\u4F1A\u8BA9 SPA \u8DEF\u7531\u5207\u9875\u65F6\u9759\u9ED8\u6CBF\u7528\u4E0A\u4E00\u9875\u7684 CSS`,
3903
+ "ooui_artifact.css_key"
3904
+ );
3905
+ }
3906
+ artifact.css = entry.css;
3907
+ artifact.css_key = key;
3908
+ }
3909
+ return artifact;
3910
+ }
3708
3911
  function parseLayoutSection(raw) {
3709
3912
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
3710
3913
  throw new SomaUiConfigError("layout \u5FC5\u987B\u662F\u6620\u5C04\uFF1A{ <\u951A\u70B9id>: { gap, wrap, <\u5B50\u9879>: { sizing, \u2026 } } }", "layout");
@@ -5035,6 +5238,152 @@ var SOMA_DATA_FIELD_TYPES = [
5035
5238
  "cascade",
5036
5239
  ...Object.keys(SOMA_DATA_FIELD_TYPE_ALIASES)
5037
5240
  ];
5241
+ var SOMA_DATA_OBJECT_ROLES = [
5242
+ "id",
5243
+ "title",
5244
+ "subtitle",
5245
+ "status",
5246
+ "timestamp",
5247
+ "amount",
5248
+ "baseline"
5249
+ ];
5250
+ var SOMA_DATA_RELATION_CARDINALITIES = [
5251
+ "one",
5252
+ "many"
5253
+ ];
5254
+
5255
+ // core/shared/object-semantics.ts
5256
+ var IDENTIFIER = /^[a-zA-Z_]\w*$/;
5257
+ var RELATION_KEYS = ["name", "to", "cardinality", "via"];
5258
+ function isPlainObject4(value) {
5259
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5260
+ }
5261
+ function fieldList(fieldKeys) {
5262
+ return fieldKeys.length > 0 ? fieldKeys.join(" / ") : "\uFF08\u7A7A\uFF09";
5263
+ }
5264
+ function validateObjectRoles(raw, fieldKeys) {
5265
+ if (raw === void 0 || raw === null) return [];
5266
+ if (!isPlainObject4(raw)) {
5267
+ return ["roles \u5FC5\u987B\u662F\u6620\u5C04\uFF08\u89D2\u8272\u540D \u2192 \u5B57\u6BB5\u540D\uFF09\uFF0C\u5982 `roles: { title: no, status: state }`"];
5268
+ }
5269
+ const entries = Object.entries(raw);
5270
+ if (entries.length === 0) {
5271
+ return ["roles \u662F\u7A7A\u6620\u5C04\u2014\u2014\u4E0D\u58F0\u660E\u4E0E\u58F0\u660E\u6210\u7A7A\u662F\u4E24\u56DE\u4E8B\uFF0C\u5220\u6389\u6574\u6BB5\u6216\u81F3\u5C11\u7ED9\u4E00\u4E2A\u89D2\u8272"];
5272
+ }
5273
+ if (fieldKeys.length === 0) {
5274
+ return [
5275
+ "roles \u7684\u503C\u662F\u5B57\u6BB5\u540D\uFF0C\u4F46\u672C\u5BF9\u8C61\u6CA1\u6709\u58F0\u660E fields\uFF0C\u4EFB\u4F55\u89D2\u8272\u90FD\u65E0\u4ECE\u5BF9\u8D26\u2014\u2014\u8BF7\u5148\u8865 `fields:` \u5B57\u6BB5\u5B57\u5178\uFF0C\u518D\u58F0\u660E roles"
5276
+ ];
5277
+ }
5278
+ const issues = [];
5279
+ const known = SOMA_DATA_OBJECT_ROLES;
5280
+ for (const [role, target] of entries) {
5281
+ if (!known.includes(role)) {
5282
+ issues.push(
5283
+ `\u672A\u77E5\u7684\u89D2\u8272 "${role}"\uFF08\u5C01\u95ED\u96C6\uFF1A${known.join(" / ")}\uFF09\u2014\u2014\u89D2\u8272\u8868\u662F\u5C01\u95ED\u96C6\uFF0C\u52A0\u4E00\u4E2A\u89D2\u8272\u662F\u4E00\u6B21\u4F53\u7CFB\u51B3\u7B56\uFF0C\u4E0D\u5728\u58F0\u660E\u91CC\u4E34\u65F6\u6269`
5284
+ );
5285
+ continue;
5286
+ }
5287
+ if (typeof target !== "string" || target.trim() === "") {
5288
+ issues.push(`\u89D2\u8272 "${role}" \u7684\u503C\u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(target)}`);
5289
+ continue;
5290
+ }
5291
+ if (!fieldKeys.includes(target)) {
5292
+ issues.push(
5293
+ `\u89D2\u8272 "${role}" \u6307\u5411\u5B57\u6BB5 "${target}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(fieldKeys)}\uFF09\u2014\u2014\u6307\u9519\u7684\u540E\u679C\u662F\u90A3\u4E00\u4F4D\u9759\u9ED8\u7559\u7A7A\uFF0C\u9875\u9762\u7167\u5E38\u6E32\u67D3`
5294
+ );
5295
+ }
5296
+ }
5297
+ return issues;
5298
+ }
5299
+ function validateObjectRelations(raw, ctx) {
5300
+ if (raw === void 0 || raw === null) return [];
5301
+ if (!Array.isArray(raw)) {
5302
+ return [
5303
+ "relations \u5FC5\u987B\u662F\u6570\u7EC4\uFF0C\u5982 `relations: [{ name: items, to: order_item, cardinality: many, via: order_no }]`"
5304
+ ];
5305
+ }
5306
+ if (raw.length === 0) {
5307
+ return ["relations \u662F\u7A7A\u6570\u7EC4\u2014\u2014\u4E0D\u58F0\u660E\u4E0E\u58F0\u660E\u6210\u7A7A\u662F\u4E24\u56DE\u4E8B\uFF0C\u5220\u6389\u6574\u6BB5\u6216\u81F3\u5C11\u7ED9\u4E00\u6761\u5173\u7CFB"];
5308
+ }
5309
+ const issues = [];
5310
+ const seen = /* @__PURE__ */ new Set();
5311
+ const cardinalities = SOMA_DATA_RELATION_CARDINALITIES;
5312
+ raw.forEach((entry, index) => {
5313
+ const at = `relations[${index}]`;
5314
+ if (!isPlainObject4(entry)) {
5315
+ issues.push(`${at} \u5FC5\u987B\u662F\u5BF9\u8C61\uFF08name / to / cardinality / via\uFF09`);
5316
+ return;
5317
+ }
5318
+ for (const key of Object.keys(entry)) {
5319
+ if (!RELATION_KEYS.includes(key)) {
5320
+ issues.push(`${at} \u4E0D\u652F\u6301\u952E "${key}"\uFF08\u53EF\u7528\uFF1A${RELATION_KEYS.join(" / ")}\uFF09`);
5321
+ }
5322
+ }
5323
+ const { name, to, cardinality, via } = entry;
5324
+ if (typeof name !== "string" || !IDENTIFIER.test(name)) {
5325
+ issues.push(`${at}.name \u5FC5\u987B\u662F\u6807\u8BC6\u7B26\uFF08\u5B57\u6BCD/\u4E0B\u5212\u7EBF\u5F00\u5934\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(name)}`);
5326
+ } else if (seen.has(name)) {
5327
+ issues.push(
5328
+ `${at}.name "${name}" \u4E0E\u524D\u9762\u7684\u5173\u7CFB\u91CD\u540D\u2014\u2014\`through\` \u6309\u540D\u5B57\u5F15\u7528\u5173\u7CFB\uFF0C\u91CD\u540D\u7B49\u4E8E\u8BA9\u5B83\u6307\u5411\u4E24\u4E2A\u5730\u65B9`
5329
+ );
5330
+ } else {
5331
+ seen.add(name);
5332
+ }
5333
+ if (typeof to !== "string" || !IDENTIFIER.test(to)) {
5334
+ issues.push(`${at}.to \u5FC5\u987B\u662F\u6570\u636E\u5BF9\u8C61\u540D\uFF08\u6807\u8BC6\u7B26\uFF09\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(to)}`);
5335
+ } else if (ctx.objectNames !== void 0 && !ctx.objectNames.includes(to)) {
5336
+ issues.push(
5337
+ `${at}.to \u6307\u5411\u672A\u58F0\u660E\u7684\u6570\u636E\u5BF9\u8C61 "${to}"\uFF08\u672C\u6B21\u58F0\u660E\u91CC\u6709\uFF1A${ctx.objectNames.length > 0 ? ctx.objectNames.join(" / ") : "\uFF08\u7A7A\uFF09"}\uFF09\u2014\u2014\u628A\u76EE\u6807\u5BF9\u8C61\u4E5F\u58F0\u660E\u8FDB data\uFF0C\u6216\u5220\u6389\u8FD9\u6761\u5173\u7CFB\uFF1B\u7559\u7740\u5B83\u4F1A\u8BA9 navigate / compare \u53D6\u4E0D\u5230\u76EE\u6807\u5B57\u5178\uFF0C\u6F14\u7ECE\u51FA\u4E00\u7247\u7A7A\u767D\u800C\u4E0D\u662F\u62A5\u9519`
5338
+ );
5339
+ }
5340
+ if (typeof cardinality !== "string" || !cardinalities.includes(cardinality)) {
5341
+ issues.push(
5342
+ `${at}.cardinality \u5FC5\u987B\u662F ${cardinalities.join(" / ")}\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(cardinality)}\u2014\u2014\u57FA\u6570\u51B3\u5B9A\u7684\u662F"\u6F14\u7ECE\u6210\u4E00\u683C\u8FD8\u662F\u4E00\u5217"\uFF0C\u731C\u4E0D\u5F97`
5343
+ );
5344
+ }
5345
+ if (via !== void 0) {
5346
+ if (typeof via !== "string" || via.trim() === "") {
5347
+ issues.push(`${at}.via \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(via)}`);
5348
+ } else if (!ctx.fieldKeys.includes(via)) {
5349
+ issues.push(
5350
+ `${at}.via \u6307\u5411\u5B57\u6BB5 "${via}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(ctx.fieldKeys)}\uFF09`
5351
+ );
5352
+ }
5353
+ }
5354
+ });
5355
+ return issues;
5356
+ }
5357
+ function validateFieldModifies(fields) {
5358
+ const issues = [];
5359
+ const keys = Object.keys(fields);
5360
+ for (const key of keys) {
5361
+ const target = fields[key]?.modifies;
5362
+ if (target === void 0) continue;
5363
+ if (typeof target !== "string" || target.trim() === "") {
5364
+ issues.push(`\u5B57\u6BB5 "${key}" \u7684 modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D\uFF0C\u5F53\u524D\u503C: ${JSON.stringify(target)}`);
5365
+ continue;
5366
+ }
5367
+ if (target === key) {
5368
+ issues.push(
5369
+ `\u5B57\u6BB5 "${key}" \u7684 modifies \u6307\u5411\u5B83\u81EA\u5DF1\u2014\u2014\u4FEE\u9970\u5173\u7CFB\u8BF4\u7684\u662F"\u6211\u662F\u522B\u4EBA\u7684\u8BED\u6C14/\u5355\u4F4D/\u56FE\u6807"\uFF0C\u81EA\u6307\u6CA1\u6709\u53EF\u6267\u884C\u542B\u4E49`
5370
+ );
5371
+ continue;
5372
+ }
5373
+ if (!(target in fields)) {
5374
+ issues.push(
5375
+ `\u5B57\u6BB5 "${key}" \u7684 modifies \u6307\u5411 "${target}"\uFF0C\u4F46\u5B57\u5178\u91CC\u6CA1\u6709\u5B83\uFF08\u672C\u5BF9\u8C61\u5B57\u5178\uFF1A${fieldList(keys)}\uFF09\u2014\u2014\u6307\u9519\u5219\u672C\u5B57\u6BB5\u4E0D\u4F1A\u88AB\u5E76\u5165\u88AB\u4FEE\u9970\u8005\uFF0C\u800C\u662F\u81EA\u5DF1\u5360\u4E00\u683C\uFF0C\u9875\u9762\u4E0A\u591A\u51FA\u4E00\u884C\u7A7A\u503C`
5376
+ );
5377
+ continue;
5378
+ }
5379
+ if (fields[target].modifies !== void 0) {
5380
+ issues.push(
5381
+ `\u5B57\u6BB5 "${key}" \u4FEE\u9970 "${target}"\uFF0C\u800C "${target}" \u81EA\u5DF1\u4E5F\u5E26 modifies\u2014\u2014\u4FEE\u9970\u4E0D\u53EF\u7EA7\u8054\uFF08\u8BF7\u8BA9 "${key}" \u76F4\u63A5\u6307\u5411\u6700\u7EC8\u88AB\u4FEE\u9970\u7684\u90A3\u4E2A\u5B57\u6BB5\uFF09`
5382
+ );
5383
+ }
5384
+ }
5385
+ return issues;
5386
+ }
5038
5387
 
5039
5388
  // core/shared/types/reaction.types.ts
5040
5389
  var SOMA_REACTION_PHASES = [
@@ -5880,13 +6229,13 @@ var CONFIG_KEYS3 = /* @__PURE__ */ new Set([
5880
6229
  ]);
5881
6230
  var NUMERIC_TYPES = /* @__PURE__ */ new Set(["int", "float", "money", "percent", "progress"]);
5882
6231
  var DEFAULT_BLOCK = { size: 100, max_blocks: 10, debounce_ms: 120 };
5883
- function isPlainObject4(value) {
6232
+ function isPlainObject5(value) {
5884
6233
  return value !== null && typeof value === "object" && !Array.isArray(value);
5885
6234
  }
5886
6235
  function parseWindow(input, deps) {
5887
6236
  const { raw, fields, path } = input;
5888
6237
  const fail = deps.fail;
5889
- if (!isPlainObject4(raw)) fail("window \u5FC5\u987B\u662F\u6620\u5C04", path);
6238
+ if (!isPlainObject5(raw)) fail("window \u5FC5\u987B\u662F\u6620\u5C04", path);
5890
6239
  const section = raw;
5891
6240
  for (const key of Object.keys(section)) {
5892
6241
  if (!CONFIG_KEYS3.has(key)) {
@@ -5912,7 +6261,7 @@ function parseWindow(input, deps) {
5912
6261
  if (depth > MAX_FILTER_DEPTH) {
5913
6262
  fail(`${at} \u7684\u8FC7\u6EE4\u6761\u4EF6\u5D4C\u5957\u8D85\u8FC7 ${MAX_FILTER_DEPTH} \u5C42\u2014\u2014\u518D\u6DF1\u5C31\u6CA1\u4EBA\u8BFB\u5F97\u61C2\u4E86`, at);
5914
6263
  }
5915
- if (!isPlainObject4(node)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
6264
+ if (!isPlainObject5(node)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
5916
6265
  if ("join" in node || "conditions" in node) {
5917
6266
  const branch = node;
5918
6267
  const join = String(branch.join ?? "");
@@ -5944,7 +6293,7 @@ function parseWindow(input, deps) {
5944
6293
  if (!Array.isArray(section.sort)) fail(`${path}.sort \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.sort`);
5945
6294
  section.sort.forEach((entry, index) => {
5946
6295
  const at = `${path}.sort[${index}]`;
5947
- if (!isPlainObject4(entry)) fail(`${at} \u5FC5\u987B\u662F { field, order }`, at);
6296
+ if (!isPlainObject5(entry)) fail(`${at} \u5FC5\u987B\u662F { field, order }`, at);
5948
6297
  const order = String(entry.order ?? "asc");
5949
6298
  if (order !== "asc" && order !== "desc") {
5950
6299
  fail(`${at}.order \u53EA\u80FD\u662F asc / desc\uFF08\u6536\u5230 ${JSON.stringify(entry.order)}\uFF09`, `${at}.order`);
@@ -5955,7 +6304,7 @@ function parseWindow(input, deps) {
5955
6304
  let group = null;
5956
6305
  if (section.group !== void 0 && section.group !== null) {
5957
6306
  const at = `${path}.group`;
5958
- if (!isPlainObject4(section.group)) fail(`${at} \u5FC5\u987B\u662F { by, keys? }`, at);
6307
+ if (!isPlainObject5(section.group)) fail(`${at} \u5FC5\u987B\u662F { by, keys? }`, at);
5959
6308
  const by = section.group.by;
5960
6309
  if (!Array.isArray(by) || by.length === 0) fail(`${at}.by \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4`, `${at}.by`);
5961
6310
  const keys = section.group.keys ?? [];
@@ -5976,7 +6325,7 @@ function parseWindow(input, deps) {
5976
6325
  if (!Array.isArray(section.aggregate)) fail(`${path}.aggregate \u5FC5\u987B\u662F\u6570\u7EC4`, `${path}.aggregate`);
5977
6326
  section.aggregate.forEach((entry, index) => {
5978
6327
  const at = `${path}.aggregate[${index}]`;
5979
- if (!isPlainObject4(entry)) fail(`${at} \u5FC5\u987B\u662F { field, fn }`, at);
6328
+ if (!isPlainObject5(entry)) fail(`${at} \u5FC5\u987B\u662F { field, fn }`, at);
5980
6329
  const fn = String(entry.fn ?? "");
5981
6330
  if (!SOMA_AGGREGATE_FNS.includes(fn)) {
5982
6331
  fail(`${at}.fn \u53EA\u80FD\u662F ${SOMA_AGGREGATE_FNS.join(" / ")}\uFF08\u6536\u5230 ${JSON.stringify(entry.fn)}\uFF09`, `${at}.fn`);
@@ -5995,7 +6344,7 @@ function parseWindow(input, deps) {
5995
6344
  let selection = { base: "none", toggled: [] };
5996
6345
  if (section.selection !== void 0) {
5997
6346
  const at = `${path}.selection`;
5998
- if (!isPlainObject4(section.selection)) fail(`${at} \u5FC5\u987B\u662F { base, toggled }`, at);
6347
+ if (!isPlainObject5(section.selection)) fail(`${at} \u5FC5\u987B\u662F { base, toggled }`, at);
5999
6348
  const base = String(section.selection.base ?? "none");
6000
6349
  if (base !== "none" && base !== "all") {
6001
6350
  fail(`${at}.base \u53EA\u80FD\u662F none / all\uFF08\u6536\u5230 ${JSON.stringify(section.selection.base)}\uFF09`, `${at}.base`);
@@ -6020,7 +6369,7 @@ function parseWindow(input, deps) {
6020
6369
  const block = { ...DEFAULT_BLOCK };
6021
6370
  if (section.block !== void 0) {
6022
6371
  const at = `${path}.block`;
6023
- if (!isPlainObject4(section.block)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
6372
+ if (!isPlainObject5(section.block)) fail(`${at} \u5FC5\u987B\u662F\u6620\u5C04`, at);
6024
6373
  const positive = (raw2, key, fallback) => {
6025
6374
  if (raw2 === void 0) return fallback;
6026
6375
  const value = Number(raw2);
@@ -6036,7 +6385,7 @@ function parseWindow(input, deps) {
6036
6385
  const cache = { ttl_ms: null, keep_previous: false };
6037
6386
  if (section.cache !== void 0) {
6038
6387
  const at = `${path}.cache`;
6039
- if (!isPlainObject4(section.cache)) fail(`${at} \u5FC5\u987B\u662F { ttl?, keep_previous? }`, at);
6388
+ if (!isPlainObject5(section.cache)) fail(`${at} \u5FC5\u987B\u662F { ttl?, keep_previous? }`, at);
6040
6389
  if (section.cache.ttl !== void 0) {
6041
6390
  cache.ttl_ms = parseDuration(String(section.cache.ttl), `${at}.ttl`, (m) => fail(m, `${at}.ttl`));
6042
6391
  }
@@ -6078,6 +6427,29 @@ var SomaDataConfigError = class extends Error {
6078
6427
  };
6079
6428
  var VALID_FIELD_TYPES = new Set(SOMA_DATA_FIELD_TYPES);
6080
6429
  var VALID_PERMISSIONS = /* @__PURE__ */ new Set(["r", "w"]);
6430
+ var SOMA_DATA_OBJECT_KEYS = [
6431
+ "from",
6432
+ "transform",
6433
+ "fields",
6434
+ "mock",
6435
+ "write",
6436
+ "predicates",
6437
+ "reactions",
6438
+ "window",
6439
+ // REQ-014 期 2'.1:对象界面演绎的语义位与关系
6440
+ "roles",
6441
+ "relations"
6442
+ ];
6443
+ var SOMA_DATA_FIELD_KEYS = [
6444
+ "name",
6445
+ "type",
6446
+ "permission",
6447
+ "rules",
6448
+ "options",
6449
+ "calc",
6450
+ // REQ-014 期 2'.1:修饰关系(`status_tone` 修饰 `status_text`)
6451
+ "modifies"
6452
+ ];
6081
6453
  var RULE_VALUE_TYPES = {
6082
6454
  required: "boolean",
6083
6455
  max_len: "number",
@@ -6287,9 +6659,14 @@ function parseField(raw, path) {
6287
6659
  throw new SomaDataConfigError("calc \u5FC5\u987B\u662F\u975E\u7A7A\u8868\u8FBE\u5F0F\u5B57\u7B26\u4E32", `${path}.calc`);
6288
6660
  }
6289
6661
  field.calc = value;
6662
+ } else if (key === "modifies") {
6663
+ if (typeof value !== "string" || value.trim() === "") {
6664
+ throw new SomaDataConfigError("modifies \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u6BB5\u540D", `${path}.modifies`);
6665
+ }
6666
+ field.modifies = value;
6290
6667
  } else {
6291
6668
  throw new SomaDataConfigError(
6292
- `\u672A\u77E5\u7684\u5B57\u5178\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: name / type / permission / rules / options / calc\uFF09`,
6669
+ `\u672A\u77E5\u7684\u5B57\u5178\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${SOMA_DATA_FIELD_KEYS.join(" / ")}\uFF09`,
6293
6670
  `${path}.${key}`
6294
6671
  );
6295
6672
  }
@@ -6489,6 +6866,8 @@ function parseObject(name, raw, path, objectNames) {
6489
6866
  let predicatesRaw;
6490
6867
  let reactionsRaw;
6491
6868
  let windowRaw;
6869
+ let rolesRaw;
6870
+ let relationsRaw;
6492
6871
  for (const [key, value] of Object.entries(raw)) {
6493
6872
  if (key === "from") {
6494
6873
  if (!Array.isArray(value) || value.length === 0) {
@@ -6506,6 +6885,10 @@ function parseObject(name, raw, path, objectNames) {
6506
6885
  fields2[fieldName] = parseField(fieldRaw, `${path}.fields.${fieldName}`);
6507
6886
  }
6508
6887
  validateDerivedFields(fields2, `${path}.fields`);
6888
+ const modifiesIssues = validateFieldModifies(fields2);
6889
+ if (modifiesIssues.length > 0) {
6890
+ throw new SomaDataConfigError(modifiesIssues.join("\uFF1B"), `${path}.fields`);
6891
+ }
6509
6892
  config.fields = fields2;
6510
6893
  } else if (key === "mock") {
6511
6894
  config.mock = value;
@@ -6517,13 +6900,35 @@ function parseObject(name, raw, path, objectNames) {
6517
6900
  reactionsRaw = value;
6518
6901
  } else if (key === "window") {
6519
6902
  windowRaw = value;
6903
+ } else if (key === "roles") {
6904
+ rolesRaw = value;
6905
+ } else if (key === "relations") {
6906
+ relationsRaw = value;
6520
6907
  } else {
6521
6908
  throw new SomaDataConfigError(
6522
- `\u672A\u77E5\u7684\u58F0\u660E\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: from / transform / fields / mock / write / predicates / reactions / window\uFF09`,
6909
+ `\u672A\u77E5\u7684\u58F0\u660E\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: ${SOMA_DATA_OBJECT_KEYS.join(" / ")}\uFF09`,
6523
6910
  `${path}.${key}`
6524
6911
  );
6525
6912
  }
6526
6913
  }
6914
+ if (rolesRaw !== void 0) {
6915
+ const issues = validateObjectRoles(rolesRaw, Object.keys(config.fields ?? {}));
6916
+ if (issues.length > 0) {
6917
+ throw new SomaDataConfigError(issues.join("\uFF1B"), `${path}.roles`);
6918
+ }
6919
+ config.roles = rolesRaw;
6920
+ }
6921
+ if (relationsRaw !== void 0) {
6922
+ const issues = validateObjectRelations(relationsRaw, {
6923
+ fieldKeys: Object.keys(config.fields ?? {}),
6924
+ objectNames: [...objectNames],
6925
+ selfName: name
6926
+ });
6927
+ if (issues.length > 0) {
6928
+ throw new SomaDataConfigError(issues.join("\uFF1B"), `${path}.relations`);
6929
+ }
6930
+ config.relations = relationsRaw;
6931
+ }
6527
6932
  if (writeRaw !== void 0) {
6528
6933
  config.write = parseWrite(writeRaw, config.fields ?? {}, `${path}.write`, objectNames);
6529
6934
  }