oak-domain 3.0.3 → 3.0.4
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/lib/actions/action.d.ts +8 -8
- package/lib/actions/action.js +2 -2
- package/lib/actions/relation.d.ts +1 -1
- package/lib/actions/relation.js +9 -22
- package/lib/base-app-domain/ActionAuth/Schema.d.ts +68 -42
- package/lib/base-app-domain/ActionAuth/Storage.js +12 -15
- package/lib/base-app-domain/ActionDefDict.d.ts +2 -3
- package/lib/base-app-domain/ActionDefDict.js +3 -5
- package/lib/base-app-domain/EntityDict.d.ts +5 -1
- package/lib/base-app-domain/I18n/Schema.d.ts +24 -24
- package/lib/base-app-domain/I18n/Storage.js +5 -5
- package/lib/base-app-domain/Modi/Action.d.ts +4 -4
- package/lib/base-app-domain/Modi/Action.js +3 -3
- package/lib/base-app-domain/Modi/Schema.d.ts +24 -24
- package/lib/base-app-domain/Modi/Storage.js +3 -3
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +128 -55
- package/lib/base-app-domain/ModiEntity/Storage.js +2 -2
- package/lib/base-app-domain/Oper/Schema.d.ts +30 -29
- package/lib/base-app-domain/Oper/Storage.js +1 -1
- package/lib/base-app-domain/OperEntity/Schema.d.ts +126 -53
- package/lib/base-app-domain/OperEntity/Storage.js +2 -2
- package/lib/base-app-domain/Path/Schema.d.ts +149 -0
- package/lib/base-app-domain/Path/Schema.js +2 -0
- package/lib/base-app-domain/Path/Storage.d.ts +3 -0
- package/lib/base-app-domain/Path/Storage.js +54 -0
- package/lib/base-app-domain/Relation/Schema.d.ts +34 -34
- package/lib/base-app-domain/Relation/Storage.js +6 -6
- package/lib/base-app-domain/Relation.d.ts +0 -8
- package/lib/base-app-domain/Relation.js +1 -7
- package/lib/base-app-domain/RelationAuth/Schema.d.ts +74 -40
- package/lib/base-app-domain/RelationAuth/Storage.js +9 -11
- package/lib/base-app-domain/Storage.js +20 -16
- package/lib/base-app-domain/User/Action.d.ts +4 -4
- package/lib/base-app-domain/User/Action.js +3 -3
- package/lib/base-app-domain/User/Schema.d.ts +40 -27
- package/lib/base-app-domain/User/Storage.js +1 -1
- package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +264 -0
- package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -0
- package/lib/base-app-domain/UserEntityClaim/Storage.d.ts +3 -0
- package/lib/base-app-domain/UserEntityClaim/Storage.js +37 -0
- package/lib/base-app-domain/UserEntityGrant/Action.d.ts +2 -2
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +55 -81
- package/lib/base-app-domain/UserEntityGrant/Storage.js +7 -11
- package/lib/base-app-domain/UserRelation/Schema.d.ts +50 -36
- package/lib/base-app-domain/UserRelation/Storage.js +7 -7
- package/lib/base-app-domain/_SubQuery.d.ts +45 -15
- package/lib/base-app-domain/index.js +1 -1
- package/lib/checkers/index.js +6 -7
- package/lib/compiler/env.js +16 -18
- package/lib/compiler/localeBuilder.js +83 -79
- package/lib/compiler/schemalBuilder.d.ts +16 -0
- package/lib/compiler/schemalBuilder.js +1160 -1378
- package/lib/entities/ActionAuth.d.ts +3 -5
- package/lib/entities/ActionAuth.js +9 -7
- package/lib/entities/I18n.js +1 -1
- package/lib/entities/Modi.js +2 -2
- package/lib/entities/ModiEntity.js +1 -1
- package/lib/entities/Oper.js +1 -1
- package/lib/entities/OperEntity.js +1 -1
- package/lib/entities/Path.d.ts +8 -0
- package/lib/entities/Path.js +35 -0
- package/lib/entities/Relation.js +1 -1
- package/lib/entities/RelationAuth.d.ts +2 -2
- package/lib/entities/RelationAuth.js +1 -1
- package/lib/entities/User.js +2 -2
- package/lib/entities/UserEntityClaim.d.ts +13 -0
- package/lib/entities/UserEntityClaim.js +17 -0
- package/lib/entities/UserEntityGrant.d.ts +5 -4
- package/lib/entities/UserEntityGrant.js +4 -7
- package/lib/entities/UserRelation.js +1 -1
- package/lib/index.d.ts +23 -0
- package/lib/index.js +37 -0
- package/lib/store/AsyncRowStore.d.ts +2 -1
- package/lib/store/AsyncRowStore.js +75 -149
- package/lib/store/CascadeStore.js +917 -1291
- package/lib/store/RelationAuth.d.ts +9 -16
- package/lib/store/RelationAuth.js +750 -908
- package/lib/store/SyncRowStore.d.ts +1 -1
- package/lib/store/SyncRowStore.js +27 -26
- package/lib/store/TriggerExecutor.d.ts +17 -10
- package/lib/store/TriggerExecutor.js +350 -423
- package/lib/store/actionAuth.js +13 -28
- package/lib/store/actionDef.js +118 -193
- package/lib/store/checker.js +225 -361
- package/lib/store/filter.d.ts +2 -3
- package/lib/store/filter.js +451 -589
- package/lib/store/modi.js +116 -177
- package/lib/store/relation.js +17 -17
- package/lib/timers/oper.d.ts +1 -1
- package/lib/timers/oper.js +44 -47
- package/lib/timers/vaccum.d.ts +2 -2
- package/lib/timers/vaccum.js +100 -165
- package/lib/triggers/index.js +1 -1
- package/lib/types/Action.d.ts +7 -7
- package/lib/types/AppLoader.d.ts +8 -2
- package/lib/types/AppLoader.js +4 -4
- package/lib/types/Aspect.d.ts +1 -3
- package/lib/types/Auth.d.ts +15 -19
- package/lib/types/Connector.d.ts +19 -15
- package/lib/types/Connector.js +0 -7
- package/lib/types/DataType.d.ts +19 -18
- package/lib/types/DataType.js +1 -1
- package/lib/types/Demand.d.ts +25 -25
- package/lib/types/Endpoint.d.ts +1 -1
- package/lib/types/Entity.d.ts +57 -53
- package/lib/types/Entity.js +3 -3
- package/lib/types/EntityDesc.d.ts +2 -1
- package/lib/types/Environment.d.ts +4 -4
- package/lib/types/Exception.d.ts +29 -2
- package/lib/types/Exception.js +205 -205
- package/lib/types/Expression.d.ts +14 -14
- package/lib/types/Expression.js +54 -87
- package/lib/types/Geo.d.ts +6 -6
- package/lib/types/Locale.d.ts +5 -5
- package/lib/types/Polyfill.d.ts +9 -9
- package/lib/types/Port.d.ts +4 -4
- package/lib/types/RowStore.d.ts +3 -3
- package/lib/types/RowStore.js +18 -19
- package/lib/types/Storage.d.ts +5 -4
- package/lib/types/Style.d.ts +2 -2
- package/lib/types/Timer.d.ts +3 -3
- package/lib/types/Trigger.d.ts +30 -14
- package/lib/types/Trigger.js +6 -2
- package/lib/types/Watcher.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -1
- package/lib/types/schema/DataTypes.d.ts +7 -7
- package/lib/utils/SimpleConnector.d.ts +24 -10
- package/lib/utils/SimpleConnector.js +166 -144
- package/lib/utils/assert.js +2 -2
- package/lib/utils/concurrent.d.ts +1 -1
- package/lib/utils/concurrent.js +31 -57
- package/lib/utils/date.js +2 -2
- package/lib/utils/geo.js +8 -8
- package/lib/utils/lodash.d.ts +3 -1
- package/lib/utils/lodash.js +21 -34
- package/lib/utils/mask.js +12 -13
- package/lib/utils/money.d.ts +1 -1
- package/lib/utils/money.js +22 -11
- package/lib/utils/projection.d.ts +4 -0
- package/lib/utils/projection.js +15 -0
- package/lib/utils/random/random.js +11 -16
- package/lib/utils/random/random.mp.js +7 -18
- package/lib/utils/random/random.web.js +6 -12
- package/lib/utils/string.d.ts +4 -4
- package/lib/utils/string.js +19 -32
- package/lib/utils/url.js +5 -4
- package/lib/utils/uuid.d.ts +1 -1
- package/lib/utils/uuid.js +46 -85
- package/lib/utils/validator.d.ts +4 -3
- package/lib/utils/validator.js +35 -32
- package/lib/utils/version.js +6 -6
- package/package.json +7 -7
- package/src/entities/ActionAuth.ts +10 -10
- package/src/entities/Path.ts +43 -0
- package/src/entities/RelationAuth.ts +2 -1
- package/src/entities/UserEntityClaim.ts +30 -0
- package/src/entities/UserEntityGrant.ts +9 -12
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RefAttr } from "./Demand";
|
|
2
2
|
import { Geo } from "./Geo";
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export type RefOrExpression<A> = RefAttr<A> | Expression<A>;
|
|
4
|
+
type MathType<A> = RefOrExpression<A> | number;
|
|
5
|
+
type StringType<A> = RefOrExpression<A> | string;
|
|
6
6
|
interface Add<A> {
|
|
7
7
|
$add: (MathType<A>)[];
|
|
8
8
|
}
|
|
@@ -30,8 +30,8 @@ interface Ceil<A> {
|
|
|
30
30
|
interface Pow<A> {
|
|
31
31
|
$pow: [MathType<A>, MathType<A>];
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
type MathExpression<A> = Add<A> | Subtract<A> | Multiply<A> | Divide<A> | Abs<A> | Round<A> | Floor<A> | Ceil<A> | Pow<A>;
|
|
34
|
+
type CmpType<A> = RefOrExpression<A> | string | number;
|
|
35
35
|
interface Gt<A> {
|
|
36
36
|
$gt: [CmpType<A>, CmpType<A>];
|
|
37
37
|
}
|
|
@@ -59,14 +59,14 @@ interface EndsWith<A> {
|
|
|
59
59
|
interface Includes<A> {
|
|
60
60
|
$includes: [RefOrExpression<A> | string, RefOrExpression<A> | string];
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
type CompareExpression<A> = Lt<A> | Gt<A> | Lte<A> | Gte<A> | Eq<A> | Ne<A> | StartsWith<A> | EndsWith<A> | Includes<A>;
|
|
63
63
|
interface BoolTrue<A> {
|
|
64
64
|
$true: Expression<A>;
|
|
65
65
|
}
|
|
66
66
|
interface BoolFalse<A> {
|
|
67
67
|
$false: Expression<A>;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
type BoolExpression<A> = BoolTrue<A> | BoolFalse<A>;
|
|
70
70
|
interface LogicAnd<A> {
|
|
71
71
|
$and: Expression<A>[];
|
|
72
72
|
}
|
|
@@ -76,7 +76,7 @@ interface LogicOr<A> {
|
|
|
76
76
|
interface LogicNot<A> {
|
|
77
77
|
$not: Expression<A>;
|
|
78
78
|
}
|
|
79
|
-
|
|
79
|
+
type LogicExpression<A> = LogicAnd<A> | LogicOr<A> | LogicNot<A>;
|
|
80
80
|
interface DateYear<A> {
|
|
81
81
|
$year: RefOrExpression<A> | Date | number;
|
|
82
82
|
}
|
|
@@ -110,18 +110,18 @@ interface DateCeiling<A> {
|
|
|
110
110
|
interface DateFloor<A> {
|
|
111
111
|
$dateFloor: [RefOrExpression<A> | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's'];
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
type DateExpression<A> = DateYear<A> | DateMonth<A> | DateWeekday<A> | DateWeekOfYear<A> | DateDay<A> | DateDayOfYear<A> | DateDayOfMonth<A> | DateDayOfWeek<A> | DateDiff<A> | DateCeiling<A> | DateFloor<A>;
|
|
114
114
|
interface StringConcat<A> {
|
|
115
115
|
$concat: StringType<A>[];
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
type StringExpression<A> = StringConcat<A>;
|
|
118
118
|
interface GeoContains<A> {
|
|
119
119
|
$contains: [RefOrExpression<A> | Geo, RefOrExpression<A> | Geo];
|
|
120
120
|
}
|
|
121
121
|
interface GeoDistance<A> {
|
|
122
122
|
$distance: [RefOrExpression<A> | Geo, RefOrExpression<A> | Geo];
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
type GeoExpression<A> = GeoContains<A> | GeoDistance<A>;
|
|
125
125
|
interface AggrCountExpression<A> {
|
|
126
126
|
$$count: RefOrExpression<A>;
|
|
127
127
|
}
|
|
@@ -137,9 +137,9 @@ interface AggrMinExpression<A> {
|
|
|
137
137
|
interface AggrAvgExpression<A> {
|
|
138
138
|
$$avg: RefOrExpression<A>;
|
|
139
139
|
}
|
|
140
|
-
export
|
|
141
|
-
export
|
|
142
|
-
export
|
|
140
|
+
export type AggrExpression<A> = AggrAvgExpression<A> | AggrCountExpression<A> | AggrSumExpression<A> | AggrMaxExpression<A> | AggrMinExpression<A>;
|
|
141
|
+
export type Expression<A> = GeoExpression<A> | DateExpression<A> | LogicExpression<A> | BoolExpression<A> | CompareExpression<A> | MathExpression<A> | StringExpression<A>;
|
|
142
|
+
export type ExpressionConstant = Geo | number | Date | string | boolean;
|
|
143
143
|
export declare function isGeoExpression<A>(expression: any): expression is GeoExpression<A>;
|
|
144
144
|
export declare function isDateExpression<A>(expression: any): expression is DateExpression<A>;
|
|
145
145
|
export declare function isLogicExpression<A>(expression: any): expression is LogicExpression<A>;
|
package/lib/types/Expression.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAttrRefInExpression = exports.execOp = exports.opMultipleParams = exports.isExpression = exports.isAggrExpression = exports.isStringExpression = exports.isMathExpression = exports.isCompareExpression = exports.isBoolExpression = exports.isLogicExpression = exports.isDateExpression = exports.isGeoExpression = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
7
|
+
const weekOfYear_1 = tslib_1.__importDefault(require("dayjs/plugin/weekOfYear"));
|
|
8
|
+
const dayOfYear_1 = tslib_1.__importDefault(require("dayjs/plugin/dayOfYear"));
|
|
9
|
+
const geo_1 = require("../utils/geo");
|
|
10
10
|
dayjs_1.default.extend(weekOfYear_1.default);
|
|
11
11
|
dayjs_1.default.extend(dayOfYear_1.default);
|
|
12
12
|
;
|
|
@@ -45,7 +45,7 @@ dayjs_1.default.extend(dayOfYear_1.default);
|
|
|
45
45
|
;
|
|
46
46
|
function isGeoExpression(expression) {
|
|
47
47
|
if (Object.keys(expression).length == 1) {
|
|
48
|
-
|
|
48
|
+
const op = Object.keys(expression)[0];
|
|
49
49
|
if (['$contains', '$distance'].includes(op)) {
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
@@ -55,7 +55,7 @@ function isGeoExpression(expression) {
|
|
|
55
55
|
exports.isGeoExpression = isGeoExpression;
|
|
56
56
|
function isDateExpression(expression) {
|
|
57
57
|
if (Object.keys(expression).length == 1) {
|
|
58
|
-
|
|
58
|
+
const op = Object.keys(expression)[0];
|
|
59
59
|
if (['$year', '$month', '$weekday', '$weekOfYear', '$day', '$dayOfMonth',
|
|
60
60
|
'$dayOfWeek', '$dayOfYear', '$dateDiff', '$dateCeil', '$dateFloor'].includes(op)) {
|
|
61
61
|
return true;
|
|
@@ -66,7 +66,7 @@ function isDateExpression(expression) {
|
|
|
66
66
|
exports.isDateExpression = isDateExpression;
|
|
67
67
|
function isLogicExpression(expression) {
|
|
68
68
|
if (Object.keys(expression).length == 1) {
|
|
69
|
-
|
|
69
|
+
const op = Object.keys(expression)[0];
|
|
70
70
|
if (['$and', '$or', '$not'].includes(op)) {
|
|
71
71
|
return true;
|
|
72
72
|
}
|
|
@@ -76,7 +76,7 @@ function isLogicExpression(expression) {
|
|
|
76
76
|
exports.isLogicExpression = isLogicExpression;
|
|
77
77
|
function isBoolExpression(expression) {
|
|
78
78
|
if (Object.keys(expression).length == 1) {
|
|
79
|
-
|
|
79
|
+
const op = Object.keys(expression)[0];
|
|
80
80
|
if (['$true', '$false'].includes(op)) {
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
@@ -86,7 +86,7 @@ function isBoolExpression(expression) {
|
|
|
86
86
|
exports.isBoolExpression = isBoolExpression;
|
|
87
87
|
function isCompareExpression(expression) {
|
|
88
88
|
if (Object.keys(expression).length == 1) {
|
|
89
|
-
|
|
89
|
+
const op = Object.keys(expression)[0];
|
|
90
90
|
if (['$gt', '$lt', '$gte', '$lte', '$eq', '$ne',
|
|
91
91
|
'$startsWith', '$endsWith', '$includes'].includes(op)) {
|
|
92
92
|
return true;
|
|
@@ -97,7 +97,7 @@ function isCompareExpression(expression) {
|
|
|
97
97
|
exports.isCompareExpression = isCompareExpression;
|
|
98
98
|
function isMathExpression(expression) {
|
|
99
99
|
if (Object.keys(expression).length == 1) {
|
|
100
|
-
|
|
100
|
+
const op = Object.keys(expression)[0];
|
|
101
101
|
if (['$add', '$subtract', '$multiply', '$divide', '$abs', '$pow',
|
|
102
102
|
'$round', '$floor', '$ceil'].includes(op)) {
|
|
103
103
|
return true;
|
|
@@ -108,7 +108,7 @@ function isMathExpression(expression) {
|
|
|
108
108
|
exports.isMathExpression = isMathExpression;
|
|
109
109
|
function isStringExpression(expression) {
|
|
110
110
|
if (Object.keys(expression).length == 1) {
|
|
111
|
-
|
|
111
|
+
const op = Object.keys(expression)[0];
|
|
112
112
|
if (['$concat'].includes(op)) {
|
|
113
113
|
return true;
|
|
114
114
|
}
|
|
@@ -118,7 +118,7 @@ function isStringExpression(expression) {
|
|
|
118
118
|
exports.isStringExpression = isStringExpression;
|
|
119
119
|
function isAggrExpression(expression) {
|
|
120
120
|
if (Object.keys(expression).length == 1) {
|
|
121
|
-
|
|
121
|
+
const op = Object.keys(expression)[0];
|
|
122
122
|
if (['$$max', '$$min', '$$sum', '$$avg', '$$count'].includes(op)) {
|
|
123
123
|
return true;
|
|
124
124
|
}
|
|
@@ -137,7 +137,6 @@ function opMultipleParams(op) {
|
|
|
137
137
|
}
|
|
138
138
|
exports.opMultipleParams = opMultipleParams;
|
|
139
139
|
function execOp(op, params, obscure) {
|
|
140
|
-
var e_1, _a, e_2, _b;
|
|
141
140
|
if (obscure && (params === undefined || params.includes(undefined))) {
|
|
142
141
|
return true;
|
|
143
142
|
}
|
|
@@ -171,23 +170,23 @@ function execOp(op, params, obscure) {
|
|
|
171
170
|
}
|
|
172
171
|
case '$add': {
|
|
173
172
|
if (typeof params[0] === 'number') {
|
|
174
|
-
|
|
175
|
-
params.forEach(
|
|
176
|
-
return
|
|
173
|
+
let result = 0;
|
|
174
|
+
params.forEach((ele) => result += ele);
|
|
175
|
+
return result;
|
|
177
176
|
}
|
|
178
177
|
else {
|
|
179
|
-
|
|
180
|
-
params.forEach(
|
|
181
|
-
return
|
|
178
|
+
let result = '';
|
|
179
|
+
params.forEach((ele) => result += ele);
|
|
180
|
+
return result;
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
case '$subtract': {
|
|
185
184
|
return params[0] - params[1];
|
|
186
185
|
}
|
|
187
186
|
case '$multiply': {
|
|
188
|
-
|
|
189
|
-
params.forEach(
|
|
190
|
-
return
|
|
187
|
+
let result = 1;
|
|
188
|
+
params.forEach((ele) => result = result * ele);
|
|
189
|
+
return result;
|
|
191
190
|
}
|
|
192
191
|
case '$divide': {
|
|
193
192
|
return params[0] / params[1];
|
|
@@ -218,73 +217,53 @@ function execOp(op, params, obscure) {
|
|
|
218
217
|
return !params;
|
|
219
218
|
}
|
|
220
219
|
case '$and': {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (!p) {
|
|
225
|
-
return false;
|
|
226
|
-
}
|
|
220
|
+
for (const p of params) {
|
|
221
|
+
if (!p) {
|
|
222
|
+
return false;
|
|
227
223
|
}
|
|
228
224
|
}
|
|
229
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
230
|
-
finally {
|
|
231
|
-
try {
|
|
232
|
-
if (params_1_1 && !params_1_1.done && (_a = params_1.return)) _a.call(params_1);
|
|
233
|
-
}
|
|
234
|
-
finally { if (e_1) throw e_1.error; }
|
|
235
|
-
}
|
|
236
225
|
return true;
|
|
237
226
|
}
|
|
238
227
|
case '$or': {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if (!!p) {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
248
|
-
finally {
|
|
249
|
-
try {
|
|
250
|
-
if (params_2_1 && !params_2_1.done && (_b = params_2.return)) _b.call(params_2);
|
|
228
|
+
for (const p of params) {
|
|
229
|
+
if (!!p) {
|
|
230
|
+
return true;
|
|
251
231
|
}
|
|
252
|
-
finally { if (e_2) throw e_2.error; }
|
|
253
232
|
}
|
|
254
233
|
return false;
|
|
255
234
|
}
|
|
256
235
|
case '$year': {
|
|
257
|
-
|
|
236
|
+
const value = (0, dayjs_1.default)(params);
|
|
258
237
|
return value.year();
|
|
259
238
|
}
|
|
260
239
|
case '$month': {
|
|
261
|
-
|
|
240
|
+
const value = (0, dayjs_1.default)(params);
|
|
262
241
|
return value.month();
|
|
263
242
|
}
|
|
264
243
|
case '$weekday': {
|
|
265
|
-
|
|
244
|
+
const value = (0, dayjs_1.default)(params);
|
|
266
245
|
return value.day(); // 0~6
|
|
267
246
|
}
|
|
268
247
|
case '$weekOfYear': {
|
|
269
|
-
|
|
248
|
+
const value = (0, dayjs_1.default)(params);
|
|
270
249
|
return value.week();
|
|
271
250
|
}
|
|
272
251
|
case '$day':
|
|
273
252
|
case '$dayOfMonth': {
|
|
274
|
-
|
|
253
|
+
const value = (0, dayjs_1.default)(params);
|
|
275
254
|
return value.date();
|
|
276
255
|
}
|
|
277
256
|
case '$dayOfWeek': {
|
|
278
|
-
|
|
257
|
+
const value = (0, dayjs_1.default)(params);
|
|
279
258
|
return value.day(); // 0~6
|
|
280
259
|
}
|
|
281
260
|
case '$dayOfYear': {
|
|
282
|
-
|
|
261
|
+
const value = (0, dayjs_1.default)(params);
|
|
283
262
|
return value.dayOfYear(); // 0~6
|
|
284
263
|
}
|
|
285
264
|
case '$dateDiff': {
|
|
286
|
-
|
|
287
|
-
|
|
265
|
+
const value1 = (0, dayjs_1.default)(params[0]);
|
|
266
|
+
const value2 = (0, dayjs_1.default)(params[1]);
|
|
288
267
|
switch (params[2]) {
|
|
289
268
|
case 'y':
|
|
290
269
|
case 'M':
|
|
@@ -300,7 +279,7 @@ function execOp(op, params, obscure) {
|
|
|
300
279
|
}
|
|
301
280
|
}
|
|
302
281
|
case '$dateCeil': {
|
|
303
|
-
|
|
282
|
+
const value = (0, dayjs_1.default)(params[0]);
|
|
304
283
|
switch (params[1]) {
|
|
305
284
|
case 'y': {
|
|
306
285
|
return value.startOf('year').millisecond();
|
|
@@ -326,7 +305,7 @@ function execOp(op, params, obscure) {
|
|
|
326
305
|
}
|
|
327
306
|
}
|
|
328
307
|
case '$dateFloor': {
|
|
329
|
-
|
|
308
|
+
const value = (0, dayjs_1.default)(params[0]);
|
|
330
309
|
switch (params[1]) {
|
|
331
310
|
case 'y': {
|
|
332
311
|
return value.endOf('year').millisecond();
|
|
@@ -352,9 +331,9 @@ function execOp(op, params, obscure) {
|
|
|
352
331
|
}
|
|
353
332
|
}
|
|
354
333
|
case '$distance': {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
334
|
+
const [geo1, geo2] = params;
|
|
335
|
+
const { type: type1, coordinate: coordinate1 } = geo1;
|
|
336
|
+
const { type: type2, coordinate: coordinate2 } = geo2;
|
|
358
337
|
if (type1 !== 'point' || type2 !== 'point') {
|
|
359
338
|
throw new Error('目前只支持point类型的距离运算');
|
|
360
339
|
}
|
|
@@ -367,7 +346,7 @@ function execOp(op, params, obscure) {
|
|
|
367
346
|
return params.join('');
|
|
368
347
|
}
|
|
369
348
|
default: {
|
|
370
|
-
(0, assert_1.default)(false,
|
|
349
|
+
(0, assert_1.default)(false, `不能识别的expression运算符:${op}`);
|
|
371
350
|
}
|
|
372
351
|
}
|
|
373
352
|
}
|
|
@@ -381,12 +360,10 @@ exports.execOp = execOp;
|
|
|
381
360
|
* }
|
|
382
361
|
*/
|
|
383
362
|
function getAttrRefInExpression(expression) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
var check = function (node) {
|
|
389
|
-
var _a, e_3, _b;
|
|
363
|
+
const result = {
|
|
364
|
+
['#current']: [],
|
|
365
|
+
};
|
|
366
|
+
const check = (node) => {
|
|
390
367
|
if (node['#attr']) {
|
|
391
368
|
result['#current'].push(node['#attr']);
|
|
392
369
|
}
|
|
@@ -395,28 +372,18 @@ function getAttrRefInExpression(expression) {
|
|
|
395
372
|
result[node['#refId']].push(node['#refAttr']);
|
|
396
373
|
}
|
|
397
374
|
else {
|
|
398
|
-
Object.assign(result,
|
|
399
|
-
|
|
400
|
-
|
|
375
|
+
Object.assign(result, {
|
|
376
|
+
[node['#refId']]: [node['#refAttr']],
|
|
377
|
+
});
|
|
401
378
|
}
|
|
402
379
|
}
|
|
403
380
|
else if (node instanceof Array) {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
var subNode = node_1_1.value;
|
|
407
|
-
check(subNode);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
411
|
-
finally {
|
|
412
|
-
try {
|
|
413
|
-
if (node_1_1 && !node_1_1.done && (_b = node_1.return)) _b.call(node_1);
|
|
414
|
-
}
|
|
415
|
-
finally { if (e_3) throw e_3.error; }
|
|
381
|
+
for (const subNode of node) {
|
|
382
|
+
check(subNode);
|
|
416
383
|
}
|
|
417
384
|
}
|
|
418
385
|
else if (typeof node === 'object') {
|
|
419
|
-
for (
|
|
386
|
+
for (const attr in node) {
|
|
420
387
|
check(node[attr]);
|
|
421
388
|
}
|
|
422
389
|
}
|
package/lib/types/Geo.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export type Point = [number, number];
|
|
2
|
+
export type Path = Array<Point>;
|
|
3
|
+
export type Polygon = Array<Path>;
|
|
4
|
+
export type Circle = [Point, number];
|
|
5
|
+
export type SingleGeo = {
|
|
6
6
|
type: 'point';
|
|
7
7
|
coordinate: Point;
|
|
8
8
|
} | {
|
|
@@ -15,4 +15,4 @@ export declare type SingleGeo = {
|
|
|
15
15
|
type: 'circle';
|
|
16
16
|
coordinate: Circle;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
18
|
+
export type Geo = SingleGeo | SingleGeo[];
|
package/lib/types/Locale.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { EntityShape } from "./Entity";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type Language = 'zh_CN' | 'en_US';
|
|
3
|
+
type LocaleOfSchema<S extends Record<string, any>> = {
|
|
4
4
|
[A in keyof Required<Omit<S, keyof EntityShape>>]: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
type LocaleOfStringEnum<A extends string> = {
|
|
7
7
|
[K in A]: string;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type LocaleOfValue<V extends Record<string, string>> = {
|
|
10
10
|
[K in keyof V]: {
|
|
11
11
|
[K2 in V[K]]: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type LocaleDef<Sc extends Record<string, any>, Ac extends string, R extends string, V extends Record<string, string>> = {
|
|
15
15
|
[L in Language]?: {
|
|
16
16
|
name: string;
|
|
17
17
|
attr: LocaleOfSchema<Sc> & {
|
package/lib/types/Polyfill.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type OmitInferKey<T, R> = {
|
|
2
2
|
[K in keyof T as T extends R ? never : K]: T[K];
|
|
3
3
|
};
|
|
4
|
-
export
|
|
4
|
+
export type OmitInferValue<T, R> = {
|
|
5
5
|
[K in keyof T as T extends R ? never : K]: T[K];
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type ValueOf<Obj> = Obj[keyof Obj];
|
|
8
|
+
export type OneOnly<Obj, Key extends keyof Obj> = {
|
|
9
9
|
[key in Exclude<keyof Obj, Key>]?: undefined;
|
|
10
10
|
} & Pick<Obj, Key>;
|
|
11
|
-
export
|
|
11
|
+
export type OneOfByKey<Obj> = {
|
|
12
12
|
[key in keyof Obj]: OneOnly<Obj, key>;
|
|
13
13
|
};
|
|
14
|
-
export
|
|
15
|
-
|
|
14
|
+
export type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
|
|
15
|
+
type IsOptional<T, K extends keyof T> = {
|
|
16
16
|
[K1 in Exclude<keyof T, K>]: T[K1];
|
|
17
17
|
} & {
|
|
18
18
|
K?: T[K];
|
|
19
19
|
} extends T ? K : never;
|
|
20
|
-
export
|
|
20
|
+
export type OptionalKeys<T> = {
|
|
21
21
|
[K in keyof T]: IsOptional<T, K>;
|
|
22
22
|
}[keyof T];
|
|
23
|
-
export
|
|
23
|
+
export type SyncOrAsync<T> = T | Promise<T>;
|
|
24
24
|
export {};
|
package/lib/types/Port.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
2
2
|
import { EntityDict } from "./Entity";
|
|
3
|
-
export
|
|
3
|
+
export type Exportation<ED extends EntityDict, T extends keyof ED, K extends string, Cxt extends AsyncContext<ED>> = {
|
|
4
4
|
name: string;
|
|
5
5
|
id: string;
|
|
6
6
|
entity: T;
|
|
7
7
|
projection: ED[T]['Selection']['data'];
|
|
8
8
|
headers?: K[];
|
|
9
9
|
makeHeaders?: (dataList: Partial<ED[T]['Schema']>[]) => string[];
|
|
10
|
-
fn: (data: ED[T]['Schema'], context?:
|
|
10
|
+
fn: (data: ED[T]['Schema'], context?: Cxt, properties?: Record<string, any>) => Promise<Partial<Record<string, string | number | boolean | null>>> | Partial<Record<string, string | number | boolean | null>>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type Importation<ED extends EntityDict, T extends keyof ED, K extends string, Cxt extends AsyncContext<ED>> = {
|
|
13
13
|
name: string;
|
|
14
14
|
id: string;
|
|
15
15
|
entity: T;
|
|
16
16
|
headers: K[];
|
|
17
|
-
fn: (data: Partial<Record<K, string | number | boolean>>[], context:
|
|
17
|
+
fn: (data: Partial<Record<K, string | number | boolean>>[], context: Cxt, option?: Record<string, any>) => Promise<ED[T]['CreateMulti']['data']>;
|
|
18
18
|
};
|
package/lib/types/RowStore.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { OperationResult, EntityDict } from './Entity';
|
|
|
2
2
|
import { StorageSchema } from './Storage';
|
|
3
3
|
import { AsyncContext } from '../store/AsyncRowStore';
|
|
4
4
|
import { SyncContext } from '../store/SyncRowStore';
|
|
5
|
-
export
|
|
5
|
+
export type TxnOption = {
|
|
6
6
|
isolationLevel: 'repeatable read' | 'serializable';
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type SelectionRewriter<ED extends EntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>> = (schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection'], context: Cxt) => void | Promise<void>;
|
|
9
|
+
export type OperationRewriter<ED extends EntityDict, Cxt extends AsyncContext<ED> | SyncContext<ED>> = (schema: StorageSchema<ED>, entity: keyof ED, operate: ED[keyof ED]['Operation'], context: Cxt) => void | Promise<void>;
|
|
10
10
|
export declare abstract class RowStore<ED extends EntityDict> {
|
|
11
11
|
protected storageSchema: StorageSchema<ED>;
|
|
12
12
|
constructor(storageSchema: StorageSchema<ED>);
|
package/lib/types/RowStore.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RowStore = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const lodash_1 = require("../utils/lodash");
|
|
5
|
+
class RowStore {
|
|
6
|
+
storageSchema;
|
|
7
|
+
constructor(storageSchema) {
|
|
7
8
|
this.storageSchema = storageSchema;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
getSchema() {
|
|
10
11
|
return this.storageSchema;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
for (
|
|
14
|
-
for (
|
|
15
|
-
|
|
12
|
+
}
|
|
13
|
+
mergeOperationResult(result, toBeMerged) {
|
|
14
|
+
for (const entity in toBeMerged) {
|
|
15
|
+
for (const action in toBeMerged[entity]) {
|
|
16
|
+
const value = (0, lodash_1.get)(result, `${entity}.${action}`);
|
|
16
17
|
if (typeof value === 'number') {
|
|
17
|
-
(0, lodash_1.set)(result,
|
|
18
|
+
(0, lodash_1.set)(result, `${entity}.${action}`, value + toBeMerged[entity][action]);
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
|
-
(0, lodash_1.set)(result,
|
|
21
|
+
(0, lodash_1.set)(result, `${entity}.${action}`, toBeMerged[entity][action]);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
toBeMerged.forEach(function (ele) { return _this.mergeOperationResult(result, ele); });
|
|
25
|
+
}
|
|
26
|
+
mergeMultipleResults(toBeMerged) {
|
|
27
|
+
const result = {};
|
|
28
|
+
toBeMerged.forEach(ele => this.mergeOperationResult(result, ele));
|
|
29
29
|
return result;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
}());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
33
32
|
exports.RowStore = RowStore;
|
|
34
33
|
;
|
package/lib/types/Storage.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ActionType } from '.';
|
|
2
2
|
import { EntityDict, EntityShape, InstinctiveAttributes } from './Entity';
|
|
3
3
|
import { DataType, DataTypeParams } from './schema/DataTypes';
|
|
4
|
-
export
|
|
4
|
+
export type Ref = 'ref';
|
|
5
5
|
export interface Column<SH extends EntityShape> {
|
|
6
6
|
name: keyof SH | `${string}State`;
|
|
7
7
|
size?: number;
|
|
@@ -28,12 +28,12 @@ export interface Attribute {
|
|
|
28
28
|
sequenceStart?: number;
|
|
29
29
|
enumeration?: string[];
|
|
30
30
|
}
|
|
31
|
-
export
|
|
31
|
+
export type Attributes<SH extends EntityShape> = Omit<{
|
|
32
32
|
[attrName in keyof SH]: Attribute;
|
|
33
33
|
}, InstinctiveAttributes>;
|
|
34
34
|
export interface EntityConfig {
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type UniqConstraint<SH extends EntityShape> = {
|
|
37
37
|
attributes: Array<keyof SH>;
|
|
38
38
|
type?: string;
|
|
39
39
|
};
|
|
@@ -51,7 +51,8 @@ export interface StorageDesc<SH extends EntityShape> {
|
|
|
51
51
|
actionType: ActionType;
|
|
52
52
|
relation?: string[];
|
|
53
53
|
view?: true;
|
|
54
|
+
recursiveDepth?: number;
|
|
54
55
|
}
|
|
55
|
-
export
|
|
56
|
+
export type StorageSchema<ED extends EntityDict> = {
|
|
56
57
|
[K in keyof ED]: StorageDesc<ED[K]['OpSchema']>;
|
|
57
58
|
};
|
package/lib/types/Style.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EntityDict } from './Entity';
|
|
2
2
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
-
|
|
4
|
-
export
|
|
3
|
+
type ThemeColor = 'default' | 'success' | 'warning' | 'error' | 'primary' | 'danger';
|
|
4
|
+
export type ColorDict<ED extends BaseEntityDict & EntityDict> = {
|
|
5
5
|
[T in keyof ED]?: {
|
|
6
6
|
[A in keyof ED[T]['OpSchema']]?: {
|
|
7
7
|
[E in ED[T]['OpSchema'][A]]?: ThemeColor | `#${string}`;
|
package/lib/types/Timer.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { RecurrenceRule, RecurrenceSpecDateRange, RecurrenceSpecObjLit } from 'node-schedule';
|
|
2
2
|
import { EntityDict } from './Entity';
|
|
3
3
|
import { AsyncContext } from '../store/AsyncRowStore';
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
type RoutineFn<ED extends EntityDict, Cxt extends AsyncContext<ED>> = (context: Cxt) => Promise<string>;
|
|
5
|
+
export type Routine<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|
6
6
|
name: string;
|
|
7
7
|
fn: RoutineFn<ED, Cxt>;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type Timer<ED extends EntityDict, Cxt extends AsyncContext<ED>> = {
|
|
10
10
|
name: string;
|
|
11
11
|
cron: RecurrenceRule | RecurrenceSpecDateRange | RecurrenceSpecObjLit | Date | string | number;
|
|
12
12
|
fn: RoutineFn<ED, Cxt>;
|