soma-core 2.2.5 → 2.2.6
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 +5 -6
- package/bin/soma.cjs +2 -2
- package/core/build/compiler/flat-page.ts +16 -0
- package/core/build/compiler/full-manifest-builder.ts +0 -3
- package/core/build/compiler/page-assets.ts +0 -1
- package/core/build/compiler/page-closure.ts +245 -0
- package/core/build/compiler/page-declaration-compiler.ts +2 -5
- package/core/build/compiler/soma-precompile.js +1848 -3244
- package/core/build/compiler/soma-precompile.ts +4 -7
- package/core/build/component-tree/artifact-codec.ts +4 -8
- package/core/build/lsp/soma-declaration.cjs +1 -1
- package/core/build/lsp/std-completion.generated.json +3 -3
- package/core/client/a11y/a11y-config.ts +2 -1
- package/core/client/a11y/dom-id.ts +1 -1
- package/core/client/base/SomaHttpClient.ts +11 -3
- package/core/client/base/SomaPageRootBase.ts +6 -0
- package/core/client/base/defineSomaView.ts +178 -0
- package/core/client/base/index.ts +13 -0
- package/core/client/base/view-context.ts +328 -0
- package/core/client/behavior/adapter-collection.ts +2 -2
- package/core/client/compiler/manifest-compiler.ts +5 -36
- package/core/client/component/component-definition.types.ts +2 -1
- package/core/client/component/component-manager.ts +110 -20
- package/core/client/component/structure-adapter.ts +3 -7
- package/core/client/container/SomaContainerAdapter.ts +9 -1
- package/core/client/data/data-object-resolver.ts +516 -181
- package/core/client/data/data-write-actions.ts +79 -15
- package/core/client/data/format-config.ts +3 -1
- package/core/client/data/region-scope-port.ts +11 -0
- package/core/client/engine/asset-resolver.ts +2 -5
- package/core/client/engine/dom-renderer.ts +7 -40
- package/core/client/engine/event-engine.ts +1 -105
- package/core/client/engine/property-watcher.ts +1 -1
- package/core/client/engine/reactive-proxy.ts +78 -17
- package/core/client/engine/runtime-builder.ts +0 -14
- package/core/client/engine/scope-resolver.ts +18 -0
- package/core/client/engine/soma-bootstrap.ts +385 -98
- package/core/client/engine/style-binder.ts +49 -106
- package/core/client/engine/timer-engine.ts +11 -1
- package/core/client/host-bridge/load-host-domain-class.ts +2 -1
- package/core/client/infra/http/SomaHttpService.ts +15 -4
- package/core/client/infra/i18n/pack-locales.ts +2 -2
- package/core/client/mount/domain-rule.ts +7 -3
- package/core/client/mount/mount-page.ts +38 -5
- package/core/client/mount/types.ts +2 -0
- package/core/client/parser/confirm-spec.ts +1 -1
- package/core/client/parser/data-config-parser.ts +27 -210
- package/core/client/parser/pipeline-parser.ts +14 -59
- package/core/client/parser/style-config-parser.ts +101 -95
- package/core/client/parser/timer-parser.ts +21 -0
- package/core/client/parser/ui-config-parser.ts +64 -12
- package/core/client/registry/declaration-renderer.ts +1 -1
- package/core/client/runtime/SomaRuntimeServices.ts +2 -1
- package/core/client/runtime/SomaSnapshotStore.ts +5 -0
- package/core/client/security/url-guard.ts +71 -11
- package/core/client/validation/async-check-registry.ts +2 -1
- package/core/client/validation/contract-validator.ts +2 -6
- package/core/client/validation/field-rules.ts +3 -13
- package/core/client/validation/object-rules.ts +2 -10
- package/core/index.ts +1 -35
- package/core/inspect/check-product.ts +5 -5
- package/core/inspect/runtime.ts +2 -1
- package/core/server/api/dispatch-service-api.ts +35 -36
- package/core/server/api/load-host-service.ts +5 -4
- package/core/server/compile-port.ts +1 -1
- package/core/server/host/app-config-composer.ts +2 -1
- package/core/server/host/host-assembly-entry.ts +1 -0
- package/core/server/host/host-assembly.ts +47 -3
- package/core/server/host/host-caller.ts +2 -1
- package/core/server/host/host-dir.ts +9 -0
- package/core/server/host/host-response-headers.ts +2 -1
- package/core/server/host/invoke-host-request-hook.ts +28 -4
- package/core/server/host/published-page-assets.ts +2 -1
- package/core/server/host/resolve-host-request-hook.ts +25 -7
- package/core/server/host/server-page-assets.ts +4 -4
- package/core/server/host/virtual-pages.ts +3 -2
- package/core/server/infra/cache/ServerFileCache.ts +79 -9
- package/core/server/registry/api-registry-store.ts +3 -1
- package/core/server/registry/declaration-precompiler.ts +0 -2
- package/core/server/registry/page-registry-repository.ts +2 -1
- package/core/server/registry/page-registry-store.ts +2 -1
- package/core/server/registry/registry-error.ts +6 -1
- package/core/server/registry/registry-file-lock.ts +296 -23
- package/core/server/registry/request-body-limit.ts +3 -2
- package/core/server/registry/validation/declaration-safety-scan.ts +151 -27
- package/core/server/runtime-space/access-gate.ts +21 -7
- package/core/server/runtime-space/bindings.ts +3 -6
- package/core/server/runtime-space/dynamic-pages.ts +181 -49
- package/core/server/runtime-space/errors.ts +3 -0
- package/core/server/runtime-space/inject.ts +74 -15
- package/core/server/runtime-space/page-grants.ts +7 -1
- package/core/server/runtime-space/resolve.ts +66 -19
- package/core/server/runtime-space/store.ts +32 -3
- package/core/server/runtime-space/submit-steps.ts +2 -1
- package/core/server/runtime-space/types.ts +3 -1
- package/core/shared/component-tree-errors.ts +2 -1
- package/core/shared/contract-a11y.ts +1 -1
- package/core/shared/contract-sections.ts +2 -2
- package/core/shared/core-diagnostic-codes.ts +8 -0
- package/core/shared/declaration-keys.ts +1 -1
- package/core/shared/engines/engine-error.ts +2 -1
- package/core/shared/generation-error.ts +2 -1
- package/core/shared/page-envelope.ts +1 -1
- package/core/shared/pure-binding.ts +88 -0
- package/core/shared/registry-generated/diagnostic-registry-index.ts +16 -19
- package/core/shared/registry-generated/diagnostic-registry.ts +135 -177
- package/core/shared/registry-generated/limits.ts +49 -13
- package/core/shared/registry-generated/std-grammar-completion.ts +0 -4
- package/core/shared/registry-generated/std-grammar-views.ts +40 -10
- package/core/shared/registry-generated/std-grammar.ts +42 -20
- package/core/shared/soma-error.ts +36 -0
- package/core/shared/types/compile-port.types.ts +1 -1
- package/core/shared/types/data-config.types.ts +17 -17
- package/core/shared/types/engine.types.ts +0 -3
- package/core/shared/types/event.types.ts +1 -11
- package/core/shared/types/generation-error.types.ts +5 -1
- package/core/shared/types/host-assembly.types.ts +7 -1
- package/core/shared/types/manifest.types.ts +0 -3
- package/core/shared/types/region-scope.types.ts +5 -1
- package/core/shared/types/scope-manifest.types.ts +0 -2
- package/core/shared/types/style-config.types.ts +21 -21
- package/core/shared/types/ui-config.types.ts +4 -5
- package/core/shared/types/watcher.types.ts +1 -1
- package/dist/browser/runtime-bundle.manifest.json +11 -13
- package/dist/browser/soma-runtime.js +2567 -2696
- package/dist/core/index.cjs +5446 -5486
- package/dist/host-native/aot-builder.cjs +46 -1
- package/dist/host-native/native-server.cjs +4879 -4505
- package/dist/lsp/component-tree.cjs +5814 -7042
- package/dist/types/build/compiler/full-manifest-builder.d.ts +0 -2
- package/dist/types/build/compiler/page-closure.d.ts +21 -0
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -4
- package/dist/types/build/compiler/soma-precompile.d.ts +1 -3
- package/dist/types/build/component-tree/artifact-codec.d.ts +0 -2
- package/dist/types/client/a11y/a11y-config.d.ts +2 -1
- package/dist/types/client/base/SomaHttpClient.d.ts +1 -1
- package/dist/types/client/base/SomaPageRootBase.d.ts +5 -0
- package/dist/types/client/base/defineSomaView.d.ts +46 -0
- package/dist/types/client/base/index.d.ts +2 -0
- package/dist/types/client/base/view-context.d.ts +136 -0
- package/dist/types/client/behavior/adapter-collection.d.ts +1 -1
- package/dist/types/client/compiler/manifest-compiler.d.ts +0 -3
- package/dist/types/client/component/component-definition.types.d.ts +2 -1
- package/dist/types/client/component/component-manager.d.ts +29 -0
- package/dist/types/client/data/data-object-resolver.d.ts +91 -31
- package/dist/types/client/data/format-config.d.ts +2 -1
- package/dist/types/client/engine/dom-renderer.d.ts +1 -2
- package/dist/types/client/engine/event-engine.d.ts +0 -7
- package/dist/types/client/engine/reactive-proxy.d.ts +11 -4
- package/dist/types/client/engine/runtime-builder.d.ts +0 -4
- package/dist/types/client/engine/soma-bootstrap.d.ts +44 -6
- package/dist/types/client/engine/style-binder.d.ts +8 -4
- package/dist/types/client/host-bridge/load-host-domain-class.d.ts +2 -1
- package/dist/types/client/mount/domain-rule.d.ts +2 -0
- package/dist/types/client/mount/mount-page.d.ts +2 -1
- package/dist/types/client/mount/types.d.ts +2 -0
- package/dist/types/client/parser/data-config-parser.d.ts +6 -5
- package/dist/types/client/parser/style-config-parser.d.ts +7 -3
- package/dist/types/client/parser/timer-parser.d.ts +5 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +6 -2
- package/dist/types/client/runtime/SomaSnapshotStore.d.ts +2 -0
- package/dist/types/client/security/url-guard.d.ts +14 -0
- package/dist/types/client/validation/async-check-registry.d.ts +2 -1
- package/dist/types/client/validation/object-rules.d.ts +0 -5
- package/dist/types/index.d.ts +2 -7
- package/dist/types/inspect/runtime.d.ts +2 -1
- package/dist/types/server/api/dispatch-service-api.d.ts +5 -0
- package/dist/types/server/api/load-host-service.d.ts +1 -1
- package/dist/types/server/compile-port.d.ts +1 -1
- package/dist/types/server/host/host-assembly-entry.d.ts +1 -1
- package/dist/types/server/host/host-assembly.d.ts +2 -0
- package/dist/types/server/host/host-dir.d.ts +2 -0
- package/dist/types/server/host/invoke-host-request-hook.d.ts +10 -3
- package/dist/types/server/host/published-page-assets.d.ts +2 -1
- package/dist/types/server/host/resolve-host-request-hook.d.ts +18 -5
- package/dist/types/server/host/server-page-assets.d.ts +2 -1
- package/dist/types/server/infra/cache/ServerFileCache.d.ts +8 -0
- package/dist/types/server/registry/declaration-precompiler.d.ts +0 -1
- package/dist/types/server/registry/registry-error.d.ts +5 -1
- package/dist/types/server/registry/registry-file-lock.d.ts +30 -0
- package/dist/types/server/registry/request-body-limit.d.ts +3 -2
- package/dist/types/server/registry/validation/declaration-safety-scan.d.ts +3 -0
- package/dist/types/server/runtime-space/access-gate.d.ts +7 -0
- package/dist/types/server/runtime-space/bindings.d.ts +3 -2
- package/dist/types/server/runtime-space/dynamic-pages.d.ts +6 -1
- package/dist/types/server/runtime-space/errors.d.ts +1 -1
- package/dist/types/server/runtime-space/resolve.d.ts +2 -0
- package/dist/types/server/runtime-space/store.d.ts +8 -1
- package/dist/types/server/runtime-space/submit-steps.d.ts +2 -1
- package/dist/types/server/runtime-space/types.d.ts +3 -1
- package/dist/types/shared/component-tree-errors.d.ts +2 -1
- package/dist/types/shared/core-diagnostic-codes.d.ts +1 -1
- package/dist/types/shared/declaration-keys.d.ts +1 -1
- package/dist/types/shared/engines/engine-error.d.ts +2 -1
- package/dist/types/shared/generation-error.d.ts +2 -1
- package/dist/types/shared/pure-binding.d.ts +48 -0
- package/dist/types/shared/registry-generated/diagnostic-registry.d.ts +119 -158
- package/dist/types/shared/registry-generated/limits.d.ts +40 -10
- package/dist/types/shared/registry-generated/std-grammar-completion.d.ts +0 -30
- package/dist/types/shared/registry-generated/std-grammar-views.d.ts +97 -23
- package/dist/types/shared/registry-generated/std-grammar.d.ts +109 -241
- package/dist/types/shared/soma-error.d.ts +15 -0
- package/dist/types/shared/types/data-config.types.d.ts +14 -16
- package/dist/types/shared/types/engine.types.d.ts +0 -3
- package/dist/types/shared/types/event.types.d.ts +1 -7
- package/dist/types/shared/types/generation-error.types.d.ts +1 -1
- package/dist/types/shared/types/host-assembly.types.d.ts +2 -0
- package/dist/types/shared/types/manifest.types.d.ts +0 -3
- package/dist/types/shared/types/region-scope.types.d.ts +4 -1
- package/dist/types/shared/types/scope-manifest.types.d.ts +0 -2
- package/dist/types/shared/types/style-config.types.d.ts +17 -19
- package/dist/types/shared/types/ui-config.types.d.ts +4 -5
- package/host-native/bin/host-native.cjs +22 -1
- package/host-native/client/browser-entry.ts +21 -172
- package/host-native/src/aot-builder.ts +52 -0
- package/host-native/src/host-prepare.ts +39 -5
- package/host-native/src/manifest-http.ts +2 -3
- package/host-native/src/native-server.ts +812 -174
- package/host-native/src/page-http.ts +3 -3
- package/host-native/src/public-packages.cjs +0 -1
- package/host-native/src/registry-handler.ts +12 -5
- package/host-native/src/static-file.ts +203 -53
- package/package.json +3 -2
- package/core/client/engine/step-runner.ts +0 -212
- package/core/client/engine/trigger-engine.ts +0 -55
- package/core/client/format/zoned.ts +0 -10
- package/core/client/parser/step-parser.ts +0 -359
- package/core/client/parser/trigger-parser.ts +0 -90
- package/core/client/parser/value-lang.ts +0 -340
- package/core/client/time/instant.ts +0 -2
- package/core/shared/calc/coerce.ts +0 -2
- package/core/shared/calc/errors.ts +0 -40
- package/core/shared/calc/evaluator.ts +0 -113
- package/core/shared/calc/index.ts +0 -11
- package/core/shared/calc/lexer.ts +0 -189
- package/core/shared/calc/parser.ts +0 -193
- package/core/shared/calc/typer.ts +0 -171
- package/core/shared/date-parts.ts +0 -2
- package/core/shared/show-when.ts +0 -77
- package/core/shared/types/step.types.ts +0 -91
- package/core/shared/types/trigger.types.ts +0 -14
- package/dist/types/client/engine/step-runner.d.ts +0 -42
- package/dist/types/client/engine/trigger-engine.d.ts +0 -16
- package/dist/types/client/format/zoned.d.ts +0 -1
- package/dist/types/client/parser/step-parser.d.ts +0 -23
- package/dist/types/client/parser/trigger-parser.d.ts +0 -13
- package/dist/types/client/parser/value-lang.d.ts +0 -63
- package/dist/types/client/time/instant.d.ts +0 -1
- package/dist/types/shared/calc/coerce.d.ts +0 -1
- package/dist/types/shared/calc/errors.d.ts +0 -14
- package/dist/types/shared/calc/evaluator.d.ts +0 -2
- package/dist/types/shared/calc/index.d.ts +0 -6
- package/dist/types/shared/calc/lexer.d.ts +0 -19
- package/dist/types/shared/calc/parser.d.ts +0 -43
- package/dist/types/shared/calc/typer.d.ts +0 -11
- package/dist/types/shared/date-parts.d.ts +0 -1
- package/dist/types/shared/show-when.d.ts +0 -21
- package/dist/types/shared/types/step.types.d.ts +0 -76
- package/dist/types/shared/types/trigger.types.d.ts +0 -12
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// 动作编排类型(REQ-010 S4)——「一个交互要按顺序做好几件事」的声明式表达。
|
|
2
|
-
//
|
|
3
|
-
// ── 它替掉的是什么 ────────────────────────────────────────────────────
|
|
4
|
-
// 今天一个事件只能挂一条管道。要「先导出、成功了跳转、失败了弹错、顺带刷统计」,
|
|
5
|
-
// 只能在 Domain 里写一个 handler 把四件事串起来——于是编排逻辑回到了代码里,
|
|
6
|
-
// 声明层看不见它,AI 也生成不了它。
|
|
7
|
-
//
|
|
8
|
-
// amis 的 `onEvent` 能表达编排,代价是它带 `custom(script)` 逃生舱;
|
|
9
|
-
// XState 能表达状态机,但它的 actions 是函数。两边的共同点:**编排图不是数据**,
|
|
10
|
-
// 所以画不出来、diff 不了、也没法在编译期回答「这条链会不会不终止」。
|
|
11
|
-
//
|
|
12
|
-
// SOMA 的每一步都是既有的四动词管道 + 闭集控制流,所以编排图是**纯数据**:
|
|
13
|
-
// 可画、可 diff、可静态判定可终止性。逃生舱换成**具名动作注册表**——
|
|
14
|
-
// 实现仍在 Host 代码里,但它有名字、要注册、可审计,声明层零脚本。
|
|
15
|
-
|
|
16
|
-
import type { SomaFieldPredicate } from '../predicates';
|
|
17
|
-
import type { ParsedEvent } from './event.types';
|
|
18
|
-
|
|
19
|
-
/** 出错之后怎么走:停 / 继续 / 跳到第 n 步(只许向后,见 AO-1) */
|
|
20
|
-
export type SomaStepOnError = 'stop' | 'continue' | `goto:${number}`;
|
|
21
|
-
|
|
22
|
-
/** 单步:一条管道 + 可选的条件、输出槽与错误去向 */
|
|
23
|
-
export interface SomaDoStep {
|
|
24
|
-
when?: SomaFieldPredicate;
|
|
25
|
-
do: string;
|
|
26
|
-
output?: string;
|
|
27
|
-
on_error?: SomaStepOnError;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** 分支:取第一个成立的 `when`;`otherwise` 可选且只能有一个、且必须在末尾 */
|
|
31
|
-
export interface SomaSwitchStep {
|
|
32
|
-
when?: SomaFieldPredicate;
|
|
33
|
-
switch: Array<{ when?: SomaFieldPredicate; otherwise?: true; do: string; output?: string }>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** 并行:分支之间**不许互引输出槽**(互引就意味着有顺序,那它就不是并行) */
|
|
37
|
-
export interface SomaParallelStep {
|
|
38
|
-
parallel: SomaStep[];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** 遍历:`over` 必须是有界的(数组型输出槽或事件载荷里的数组) */
|
|
42
|
-
export interface SomaForEachStep {
|
|
43
|
-
for_each: { over: string; as: string; steps: SomaStep[] };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export type SomaStep = SomaDoStep | SomaSwitchStep | SomaParallelStep | SomaForEachStep;
|
|
47
|
-
|
|
48
|
-
/** 输出槽:本次事件内的具名中间结果 */
|
|
49
|
-
export interface SomaStepSlot {
|
|
50
|
-
/** 声明它的步骤序号(引用只许向后,见 AO-2) */
|
|
51
|
-
declaredAt: number;
|
|
52
|
-
/** 产出它的动作类型,用于「这个槽是不是数组」这类判断 */
|
|
53
|
-
producedBy: string;
|
|
54
|
-
/** 是否已知为数组(`for_each.over` 只认这种) */
|
|
55
|
-
bounded: boolean;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** 编译后的一步:管道已解析,条件已校验 */
|
|
59
|
-
export interface SomaCompiledStep {
|
|
60
|
-
index: number;
|
|
61
|
-
kind: 'do' | 'switch' | 'parallel' | 'for_each';
|
|
62
|
-
when?: SomaFieldPredicate;
|
|
63
|
-
/** kind='do' */
|
|
64
|
-
pipeline?: Omit<ParsedEvent, 'somaId' | 'domEvent'>;
|
|
65
|
-
output?: string;
|
|
66
|
-
onError: SomaStepOnError;
|
|
67
|
-
/** kind='switch' */
|
|
68
|
-
branches?: Array<{
|
|
69
|
-
when?: SomaFieldPredicate;
|
|
70
|
-
otherwise: boolean;
|
|
71
|
-
pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>;
|
|
72
|
-
output?: string;
|
|
73
|
-
}>;
|
|
74
|
-
/** kind='parallel' / 'for_each' */
|
|
75
|
-
children?: SomaCompiledStep[];
|
|
76
|
-
/** kind='for_each' */
|
|
77
|
-
over?: string;
|
|
78
|
-
as?: string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 编译产物:纯数据,可画、可 diff、可进目录快照(AO-4)。
|
|
83
|
-
*
|
|
84
|
-
* `edges` 是顺序边与 `goto` 边的并集——它存在的唯一理由是**能被画出来**:
|
|
85
|
-
* 一张编排图如果只能靠读 YAML 想象,那它和写在代码里的 handler 没有区别。
|
|
86
|
-
*/
|
|
87
|
-
export interface SomaStepGraph {
|
|
88
|
-
steps: SomaCompiledStep[];
|
|
89
|
-
slots: Record<string, SomaStepSlot>;
|
|
90
|
-
edges: Array<[number, number]>;
|
|
91
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// 属性变化 DOM 事件触发器 — 对应 _event.yaml 的 triggers 块
|
|
2
|
-
|
|
3
|
-
export interface PropertyTrigger {
|
|
4
|
-
/** 监听的数据路径(含 var 别名,如 page.isLoading) */
|
|
5
|
-
condition: string;
|
|
6
|
-
/** 触发条件:属性值等于此值时执行 */
|
|
7
|
-
value: string | number | boolean | null;
|
|
8
|
-
/** 目标元素的 data-soma-id */
|
|
9
|
-
target: string;
|
|
10
|
-
/** 分发的 DOM 事件名(如 soma:show、click) */
|
|
11
|
-
event: string;
|
|
12
|
-
/** 自定义事件 detail 载荷 */
|
|
13
|
-
detail?: Record<string, unknown>;
|
|
14
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ParsedEvent, SomaConfirmSpec } from '../../shared/types/event.types';
|
|
2
|
-
import type { SomaStepGraph } from '../../shared/types/step.types';
|
|
3
|
-
export interface StepRunContext {
|
|
4
|
-
/** 事件载荷:`when` 的字段来源之一 */
|
|
5
|
-
payload: Record<string, unknown>;
|
|
6
|
-
/** 执行一条已解析的管道;返回值进输出槽 */
|
|
7
|
-
dispatch(pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>, scope?: Record<string, unknown>): Promise<unknown>;
|
|
8
|
-
/** bootstrap 注册的具名动作 */
|
|
9
|
-
actions?: Record<string, (payload: Record<string, unknown>) => Promise<unknown> | unknown>;
|
|
10
|
-
/** 出错落点;不给就 console.error */
|
|
11
|
-
onError?(message: string, detail: {
|
|
12
|
-
step: number;
|
|
13
|
-
cause: unknown;
|
|
14
|
-
}): void;
|
|
15
|
-
isValid?(): boolean;
|
|
16
|
-
/**
|
|
17
|
-
* 确认分级的执行口(R-23):步骤管道带 `confirm`(plain 文案或 typed / consent 规格)时,执行前先过它;
|
|
18
|
-
* 返回 false = 用户取消,整条编排中止(`stopped` + `cancelled`),与单管道事件「取消即中止」同口径。
|
|
19
|
-
* 不给就不确认。步骤类型不限:ACTION 步骤与其余步骤一样先过它。
|
|
20
|
-
*/
|
|
21
|
-
confirm?(spec: SomaConfirmSpec): boolean | Promise<boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* 权限码判据(管道尾段 `permission:code`):返回 false = 拒绝,整条编排中止(`stopped` + `denied: 'permission'`),
|
|
24
|
-
* 与单管道事件被权限中间件拦下同口径;提示由实现方负责。不给就不判。
|
|
25
|
-
*/
|
|
26
|
-
permission?(code: string): boolean | Promise<boolean>;
|
|
27
|
-
/** 角色判据(管道尾段 `roles:a,b`):返回 false = 拒绝,整条编排中止(`denied: 'roles'`),与单管道的角色门同口径。不给就不判。 */
|
|
28
|
-
roles?(roles: readonly string[]): boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface StepRunResult {
|
|
31
|
-
/** 实际执行过的步骤序号(顺序即执行序,`goto` 会让它跳号) */
|
|
32
|
-
executed: number[];
|
|
33
|
-
/** 事件结束时的槽(仅用于测试与诊断;运行期不外泄) */
|
|
34
|
-
slots: Record<string, unknown>;
|
|
35
|
-
/** 是否被 on_error: stop 中断 */
|
|
36
|
-
stopped: boolean;
|
|
37
|
-
/** 因某步确认被取消而中止(`stopped` 同为 true) */
|
|
38
|
-
cancelled?: boolean;
|
|
39
|
-
/** 因某步权限码或角色不通过而中止(`stopped` 同为 true) */
|
|
40
|
-
denied?: 'permission' | 'roles';
|
|
41
|
-
}
|
|
42
|
-
export declare function runSteps(graph: SomaStepGraph, ctx: StepRunContext): Promise<StepRunResult>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IContainerAdapter } from '../container/IContainerAdapter';
|
|
2
|
-
import type { PropertyTrigger } from '../../shared/types/trigger.types';
|
|
3
|
-
import type { SomaScopeResolver } from './scope-resolver';
|
|
4
|
-
import type { SomaPropertyWatcher } from './property-watcher';
|
|
5
|
-
export interface SomaTriggerEngineOptions {
|
|
6
|
-
propertyWatcher: SomaPropertyWatcher;
|
|
7
|
-
resolver: SomaScopeResolver;
|
|
8
|
-
container: HTMLElement;
|
|
9
|
-
adapter: IContainerAdapter;
|
|
10
|
-
triggers: PropertyTrigger[];
|
|
11
|
-
}
|
|
12
|
-
export declare class SomaTriggerEngine {
|
|
13
|
-
private readonly unwatchers;
|
|
14
|
-
init(options: SomaTriggerEngineOptions): void;
|
|
15
|
-
destroy(): void;
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { MS_PER_DAY, civilDayNumber, civilUtcMs, isValidTimeZone, zonedPartsOf, zonedTimeToMs, type ZonedParts, } from 'soma-foundation/values';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ParsedEvent } from '../../shared/types/event.types';
|
|
2
|
-
import type { SomaStepGraph } from '../../shared/types/step.types';
|
|
3
|
-
export interface StepParseInput {
|
|
4
|
-
raw: unknown;
|
|
5
|
-
/** 事件载荷里的字段名:`when` 的作用域起点 */
|
|
6
|
-
payloadFields: readonly string[];
|
|
7
|
-
/** bootstrap 注册的具名动作;给了就校验 `do: ACTION | <name>` 的名字存在 */
|
|
8
|
-
actionNames?: readonly string[];
|
|
9
|
-
path: string;
|
|
10
|
-
}
|
|
11
|
-
export interface StepParseDeps {
|
|
12
|
-
fail(message: string, path: string): never;
|
|
13
|
-
/**
|
|
14
|
-
* 单条管道的解析器(`pipeline-parser` 的 `parsePipelineBody`)。
|
|
15
|
-
*
|
|
16
|
-
* 由调用方注入而不是直接 import,是为了不成环:`pipeline-parser` 的
|
|
17
|
-
* `parseEventConfig` 要认 `{ steps: [...] }` 形态,于是它得调本模块;
|
|
18
|
-
* 本模块再反向 import 它就构成循环,而循环 import 在 ESM 下"多数时候能跑"
|
|
19
|
-
* ——它坏起来是模块初始化顺序变了之后的一个 undefined,跟本次改动毫无关联。
|
|
20
|
-
*/
|
|
21
|
-
parsePipeline(expression: string): Omit<ParsedEvent, 'somaId' | 'domEvent'>;
|
|
22
|
-
}
|
|
23
|
-
export declare function parseSteps(input: StepParseInput, deps: StepParseDeps): SomaStepGraph;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { PropertyTrigger } from '../../shared/types/trigger.types';
|
|
2
|
-
import type { ParsedTimer } from '../../shared/types/timer.types';
|
|
3
|
-
export declare class SomaTriggerParseError extends Error {
|
|
4
|
-
constructor(message: string);
|
|
5
|
-
}
|
|
6
|
-
/** 解析 triggers 数组(YAML 中 triggers: [...]) */
|
|
7
|
-
export declare function parseTriggers(raw: unknown): PropertyTrigger[];
|
|
8
|
-
/** 从 event 配置根对象分离 triggers / timers 与事件声明 */
|
|
9
|
-
export declare function splitEventConfigRaw(raw: unknown): {
|
|
10
|
-
eventsRaw: Record<string, unknown>;
|
|
11
|
-
triggers: PropertyTrigger[];
|
|
12
|
-
timers: ParsedTimer[];
|
|
13
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { SomaPipeCall } from '../../shared/types/scope-manifest.types';
|
|
2
|
-
export declare class SomaValueLangError extends Error {
|
|
3
|
-
readonly raw: string;
|
|
4
|
-
constructor(message: string, raw: string);
|
|
5
|
-
}
|
|
6
|
-
/** 值段的指令节点:JSON 可序列化,进清单 */
|
|
7
|
-
export type ValueNode = {
|
|
8
|
-
kind: 'path';
|
|
9
|
-
path: string;
|
|
10
|
-
} | {
|
|
11
|
-
kind: 'lit';
|
|
12
|
-
value: string | number | boolean;
|
|
13
|
-
} | {
|
|
14
|
-
kind: 'neg';
|
|
15
|
-
operand: ValueNode;
|
|
16
|
-
} | {
|
|
17
|
-
kind: 'arith';
|
|
18
|
-
op: '+' | '-' | '*' | '/';
|
|
19
|
-
left: ValueNode;
|
|
20
|
-
right: ValueNode;
|
|
21
|
-
};
|
|
22
|
-
export interface PipedValue {
|
|
23
|
-
seg: ValueNode;
|
|
24
|
-
pipes: SomaPipeCall[];
|
|
25
|
-
/** 值内引用的全部绑定路径(段内 + 管道实参),供 watchPaths 注册 */
|
|
26
|
-
paths: string[];
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 值位置。算术与计算管道是**展示位专有**——算出来的值不驱动行为,
|
|
30
|
-
* 业务规则(定价、优惠、判断)留在 Domain 才可测试。
|
|
31
|
-
*/
|
|
32
|
-
export type ValuePosition = 'display' | 'condition' | 'key';
|
|
33
|
-
/** 判定一个变量首段是否在当前作用域(与既有 hasVar 同款契约) */
|
|
34
|
-
export type HasVarFn = (segment: string) => boolean;
|
|
35
|
-
/** 段内是否需要走算术解析(出现运算符或括号即是;路径词法不含它们) */
|
|
36
|
-
export declare function isArithSegment(segment: string): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* 解析一个值段(不含管道)。
|
|
39
|
-
*
|
|
40
|
-
* 纯路径与纯字面量走快路径;含运算符时进算术文法。
|
|
41
|
-
*/
|
|
42
|
-
export declare function parseValueSegment(segment: string, hasVar: HasVarFn, position?: ValuePosition, source?: string): {
|
|
43
|
-
node: ValueNode;
|
|
44
|
-
paths: string[];
|
|
45
|
-
};
|
|
46
|
-
/** 值段内是否只是一条裸路径(供上层决定是否走既有轻路径) */
|
|
47
|
-
export declare function isPlainPath(node: ValueNode): node is {
|
|
48
|
-
kind: 'path';
|
|
49
|
-
path: string;
|
|
50
|
-
};
|
|
51
|
-
export interface EvalOptions {
|
|
52
|
-
/** dev 下算术遇非数值/除零直接抛错(含表达式原文);prod 返回 null 交由上层占位 */
|
|
53
|
-
dev?: boolean;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 对指令节点求值。
|
|
57
|
-
*
|
|
58
|
-
* 除零与非数值:dev 抛错(点名原文,避免"页面上一个 NaN 查半天"),
|
|
59
|
-
* prod 返回 null——上层渲染占位符,与 role_by 未命中的既有语义一致。
|
|
60
|
-
*/
|
|
61
|
-
export declare function evaluateValueNode(node: ValueNode, read: (path: string) => unknown, options?: EvalOptions): unknown;
|
|
62
|
-
/** 把指令节点还原成近似原文,仅用于报错可读性 */
|
|
63
|
-
export declare function describeNode(node: ValueNode): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { instantOf, type SomaInstantOptions } from 'soma-foundation/values';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ordinalOf, textOf } from 'soma-foundation/predicates';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** 源串里的字符区间 [起, 止),用于错误定位 */
|
|
2
|
-
export type CalcSpan = readonly [number, number];
|
|
3
|
-
export declare class SomaCalcSyntaxError extends Error {
|
|
4
|
-
readonly pos: CalcSpan;
|
|
5
|
-
/** 出错处附近的原文片段(供报错时回显) */
|
|
6
|
-
readonly near: string;
|
|
7
|
-
constructor(message: string, source: string, pos: CalcSpan);
|
|
8
|
-
}
|
|
9
|
-
export declare class SomaCalcTypeError extends Error {
|
|
10
|
-
readonly pos: CalcSpan;
|
|
11
|
-
readonly expected: string;
|
|
12
|
-
readonly actual: string;
|
|
13
|
-
constructor(message: string, source: string, pos: CalcSpan, expected: string, actual: string);
|
|
14
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { SomaCalcSyntaxError, SomaCalcTypeError, type CalcSpan } from './errors';
|
|
2
|
-
export { tokenize, parseDateLiteral, CALC_FUNCTIONS, type CalcToken, type CalcTokenKind, type CalcFunctionName } from './lexer';
|
|
3
|
-
export { parseCalc, collectCalcRefs, type CalcAst, type CalcBinaryOp } from './parser';
|
|
4
|
-
export { inferCalcType, assertCalcResultType, type CalcType, type CalcTypeContext } from './typer';
|
|
5
|
-
export { evaluateCalc } from './evaluator';
|
|
6
|
-
export { ordinalOf, textOf } from './coerce';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { type CalcSpan } from './errors';
|
|
2
|
-
export type CalcTokenKind = 'number' | 'string' | 'date' | 'bool' | 'ref' | 'ident' | 'op' | 'lparen' | 'rparen' | 'comma' | 'eof';
|
|
3
|
-
export interface CalcToken {
|
|
4
|
-
kind: CalcTokenKind;
|
|
5
|
-
/** number → 数值;string → 已去引号去转义的文本;date → UTC 毫秒;bool → 布尔;
|
|
6
|
-
* ref → 字段名;ident → 函数名;op → 运算符原文 */
|
|
7
|
-
value: string | number | boolean;
|
|
8
|
-
pos: CalcSpan;
|
|
9
|
-
}
|
|
10
|
-
/** 六个函数名——封闭集 */
|
|
11
|
-
export declare const CALC_FUNCTIONS: readonly ["IF", "MIN", "MAX", "ROUND", "CONCAT", "ABS"];
|
|
12
|
-
export type CalcFunctionName = typeof CALC_FUNCTIONS[number];
|
|
13
|
-
export declare function tokenize(source: string): CalcToken[];
|
|
14
|
-
/**
|
|
15
|
-
* 日期字面量 → UTC 毫秒。
|
|
16
|
-
* 用 `Date.UTC` 而不是 `Date.parse`:后者对无时区的串在各引擎上曾有本地/UTC 之争,
|
|
17
|
-
* 而派生列的日期比较必须在任何机器上给同一个答案。
|
|
18
|
-
*/
|
|
19
|
-
export declare function parseDateLiteral(text: string): number | null;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type CalcSpan } from './errors';
|
|
2
|
-
import { type CalcFunctionName } from './lexer';
|
|
3
|
-
export type CalcBinaryOp = '+' | '-' | '*' | '/' | '>' | '>=' | '<' | '<=' | '==' | '!=';
|
|
4
|
-
export type CalcAst = {
|
|
5
|
-
k: 'num';
|
|
6
|
-
v: number;
|
|
7
|
-
pos: CalcSpan;
|
|
8
|
-
} | {
|
|
9
|
-
k: 'str';
|
|
10
|
-
v: string;
|
|
11
|
-
pos: CalcSpan;
|
|
12
|
-
} | {
|
|
13
|
-
k: 'date';
|
|
14
|
-
v: number;
|
|
15
|
-
pos: CalcSpan;
|
|
16
|
-
} | {
|
|
17
|
-
k: 'bool';
|
|
18
|
-
v: boolean;
|
|
19
|
-
pos: CalcSpan;
|
|
20
|
-
} | {
|
|
21
|
-
k: 'ref';
|
|
22
|
-
name: string;
|
|
23
|
-
pos: CalcSpan;
|
|
24
|
-
} | {
|
|
25
|
-
k: 'un';
|
|
26
|
-
op: '-';
|
|
27
|
-
arg: CalcAst;
|
|
28
|
-
pos: CalcSpan;
|
|
29
|
-
} | {
|
|
30
|
-
k: 'bin';
|
|
31
|
-
op: CalcBinaryOp;
|
|
32
|
-
left: CalcAst;
|
|
33
|
-
right: CalcAst;
|
|
34
|
-
pos: CalcSpan;
|
|
35
|
-
} | {
|
|
36
|
-
k: 'call';
|
|
37
|
-
fn: CalcFunctionName;
|
|
38
|
-
args: CalcAst[];
|
|
39
|
-
pos: CalcSpan;
|
|
40
|
-
};
|
|
41
|
-
export declare function parseCalc(source: string): CalcAst;
|
|
42
|
-
/** 收集表达式引用的字段名(去重、首次出现序):派生列互相引用时按它排求值次序 */
|
|
43
|
-
export declare function collectCalcRefs(ast: CalcAst): string[];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { CalcAst } from './parser';
|
|
2
|
-
export type CalcType = 'number' | 'text' | 'bool' | 'date';
|
|
3
|
-
export interface CalcTypeContext {
|
|
4
|
-
/** 字段名 → 字典里的 `type`(缺省视为 text,与字典本身的缺省一致) */
|
|
5
|
-
fieldTypes: Readonly<Record<string, string | undefined>>;
|
|
6
|
-
/** 原始表达式串,仅用于错误定位 */
|
|
7
|
-
source: string;
|
|
8
|
-
}
|
|
9
|
-
export declare function inferCalcType(ast: CalcAst, ctx: CalcTypeContext): CalcType;
|
|
10
|
-
/** 与字段声明的 `type` 对账(单独一个函数,便于「只想知道类型」的场合不带目标字段) */
|
|
11
|
-
export declare function assertCalcResultType(result: CalcType, declaredFieldType: string | undefined, ctx: CalcTypeContext, ast: CalcAst): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SOMA_DATE_PARTS, isDatePart, type SomaDatePart } from 'soma-foundation/values';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** Show `when` 对象形的 `op` 闭集:谓词算子 + 有无值算子 */
|
|
2
|
-
export declare const SOMA_SHOW_WHEN_OPS: readonly string[];
|
|
3
|
-
export interface SomaShowWhenObject {
|
|
4
|
-
field: string;
|
|
5
|
-
op: string;
|
|
6
|
-
value?: unknown;
|
|
7
|
-
}
|
|
8
|
-
/** `when` 的两种写法:字符串(真值 / `!` 取反)或对象谓词 */
|
|
9
|
-
export type SomaShowWhen = string | SomaShowWhenObject;
|
|
10
|
-
/** 编译后挂在绑定上的谓词部分(路径另存在 dataPath) */
|
|
11
|
-
export interface SomaShowWhenTest {
|
|
12
|
-
op: string;
|
|
13
|
-
value?: unknown;
|
|
14
|
-
}
|
|
15
|
-
export declare function isShowWhenObject(raw: unknown): raw is SomaShowWhenObject;
|
|
16
|
-
/** 有值:非 null / undefined / 空白串 / 空数组;`0` 与 `false` 算有值 */
|
|
17
|
-
export declare function isPresentValue(value: unknown): boolean;
|
|
18
|
-
/** 校验对象形 `when`:封闭键、`field` 纯路径、`op` 在闭集内、`value` 与算子匹配;返回问题清单(空 = 通过) */
|
|
19
|
-
export declare function inspectShowWhen(raw: unknown, path?: string): string[];
|
|
20
|
-
/** 对一个已读到的值求对象谓词 */
|
|
21
|
-
export declare function evaluateShowWhen(test: SomaShowWhenTest, actual: unknown): boolean;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import type { SomaFieldPredicate } from '../predicates';
|
|
2
|
-
import type { ParsedEvent } from './event.types';
|
|
3
|
-
/** 出错之后怎么走:停 / 继续 / 跳到第 n 步(只许向后,见 AO-1) */
|
|
4
|
-
export type SomaStepOnError = 'stop' | 'continue' | `goto:${number}`;
|
|
5
|
-
/** 单步:一条管道 + 可选的条件、输出槽与错误去向 */
|
|
6
|
-
export interface SomaDoStep {
|
|
7
|
-
when?: SomaFieldPredicate;
|
|
8
|
-
do: string;
|
|
9
|
-
output?: string;
|
|
10
|
-
on_error?: SomaStepOnError;
|
|
11
|
-
}
|
|
12
|
-
/** 分支:取第一个成立的 `when`;`otherwise` 可选且只能有一个、且必须在末尾 */
|
|
13
|
-
export interface SomaSwitchStep {
|
|
14
|
-
when?: SomaFieldPredicate;
|
|
15
|
-
switch: Array<{
|
|
16
|
-
when?: SomaFieldPredicate;
|
|
17
|
-
otherwise?: true;
|
|
18
|
-
do: string;
|
|
19
|
-
output?: string;
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
/** 并行:分支之间**不许互引输出槽**(互引就意味着有顺序,那它就不是并行) */
|
|
23
|
-
export interface SomaParallelStep {
|
|
24
|
-
parallel: SomaStep[];
|
|
25
|
-
}
|
|
26
|
-
/** 遍历:`over` 必须是有界的(数组型输出槽或事件载荷里的数组) */
|
|
27
|
-
export interface SomaForEachStep {
|
|
28
|
-
for_each: {
|
|
29
|
-
over: string;
|
|
30
|
-
as: string;
|
|
31
|
-
steps: SomaStep[];
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export type SomaStep = SomaDoStep | SomaSwitchStep | SomaParallelStep | SomaForEachStep;
|
|
35
|
-
/** 输出槽:本次事件内的具名中间结果 */
|
|
36
|
-
export interface SomaStepSlot {
|
|
37
|
-
/** 声明它的步骤序号(引用只许向后,见 AO-2) */
|
|
38
|
-
declaredAt: number;
|
|
39
|
-
/** 产出它的动作类型,用于「这个槽是不是数组」这类判断 */
|
|
40
|
-
producedBy: string;
|
|
41
|
-
/** 是否已知为数组(`for_each.over` 只认这种) */
|
|
42
|
-
bounded: boolean;
|
|
43
|
-
}
|
|
44
|
-
/** 编译后的一步:管道已解析,条件已校验 */
|
|
45
|
-
export interface SomaCompiledStep {
|
|
46
|
-
index: number;
|
|
47
|
-
kind: 'do' | 'switch' | 'parallel' | 'for_each';
|
|
48
|
-
when?: SomaFieldPredicate;
|
|
49
|
-
/** kind='do' */
|
|
50
|
-
pipeline?: Omit<ParsedEvent, 'somaId' | 'domEvent'>;
|
|
51
|
-
output?: string;
|
|
52
|
-
onError: SomaStepOnError;
|
|
53
|
-
/** kind='switch' */
|
|
54
|
-
branches?: Array<{
|
|
55
|
-
when?: SomaFieldPredicate;
|
|
56
|
-
otherwise: boolean;
|
|
57
|
-
pipeline: Omit<ParsedEvent, 'somaId' | 'domEvent'>;
|
|
58
|
-
output?: string;
|
|
59
|
-
}>;
|
|
60
|
-
/** kind='parallel' / 'for_each' */
|
|
61
|
-
children?: SomaCompiledStep[];
|
|
62
|
-
/** kind='for_each' */
|
|
63
|
-
over?: string;
|
|
64
|
-
as?: string;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 编译产物:纯数据,可画、可 diff、可进目录快照(AO-4)。
|
|
68
|
-
*
|
|
69
|
-
* `edges` 是顺序边与 `goto` 边的并集——它存在的唯一理由是**能被画出来**:
|
|
70
|
-
* 一张编排图如果只能靠读 YAML 想象,那它和写在代码里的 handler 没有区别。
|
|
71
|
-
*/
|
|
72
|
-
export interface SomaStepGraph {
|
|
73
|
-
steps: SomaCompiledStep[];
|
|
74
|
-
slots: Record<string, SomaStepSlot>;
|
|
75
|
-
edges: Array<[number, number]>;
|
|
76
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface PropertyTrigger {
|
|
2
|
-
/** 监听的数据路径(含 var 别名,如 page.isLoading) */
|
|
3
|
-
condition: string;
|
|
4
|
-
/** 触发条件:属性值等于此值时执行 */
|
|
5
|
-
value: string | number | boolean | null;
|
|
6
|
-
/** 目标元素的 data-soma-id */
|
|
7
|
-
target: string;
|
|
8
|
-
/** 分发的 DOM 事件名(如 soma:show、click) */
|
|
9
|
-
event: string;
|
|
10
|
-
/** 自定义事件 detail 载荷 */
|
|
11
|
-
detail?: Record<string, unknown>;
|
|
12
|
-
}
|