soma-core 1.4.0 → 1.4.2
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 +1 -1
- package/core/build/blocks/block-compile.ts +31 -2
- package/core/build/blocks/block-container.ts +2 -11
- package/core/build/compiler/page-declaration-compiler.ts +30 -2
- package/core/build/compiler/soma-precompile.js +2053 -23
- package/core/build/component/component-graph.ts +208 -0
- package/core/build/component/package-loader.ts +32 -0
- package/core/build/eject/component-eject.ts +473 -0
- package/core/build/eject/component-upgrade.ts +359 -0
- package/core/build/layout/constraint-solver.ts +235 -0
- package/core/build/layout/css-emitter.ts +116 -0
- package/core/build/layout/page-layout.ts +85 -0
- package/core/build/pack/pack-init.ts +270 -0
- package/core/client/base/SomaHttpClient.ts +34 -1
- package/core/client/base/SomaPageRootBase.ts +61 -0
- package/core/client/component/ai-catalog.ts +121 -4
- package/core/client/component/component-defaults.ts +100 -0
- package/core/client/component/component-definition.types.ts +39 -0
- package/core/client/component/component-manager.ts +79 -4
- package/core/client/component/component-pack.ts +126 -2
- package/core/client/component/keyboard-matrix.ts +144 -0
- package/core/client/component/pack-styles.ts +59 -1
- package/core/client/component/style-features.ts +131 -0
- package/core/client/component/theme-component-tokens.ts +83 -0
- package/core/client/component/verify-pack.ts +120 -1
- package/core/client/container/SomaContainerAdapter.ts +6 -2
- package/core/client/data/data-object-resolver.ts +407 -4
- package/core/client/data/reaction-engine.ts +176 -0
- package/core/client/data/window-engine.ts +477 -0
- package/core/client/engine/event-engine.ts +98 -0
- package/core/client/engine/soma-bootstrap.ts +265 -5
- package/core/client/engine/step-runner.ts +134 -0
- package/core/client/infra/http/SomaHttpService.ts +2 -2
- package/core/client/parser/blocks/page-parser.ts +15 -1
- package/core/client/parser/blocks/use-parser.ts +5 -12
- package/core/client/parser/data-config-parser.ts +316 -8
- package/core/client/parser/duration.ts +16 -0
- package/core/client/parser/layout-parser.ts +157 -0
- package/core/client/parser/page-state-parser.ts +166 -0
- package/core/client/parser/pipeline-parser.ts +76 -1
- package/core/client/parser/reaction-parser.ts +459 -0
- package/core/client/parser/reaction-sugar.ts +47 -0
- package/core/client/parser/step-parser.ts +359 -0
- package/core/client/parser/ui-config-parser.ts +59 -0
- package/core/client/parser/window-parser.ts +294 -0
- package/core/client/theme/theme-engine.ts +102 -2
- package/core/index.ts +184 -0
- package/core/shared/block-errors.ts +11 -0
- package/core/shared/calc/coerce.ts +29 -0
- package/core/shared/calc/errors.ts +43 -0
- package/core/shared/calc/evaluator.ts +101 -0
- package/core/shared/calc/index.ts +12 -0
- package/core/shared/calc/lexer.ts +194 -0
- package/core/shared/calc/parser.ts +204 -0
- package/core/shared/calc/typer.ts +184 -0
- package/core/shared/component/derive-sample.ts +105 -0
- package/core/shared/component/field-lines.ts +473 -0
- package/core/shared/path-algebra.ts +169 -0
- package/core/shared/predicates/index.ts +527 -0
- package/core/shared/types/component-contract.types.ts +151 -9
- package/core/shared/types/data-config.types.ts +120 -1
- package/core/shared/types/domain.types.ts +13 -0
- package/core/shared/types/event.types.ts +22 -2
- package/core/shared/types/layout-constraint.types.ts +73 -0
- package/core/shared/types/page-state.types.ts +60 -0
- package/core/shared/types/reaction.types.ts +144 -0
- package/core/shared/types/step.types.ts +91 -0
- package/core/shared/types/ui-config.types.ts +18 -0
- package/core/shared/types/window.types.ts +177 -0
- package/dist/cli/soma.js +13 -1
- package/dist/core/index.cjs +5529 -631
- package/dist/types/build/blocks/block-container.d.ts +1 -6
- package/dist/types/build/compiler/page-declaration-compiler.d.ts +2 -0
- package/dist/types/build/component/component-graph.d.ts +85 -0
- package/dist/types/build/eject/component-eject.d.ts +121 -0
- package/dist/types/build/eject/component-upgrade.d.ts +43 -0
- package/dist/types/build/layout/constraint-solver.d.ts +36 -0
- package/dist/types/build/layout/css-emitter.d.ts +18 -0
- package/dist/types/build/layout/page-layout.d.ts +24 -0
- package/dist/types/build/pack/pack-init.d.ts +8 -0
- package/dist/types/client/base/SomaHttpClient.d.ts +8 -0
- package/dist/types/client/base/SomaPageRootBase.d.ts +28 -0
- package/dist/types/client/component/ai-catalog.d.ts +33 -1
- package/dist/types/client/component/component-defaults.d.ts +15 -0
- package/dist/types/client/component/component-definition.types.d.ts +38 -0
- package/dist/types/client/component/component-manager.d.ts +36 -0
- package/dist/types/client/component/component-pack.d.ts +32 -2
- package/dist/types/client/component/keyboard-matrix.d.ts +24 -0
- package/dist/types/client/component/pack-styles.d.ts +21 -0
- package/dist/types/client/component/style-features.d.ts +26 -0
- package/dist/types/client/component/theme-component-tokens.d.ts +14 -0
- package/dist/types/client/component/verify-pack.d.ts +10 -0
- package/dist/types/client/data/data-object-resolver.d.ts +106 -1
- package/dist/types/client/data/reaction-engine.d.ts +21 -0
- package/dist/types/client/data/window-engine.d.ts +27 -0
- package/dist/types/client/engine/event-engine.d.ts +15 -0
- package/dist/types/client/engine/soma-bootstrap.d.ts +70 -0
- package/dist/types/client/engine/step-runner.d.ts +24 -0
- package/dist/types/client/parser/blocks/use-parser.d.ts +2 -2
- package/dist/types/client/parser/duration.d.ts +1 -0
- package/dist/types/client/parser/layout-parser.d.ts +9 -0
- package/dist/types/client/parser/page-state-parser.d.ts +32 -0
- package/dist/types/client/parser/reaction-parser.d.ts +16 -0
- package/dist/types/client/parser/reaction-sugar.d.ts +13 -0
- package/dist/types/client/parser/step-parser.d.ts +23 -0
- package/dist/types/client/parser/ui-config-parser.d.ts +5 -0
- package/dist/types/client/parser/window-parser.d.ts +25 -0
- package/dist/types/client/theme/theme-engine.d.ts +26 -0
- package/dist/types/index.d.ts +35 -2
- package/dist/types/shared/block-errors.d.ts +5 -0
- package/dist/types/shared/calc/coerce.d.ts +4 -0
- package/dist/types/shared/calc/errors.d.ts +14 -0
- package/dist/types/shared/calc/evaluator.d.ts +2 -0
- package/dist/types/shared/calc/index.d.ts +6 -0
- package/dist/types/shared/calc/lexer.d.ts +20 -0
- package/dist/types/shared/calc/parser.d.ts +49 -0
- package/dist/types/shared/calc/typer.d.ts +16 -0
- package/dist/types/shared/component/derive-sample.d.ts +23 -0
- package/dist/types/shared/component/field-lines.d.ts +19 -0
- package/dist/types/shared/path-algebra.d.ts +56 -0
- package/dist/types/shared/predicates/index.d.ts +79 -0
- package/dist/types/shared/types/component-contract.types.d.ts +134 -6
- package/dist/types/shared/types/data-config.types.d.ts +115 -1
- package/dist/types/shared/types/domain.types.d.ts +12 -0
- package/dist/types/shared/types/event.types.d.ts +8 -2
- package/dist/types/shared/types/layout-constraint.types.d.ts +52 -0
- package/dist/types/shared/types/page-state.types.d.ts +49 -0
- package/dist/types/shared/types/reaction.types.d.ts +115 -0
- package/dist/types/shared/types/step.types.d.ts +76 -0
- package/dist/types/shared/types/ui-config.types.d.ts +18 -0
- package/dist/types/shared/types/window.types.d.ts +171 -0
- package/package.json +3 -2
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { SomaFieldPredicateOp } from '../predicates';
|
|
2
|
+
import type { SomaDataSubmitResult } from './data-config.types';
|
|
3
|
+
/**
|
|
4
|
+
* 过滤 AST:递归的 `join + conditions`,叶子复用谓词图的算子闭集。
|
|
5
|
+
*
|
|
6
|
+
* 复用而不是另立一套算子,是因为同一个「状态在已付/已发货里」的判断,在字段显隐
|
|
7
|
+
* (RG 的 `when`)与列表过滤(这里)上必须是同一个意思。两套算子表迟早会有一套先长出
|
|
8
|
+
* 第 13 个算子。
|
|
9
|
+
*/
|
|
10
|
+
export type SomaFilterNode = {
|
|
11
|
+
join: 'and' | 'or';
|
|
12
|
+
conditions: SomaFilterNode[];
|
|
13
|
+
} | {
|
|
14
|
+
field: string;
|
|
15
|
+
op: SomaFieldPredicateOp;
|
|
16
|
+
value?: unknown;
|
|
17
|
+
};
|
|
18
|
+
/** 排序意图:多列,声明序即优先级 */
|
|
19
|
+
export interface SomaWindowSort {
|
|
20
|
+
field: string;
|
|
21
|
+
order: 'asc' | 'desc';
|
|
22
|
+
}
|
|
23
|
+
/** 聚合函数闭集;`count` 之外都只对数值型字段(声明期配对) */
|
|
24
|
+
export declare const SOMA_AGGREGATE_FNS: readonly ["sum", "avg", "min", "max", "count"];
|
|
25
|
+
export type SomaAggregateFn = typeof SOMA_AGGREGATE_FNS[number];
|
|
26
|
+
export interface SomaWindowAggregate {
|
|
27
|
+
field: string;
|
|
28
|
+
fn: SomaAggregateFn;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 全选语义三档。
|
|
32
|
+
*
|
|
33
|
+
* `all` 与 `filtered` 的差别只在后端:前者是「库里所有行」,后者是「当前过滤条件命中的行」。
|
|
34
|
+
* 前端表现一样(都是 `base: 'all'`),但一个批量删除操作在这两档之间的差别是灾难性的,
|
|
35
|
+
* 所以它必须是显式声明,不能靠"当时有没有过滤条件"猜。
|
|
36
|
+
*/
|
|
37
|
+
export declare const SOMA_SELECT_ALL_MODES: readonly ["all", "filtered", "current_page"];
|
|
38
|
+
export type SomaSelectAllMode = typeof SOMA_SELECT_ALL_MODES[number];
|
|
39
|
+
/**
|
|
40
|
+
* 选择态:基线 + 反选集。
|
|
41
|
+
*
|
|
42
|
+
* 十万行里「全选后取消三行」,朴素做法要传九万九千九百九十七个 id。
|
|
43
|
+
* 记成 `{ base: 'all', toggled: [3 个] }` 之后载荷是 O(反选数) —— 这也是
|
|
44
|
+
* 后端唯一能高效解释的形状(它自己知道 `all` 是哪些行)。
|
|
45
|
+
*/
|
|
46
|
+
export interface SomaWindowSelection {
|
|
47
|
+
base: 'none' | 'all';
|
|
48
|
+
toggled: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface SomaWindowBlockConfig {
|
|
51
|
+
/** 一块多少行(SSRM cacheBlockSize 等价) */
|
|
52
|
+
size: number;
|
|
53
|
+
/** 最多缓存几块,超出按 LRU 淘汰;当前视口覆盖的块永不淘汰 */
|
|
54
|
+
max_blocks: number;
|
|
55
|
+
/** 合并快速滚动期间的中间块请求(毫秒) */
|
|
56
|
+
debounce_ms: number;
|
|
57
|
+
}
|
|
58
|
+
/** 解析产物:声明期已把所有缺省补齐、所有引用对着字典校验过 */
|
|
59
|
+
export interface SomaWindowConfig {
|
|
60
|
+
/** 只有服务端窗口。客户端窗口与「业务逻辑归后端」冲突,不做 */
|
|
61
|
+
mode: 'server';
|
|
62
|
+
block: SomaWindowBlockConfig;
|
|
63
|
+
sort: SomaWindowSort[];
|
|
64
|
+
filter: SomaFilterNode | null;
|
|
65
|
+
group: {
|
|
66
|
+
by: string[];
|
|
67
|
+
keys: string[];
|
|
68
|
+
} | null;
|
|
69
|
+
aggregate: SomaWindowAggregate[];
|
|
70
|
+
selection: SomaWindowSelection;
|
|
71
|
+
select_all: SomaSelectAllMode;
|
|
72
|
+
cache: {
|
|
73
|
+
ttl_ms: number | null;
|
|
74
|
+
keep_previous: boolean;
|
|
75
|
+
};
|
|
76
|
+
revalidate_ms: number | null;
|
|
77
|
+
/**
|
|
78
|
+
* 字段字典的稳定哈希(字段名 + 类型 + 权限)。
|
|
79
|
+
* 随请求下发,后端据此拒收「按一份它不认识的字典发来的意图」。
|
|
80
|
+
*/
|
|
81
|
+
dict_hash: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 请求体:**纯 JSON**(DW-2)。
|
|
85
|
+
*
|
|
86
|
+
* 这里不许出现函数、Set、Map、DOM 引用——它要能 `JSON.stringify` 往返相等,
|
|
87
|
+
* 因为它同时是网络载荷、缓存键和排障时贴进工单的那段文本。
|
|
88
|
+
*/
|
|
89
|
+
export interface SomaWindowRequest {
|
|
90
|
+
start: number;
|
|
91
|
+
end: number;
|
|
92
|
+
sort: SomaWindowSort[];
|
|
93
|
+
filter: SomaFilterNode | null;
|
|
94
|
+
group: {
|
|
95
|
+
by: string[];
|
|
96
|
+
keys: string[];
|
|
97
|
+
} | null;
|
|
98
|
+
aggregate: SomaWindowAggregate[];
|
|
99
|
+
dict_hash: string;
|
|
100
|
+
}
|
|
101
|
+
export interface SomaWindowResponse {
|
|
102
|
+
rows: unknown[];
|
|
103
|
+
/** 后端不知道总数时可省略:滚动条按「至少还有一块」的语义给初值 */
|
|
104
|
+
total?: number;
|
|
105
|
+
group_info?: Record<string, unknown>;
|
|
106
|
+
grand_total?: Record<string, unknown>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 写通道事务体(对齐 AG Grid ServerSideTransaction)。
|
|
110
|
+
* 一次提交是一个 patch 集,不是一个对象——批量编辑的天然形状。
|
|
111
|
+
*/
|
|
112
|
+
export interface SomaTransaction {
|
|
113
|
+
/** 分组路径:改的是哪一层的行 */
|
|
114
|
+
route?: string[];
|
|
115
|
+
add?: Array<Record<string, unknown>>;
|
|
116
|
+
remove?: Array<Record<string, unknown>>;
|
|
117
|
+
update?: Array<Record<string, unknown>>;
|
|
118
|
+
}
|
|
119
|
+
/** 组件消费面:自治组件与受控组件都只认这一个把手 */
|
|
120
|
+
export interface SomaWindowHandle {
|
|
121
|
+
readonly spec: SomaWindowConfig;
|
|
122
|
+
/** 展示值:已提交值 ⊕ 未提交编辑(pending) */
|
|
123
|
+
readonly rows: readonly unknown[];
|
|
124
|
+
readonly total: number | undefined;
|
|
125
|
+
readonly selection: SomaWindowSelection;
|
|
126
|
+
readonly loading: boolean;
|
|
127
|
+
readonly error: string;
|
|
128
|
+
/** 当前缓存块数(DW-6 的观测面) */
|
|
129
|
+
readonly blockCount: number;
|
|
130
|
+
/** 当前视口 [start, end):`rows` 就是这一段;受控组件按 `start` 还原真实行号 */
|
|
131
|
+
readonly start: number;
|
|
132
|
+
readonly end: number;
|
|
133
|
+
/** 当前生效的排序 / 过滤意图(声明起步,之后随 request(patch) 改写) */
|
|
134
|
+
readonly sort: SomaWindowSort[];
|
|
135
|
+
readonly filter: SomaFilterNode | null;
|
|
136
|
+
/** 改意图或挪视口;改 sort/filter/group/aggregate 任一项都会清空缓存并回到第 0 行 */
|
|
137
|
+
request(patch: SomaWindowRequestPatch): Promise<void>;
|
|
138
|
+
/** 翻转选择:`toggle` 逐个翻,`base` 换基线并清空反选集 */
|
|
139
|
+
select(patch: {
|
|
140
|
+
toggle?: string[];
|
|
141
|
+
base?: 'none' | 'all';
|
|
142
|
+
}): void;
|
|
143
|
+
isSelected(id: string): boolean;
|
|
144
|
+
/** 未提交的单元格编辑(受控编辑:组件只发意图,不写数据) */
|
|
145
|
+
edit(id: string, field: string, value: unknown): void;
|
|
146
|
+
readonly pendingCount: number;
|
|
147
|
+
commit(tx?: SomaTransaction): Promise<SomaDataSubmitResult>;
|
|
148
|
+
savepoint(): number;
|
|
149
|
+
revertTo(id: number): void;
|
|
150
|
+
/**
|
|
151
|
+
* 分组下钻(F-33):展开到 `keys` 这一层,拿它自己的窗口。
|
|
152
|
+
* 没声明 `group:` 段、或路径比分组层数还深时返回 null。
|
|
153
|
+
* 子窗口继承父的排序与过滤,**不继承**选择态。
|
|
154
|
+
*/
|
|
155
|
+
drillDown(keys: readonly string[]): SomaWindowHandle | null;
|
|
156
|
+
/** 已展开的子窗口路径(诊断用) */
|
|
157
|
+
readonly childPaths: string[];
|
|
158
|
+
/** 对象级 reload 时销毁(连同子分组窗口) */
|
|
159
|
+
destroy(): void;
|
|
160
|
+
}
|
|
161
|
+
export interface SomaWindowRequestPatch {
|
|
162
|
+
start?: number;
|
|
163
|
+
end?: number;
|
|
164
|
+
sort?: SomaWindowSort[];
|
|
165
|
+
filter?: SomaFilterNode | null;
|
|
166
|
+
group?: {
|
|
167
|
+
by: string[];
|
|
168
|
+
keys: string[];
|
|
169
|
+
} | null;
|
|
170
|
+
aggregate?: SomaWindowAggregate[];
|
|
171
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soma-core",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "SOMA — Semantic Oriented Modular Architecture. A declarative frontend framework runtime built on Next.js 16 App Router.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"soma",
|
|
@@ -157,13 +157,14 @@
|
|
|
157
157
|
"@vitest/coverage-v8": "^3.2.7",
|
|
158
158
|
"ajv-formats": "3.0.1",
|
|
159
159
|
"esbuild": "^0.25.12",
|
|
160
|
-
"js-yaml": "^4.3.
|
|
160
|
+
"js-yaml": "^4.3.2",
|
|
161
161
|
"jsdom": "^26.1.0",
|
|
162
162
|
"next": "16.3.1",
|
|
163
163
|
"playwright": "^1.62.1",
|
|
164
164
|
"react": "^18.3.0",
|
|
165
165
|
"react-dom": "^18.3.0",
|
|
166
166
|
"semver": "^7.8.5",
|
|
167
|
+
"tsx": "^4.23.13",
|
|
167
168
|
"typescript": "^5.3.3",
|
|
168
169
|
"vite": "6.4.3",
|
|
169
170
|
"vitest": "^3.2.7",
|