e10-data 0.1.7 → 0.1.8
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 +38 -0
- package/bin/e10-data.mjs +39 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,44 @@ e10-data attend statis # 查当前登录用户当月假
|
|
|
53
53
|
e10-data attend statis --user 6264843388578732287 --begin 2026-09-01 --end 2026-09-30
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
## ds --where 过滤条件(v0.1.8 起支持树形 OR)
|
|
57
|
+
|
|
58
|
+
`e10-data ds list|chart|stat|count --where` 接收**条件数组**或**完整条件树**,均可递归嵌套表达 AND/OR:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# ① 数组 = AND 根(旧写法,行为不变):满足全部条件的记录
|
|
62
|
+
e10-data ds count --group <gid> --table <tid> \
|
|
63
|
+
--where '[{"fieldId":"fieldA","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"fieldB","compareType":"eq","conditionValue":"1"}]'
|
|
64
|
+
|
|
65
|
+
# ② 对象 = 完整条件树:relationship "0"=OR、"1"=AND(缺省 AND),conditionList 内可再嵌套条件组
|
|
66
|
+
e10-data ds count --group <gid> --table <tid> \
|
|
67
|
+
--where '{"relationship":"0","conditionList":[{"fieldId":"fieldA","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"fieldB","compareType":"range","conditionValue":"2026-09~2026-10"}]}'
|
|
68
|
+
|
|
69
|
+
# ③ 数组元素内嵌条件组 → 复杂组合,如 (A AND B) OR (C AND D)
|
|
70
|
+
e10-data ds list --group <gid> --table <tid> --fields a,b \
|
|
71
|
+
--where @cond.json # 内容见下
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
// cond.json —— 组合条件示例
|
|
76
|
+
[
|
|
77
|
+
{ "relationship": "1", "conditionList": [
|
|
78
|
+
{ "fieldId": "A", "compareType": "eq", "conditionValue": "x" },
|
|
79
|
+
{ "fieldId": "B", "compareType": "eq", "conditionValue": "y" } ] },
|
|
80
|
+
{ "relationship": "0", "conditionList": [
|
|
81
|
+
{ "fieldId": "C", "compareType": "eq", "conditionValue": "m" },
|
|
82
|
+
{ "fieldId": "D", "compareType": "eq", "conditionValue": "n" } ] }
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
要点:
|
|
87
|
+
|
|
88
|
+
- **叶子字段键**:`fieldId` 与 `conditionId` 均可(fieldId 优先),旧树形 `conditionId` 写法兼容;
|
|
89
|
+
- **relationship**:`"0"`/`0`/`false` = OR,其余 = AND;子节点关系作用于其自身 `conditionList`;
|
|
90
|
+
- 数组顶层恒为 AND 根,需要整体 OR 请用对象形态 `{"relationship":"0","conditionList":[...]}`;
|
|
91
|
+
- 叶子缺少字段会**直接报错**(v0.1.8 起,不再静默产生空条件导致误返回全表);
|
|
92
|
+
- 其余条件属性(conditionType/compareType/conditionValue/objId/mainField/ignoreCaseMark 等)照旧透传。
|
|
93
|
+
|
|
56
94
|
## exp pull 智能拉取(v0.1.4 新增,防本地修改被覆盖)`exp pull` 不再盲目覆盖。CLI 在专家包本地目录维护基线文件 `.sync-state.json`(记录上次同步的 commitId/headRevision 与每文件 sha256),拉取时逐文件三方对比:
|
|
57
95
|
|
|
58
96
|
| 场景 | 判定 | 处理 |
|
package/bin/e10-data.mjs
CHANGED
|
@@ -321,21 +321,43 @@ function dyn() {
|
|
|
321
321
|
function baseDto(tableId, groupId, pageNo, pageSize, queryType) {
|
|
322
322
|
return { tableId: String(tableId), groupId, pageNo, pageSize, queryType, containDetailTable: false, needFormat: true, dynamicParams: dyn() };
|
|
323
323
|
}
|
|
324
|
+
// 条件树(conditionTrees)协议:根/组节点 { key, relationship("1"=AND|"0"=OR), isParent:true, parentNode, conditionList:[...] }
|
|
325
|
+
// 叶子节点 { key, relationship:"1", isParent:false, parentNode, conditionId, conditionType, compareType, conditionValue, ... }
|
|
326
|
+
// v0.1.8 起 parseWhere 支持递归树(OR);向后兼容:数组=AND 根、叶子键 fieldId 优先(conditionId 兼容兜底)
|
|
327
|
+
function normRel(r) { return (r === "0" || r === 0 || r === false) ? "0" : "1"; }
|
|
328
|
+
function isCondGroup(c) { return !!c && Array.isArray(c.conditionList) && c.conditionList.length > 0; }
|
|
329
|
+
function buildCondNode(c, key, parentKey) {
|
|
330
|
+
if (isCondGroup(c)) {
|
|
331
|
+
return {
|
|
332
|
+
key, relationship: normRel(c.relationship), isParent: true, parentNode: parentKey,
|
|
333
|
+
mainField: c.mainField !== false,
|
|
334
|
+
conditionList: c.conditionList.map((k, i) => buildCondNode(k, key + "_" + i, key)),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
const fid = (c && (c.fieldId || c.conditionId)) || "";
|
|
338
|
+
if (!fid) throw new Error("--where 条件缺少字段:叶子须提供 fieldId(或 conditionId),条件组须提供非空 conditionList");
|
|
339
|
+
return {
|
|
340
|
+
key, relationship: "1", isParent: false, parentNode: parentKey,
|
|
341
|
+
objId: c.objId || "", conditionId: fid, fieldName: c.fieldName || fid,
|
|
342
|
+
conditionType: c.conditionType || "", compareType: c.compareType, conditionValue: c.conditionValue ?? "",
|
|
343
|
+
fieldValue: c.fieldValue || "", mainField: c.mainField !== false, ignoreCaseMark: c.ignoreCaseMark || false,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
324
346
|
function parseWhere(val) {
|
|
325
347
|
if (!val) return null;
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
if (!list.length) return null;
|
|
348
|
+
const raw = readJsonArg(val, "--where");
|
|
349
|
+
if (!raw) return null;
|
|
329
350
|
const ts = Date.now(), rootKey = "root_" + ts;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
351
|
+
if (Array.isArray(raw)) { // 数组 → AND 根(元素可为叶子或内嵌条件组,组自带 relationship)
|
|
352
|
+
const kids = [];
|
|
353
|
+
raw.forEach((c, i) => { if (c && typeof c === "object") kids.push(buildCondNode(c, rootKey + "_" + i, rootKey)); });
|
|
354
|
+
if (!kids.length) return null;
|
|
355
|
+
return { key: rootKey, relationship: "1", isParent: true, parentNode: "", mainField: true, conditionList: kids };
|
|
356
|
+
}
|
|
357
|
+
if (typeof raw !== "object") throw new Error("--where 须为条件数组或条件树对象");
|
|
358
|
+
// 对象形态 = 完整条件树({relationship, conditionList:[...]},缺省 AND);无 conditionList 视为无条件
|
|
359
|
+
if (!Array.isArray(raw.conditionList) || !raw.conditionList.length) return null;
|
|
360
|
+
return buildCondNode(raw, rootKey, "");
|
|
339
361
|
}
|
|
340
362
|
function parseStat(val) {
|
|
341
363
|
const arr = readJsonArg(val, "--stat");
|
|
@@ -1133,6 +1155,11 @@ ds 数据源(业务模块)取数与元数据
|
|
|
1133
1155
|
ds stat --group <gid> --table <tid> --stat '[...]' [--where ...]
|
|
1134
1156
|
ds count --group <gid> --table <tid> [--where ...]
|
|
1135
1157
|
(ds 通用 --source-type LOGIC|ETEAMS,默认 LOGIC)
|
|
1158
|
+
--where 过滤条件(v0.1.8 起支持树形 OR,递归):
|
|
1159
|
+
数组 = AND 根: [{"fieldId":"f1","conditionType":"Date","compareType":"range","conditionValue":"2026-09~2026-10"},{"fieldId":"f2",...}]
|
|
1160
|
+
对象 = 完整树: {"relationship":"0","conditionList":[{"fieldId":"f1",...},{"fieldId":"f2",...}]} # "0"=OR、"1"=AND,缺省 AND
|
|
1161
|
+
数组元素可内嵌条件组 {"relationship":"0","conditionList":[...]} 实现 (A AND B) OR (C AND D)
|
|
1162
|
+
叶子键 fieldId/conditionId 均可(fieldId 优先);缺少字段的叶子会直接报错(不再静默当全表)
|
|
1136
1163
|
doc 文档查询
|
|
1137
1164
|
doc count [--name 关键词] [--creator id1,id2] [--author id1,id2] [--content-type office] [--time "起~止"] [--last-time "起~止"] [--folder id,id|--folder-neq id,id]
|
|
1138
1165
|
doc list [同上条件] [--all 翻页到底] [--page N] [--size 100]
|
package/package.json
CHANGED