@scx-js/scx-data 0.2.4 → 0.3.0
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/LICENSE +21 -0
- package/README.md +20 -0
- package/field_policy/AssignField.js +3 -3
- package/field_policy/FieldPolicy.js +6 -0
- package/field_policy/FieldPolicyBuilder.js +16 -3
- package/field_policy/FieldPolicyImpl.js +54 -17
- package/field_policy/FilterMode.js +20 -3
- package/field_policy/VirtualField.js +3 -3
- package/index.js +8 -7
- package/package.json +3 -6
- package/query/And.js +2 -2
- package/query/BuildControl.js +27 -4
- package/query/Condition.js +6 -10
- package/query/ConditionType.js +29 -70
- package/query/Junction.js +35 -27
- package/query/Not.js +1 -0
- package/query/Or.js +2 -2
- package/query/OrderBy.js +5 -7
- package/query/OrderByType.js +16 -2
- package/query/QueryBuilder.js +36 -18
- package/query/QueryImpl.js +39 -19
- package/query/QueryLike.js +7 -1
- package/query/SkipIfInfo.js +21 -28
- package/query/WhereClause.js +1 -5
- package/x/FieldPolicyNodeConverter.js +73 -0
- package/x/QueryNodeConverter.js +163 -0
- package/serialization/FieldPolicySerializer.js +0 -47
- package/serialization/QuerySerializer.js +0 -120
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {WhereClause} from "../query/WhereClause.js";
|
|
2
|
-
import {And} from "../query/And.js";
|
|
3
|
-
import {Or} from "../query/Or.js";
|
|
4
|
-
import {Not} from "../query/Not.js";
|
|
5
|
-
import {Condition} from "../query/Condition.js";
|
|
6
|
-
|
|
7
|
-
function serializeQueryToJson(query) {
|
|
8
|
-
return JSON.stringify(serializeQuery(query));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function serializeQuery(query) {
|
|
12
|
-
return {
|
|
13
|
-
"@type": "Query",
|
|
14
|
-
where: serializeWhere(query.getWhere()),
|
|
15
|
-
orderBys: serializeOrderBys(query.getOrderBys()),
|
|
16
|
-
offset: query.getOffset(),
|
|
17
|
-
limit: query.getLimit(),
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function serializeWhere(obj) {
|
|
22
|
-
if (!obj) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (obj instanceof WhereClause) {
|
|
27
|
-
return serializeWhereClause(obj);
|
|
28
|
-
}
|
|
29
|
-
if (obj instanceof And) {
|
|
30
|
-
return serializeAnd(obj);
|
|
31
|
-
}
|
|
32
|
-
if (obj instanceof Or) {
|
|
33
|
-
return serializeOr(obj);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (obj instanceof Not) {
|
|
37
|
-
return serializeNot(obj);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (obj instanceof Condition) {
|
|
41
|
-
return serializeCondition(obj);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
throw new Error(`Unknown Where type: ${obj}`);
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function serializeWhereClause(w) {
|
|
49
|
-
return {
|
|
50
|
-
"@type": "WhereClause",
|
|
51
|
-
expression: w.expression(),
|
|
52
|
-
params: w.params(),
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function serializeAnd(a) {
|
|
57
|
-
return {
|
|
58
|
-
"@type": "And",
|
|
59
|
-
clauses: serializeWhereAll(a.clauses()),
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function serializeOr(o) {
|
|
64
|
-
return {
|
|
65
|
-
"@type": "Or",
|
|
66
|
-
clauses: serializeWhereAll(o.clauses()),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function serializeNot(n) {
|
|
71
|
-
return {
|
|
72
|
-
"@type": "Not",
|
|
73
|
-
clause: serializeWhere(n.clause()),
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function serializeCondition(w) {
|
|
78
|
-
return {
|
|
79
|
-
"@type": "Condition",
|
|
80
|
-
selector: w.selector(),
|
|
81
|
-
conditionType: w.conditionType(),
|
|
82
|
-
value1: w.value1(),
|
|
83
|
-
value2: w.value2(),
|
|
84
|
-
useExpression: w.useExpression(),
|
|
85
|
-
useExpressionValue: w.useExpressionValue(),
|
|
86
|
-
skipIfInfo: serializeSkipIfInfo(w.skipIfInfo()),
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function serializeWhereAll(objs) {
|
|
91
|
-
return objs.map(obj => serializeWhere(obj));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function serializeOrderBys(objs) {
|
|
95
|
-
return objs.map(obj => serializeOrderBy(obj));
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function serializeOrderBy(orderBy) {
|
|
99
|
-
return {
|
|
100
|
-
"@type": "OrderBy",
|
|
101
|
-
selector: orderBy.selector(),
|
|
102
|
-
orderByType: orderBy.orderByType(),
|
|
103
|
-
useExpression: orderBy.useExpression(),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function serializeSkipIfInfo(info) {
|
|
108
|
-
return {
|
|
109
|
-
"@type": "SkipIfInfo",
|
|
110
|
-
skipIfNull: info.skipIfNull,
|
|
111
|
-
skipIfEmptyList: info.skipIfEmptyList,
|
|
112
|
-
skipIfEmptyString: info.skipIfEmptyString,
|
|
113
|
-
skipIfBlankString: info.skipIfBlankString,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export {
|
|
118
|
-
serializeQueryToJson,
|
|
119
|
-
serializeQuery,
|
|
120
|
-
};
|