ccd16bf956
Node.js Build / build (push) Has been skipped
- 基于 grill-me Q1-Q61 决策 - Vitest 测试与 CI workflow - middleware: parseFilters 核心实现 - component: Vue3 TransForm 基础组件 + Storybook Co-authored-by: Cursor <cursoragent@cursor.com>
1.5 KiB
1.5 KiB
trans-form-middleware — Design (Q1–Q61)
Status: implementation scaffold (v0.1.0)
Companion package: @windychen/trans-form-component (Vue 3 dynamic query form).
Role
Receive component filter output → structured { field, query, op, value, logic?, values?, empty? }[]. No SQL generation.
Key decisions
| # | Decision |
|---|---|
| 1–2 | Node.js pure JS; structured filters only |
| 8 | Dual fields: query (code) + op (symbol) |
| 14 | mode: pass-through (default) / flat / tree |
| 24–25 | Zero deps; ESM only; no bundling (src/index.js) |
| 38 | empty: true preserved by default |
| 39 | Built-in DEFAULT_OPERATOR_MAP, merge via operatorMap |
| 41 | Multi-function exports: parseFilters, toTree, mapOperators, … |
| 44 | strict default false |
| 46 | Multi-value: value (string) + values (parsed array) |
| 49–50 | allowedFields required; unknownField: 'error' default |
| 60 | Component emits all state flags; middleware skips disabled by default |
| 61 | Also skips hidden; skipEmpty option controls empty items |
Output example
[
{
"field": "tags",
"query": "IN",
"op": "IN",
"value": "a,b,c",
"values": ["a", "b", "c"],
"logic": "OR"
}
]
Operator map
EQ→=, NE→<>, GT→>, GTE→>=, LT→<, LTE→<=, LIKE→LIKE, IN→IN, NOT_IN→NOT IN, BETWEEN→BETWEEN, IS_NULL→IS NULL, IS_NOT_NULL→IS NOT NULL
CI
Copy of windychen-utils pattern: commit message must contain chore + 版本 + 更新 to trigger publish.