oak-domain 2.5.2 → 2.6.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/lib/actions/action.d.ts +16 -16
- package/lib/actions/action.js +17 -17
- package/lib/actions/relation.d.ts +5 -5
- package/lib/actions/relation.js +38 -38
- package/lib/base-app-domain/ActionDefDict.d.ts +8 -8
- package/lib/base-app-domain/ActionDefDict.js +9 -9
- package/lib/base-app-domain/EntityDict.d.ts +14 -14
- package/lib/base-app-domain/EntityDict.js +2 -2
- package/lib/base-app-domain/Modi/Action.d.ts +10 -10
- package/lib/base-app-domain/Modi/Action.js +14 -14
- package/lib/base-app-domain/Modi/Schema.d.ts +146 -146
- package/lib/base-app-domain/Modi/Schema.js +2 -2
- package/lib/base-app-domain/Modi/Storage.d.ts +3 -3
- package/lib/base-app-domain/Modi/Storage.js +60 -60
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +189 -189
- package/lib/base-app-domain/ModiEntity/Schema.js +2 -2
- package/lib/base-app-domain/ModiEntity/Storage.d.ts +3 -3
- package/lib/base-app-domain/ModiEntity/Storage.js +27 -27
- package/lib/base-app-domain/Oper/Schema.d.ts +144 -144
- package/lib/base-app-domain/Oper/Schema.js +2 -2
- package/lib/base-app-domain/Oper/Storage.d.ts +3 -3
- package/lib/base-app-domain/Oper/Storage.js +29 -29
- package/lib/base-app-domain/OperEntity/Schema.d.ts +205 -205
- package/lib/base-app-domain/OperEntity/Schema.js +2 -2
- package/lib/base-app-domain/OperEntity/Storage.d.ts +3 -3
- package/lib/base-app-domain/OperEntity/Storage.js +27 -27
- package/lib/base-app-domain/Storage.d.ts +3 -3
- package/lib/base-app-domain/Storage.js +17 -17
- package/lib/base-app-domain/User/Action.d.ts +10 -10
- package/lib/base-app-domain/User/Action.js +12 -12
- package/lib/base-app-domain/User/Schema.d.ts +180 -180
- package/lib/base-app-domain/User/Schema.js +2 -2
- package/lib/base-app-domain/User/Storage.d.ts +3 -3
- package/lib/base-app-domain/User/Storage.js +36 -36
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +121 -121
- package/lib/base-app-domain/UserEntityGrant/Schema.js +2 -2
- package/lib/base-app-domain/UserEntityGrant/Storage.d.ts +3 -3
- package/lib/base-app-domain/UserEntityGrant/Storage.js +28 -28
- package/lib/base-app-domain/_SubQuery.d.ts +44 -44
- package/lib/base-app-domain/_SubQuery.js +2 -2
- package/lib/base-app-domain/index.d.ts +3 -3
- package/lib/base-app-domain/index.js +6 -6
- package/lib/checkers/index.d.ts +5 -5
- package/lib/checkers/index.js +16 -16
- package/lib/compiler/env.d.ts +11 -11
- package/lib/compiler/env.js +39 -39
- package/lib/compiler/schemalBuilder.d.ts +2 -2
- package/lib/compiler/schemalBuilder.js +3355 -3355
- package/lib/compiler/uiBuilder.d.ts +1 -1
- package/lib/compiler/uiBuilder.js +3 -3
- package/lib/entities/Modi.d.ts +11 -11
- package/lib/entities/Modi.js +46 -46
- package/lib/entities/ModiEntity.d.ts +8 -8
- package/lib/entities/ModiEntity.js +15 -15
- package/lib/entities/Oper.d.ts +10 -10
- package/lib/entities/Oper.js +17 -17
- package/lib/entities/OperEntity.d.ts +8 -8
- package/lib/entities/OperEntity.js +15 -15
- package/lib/entities/User.d.ts +8 -8
- package/lib/entities/User.js +28 -28
- package/lib/entities/UserEntityGrant.d.ts +7 -7
- package/lib/entities/UserEntityGrant.js +12 -12
- package/lib/store/AsyncRowStore.d.ts +51 -48
- package/lib/store/AsyncRowStore.js +189 -183
- package/lib/store/CascadeStore.d.ts +91 -91
- package/lib/store/CascadeStore.js +1634 -1603
- package/lib/store/SyncRowStore.d.ts +29 -29
- package/lib/store/SyncRowStore.js +48 -48
- package/lib/store/TriggerExecutor.d.ts +32 -32
- package/lib/store/TriggerExecutor.js +532 -532
- package/lib/store/actionDef.d.ts +9 -9
- package/lib/store/actionDef.js +333 -333
- package/lib/store/checker.d.ts +26 -26
- package/lib/store/checker.js +829 -867
- package/lib/store/filter.d.ts +109 -109
- package/lib/store/filter.js +893 -893
- package/lib/store/modi.d.ts +13 -13
- package/lib/store/modi.js +216 -216
- package/lib/store/relation.d.ts +13 -13
- package/lib/store/relation.js +66 -66
- package/lib/store/selection.d.ts +19 -7
- package/lib/store/selection.js +265 -238
- package/lib/triggers/index.d.ts +6 -6
- package/lib/triggers/index.js +11 -11
- package/lib/triggers/modi.d.ts +5 -5
- package/lib/triggers/modi.js +72 -72
- package/lib/types/Action.d.ts +20 -20
- package/lib/types/Action.js +2 -2
- package/lib/types/AppLoader.d.ts +11 -11
- package/lib/types/AppLoader.js +10 -10
- package/lib/types/Aspect.d.ts +13 -12
- package/lib/types/Aspect.js +4 -4
- package/lib/types/Auth.d.ts +69 -69
- package/lib/types/Auth.js +2 -2
- package/lib/types/Connector.d.ts +27 -26
- package/lib/types/Connector.js +9 -9
- package/lib/types/Context.d.ts +7 -7
- package/lib/types/Context.js +3 -3
- package/lib/types/DataType.d.ts +18 -18
- package/lib/types/DataType.js +5 -5
- package/lib/types/Demand.d.ts +77 -77
- package/lib/types/Demand.js +9 -9
- package/lib/types/Endpoint.d.ts +11 -11
- package/lib/types/Endpoint.js +3 -3
- package/lib/types/Entity.d.ts +183 -183
- package/lib/types/Entity.js +14 -14
- package/lib/types/Exception.d.ts +100 -98
- package/lib/types/Exception.js +327 -283
- package/lib/types/Expression.d.ts +163 -163
- package/lib/types/Expression.js +427 -427
- package/lib/types/Geo.d.ts +18 -18
- package/lib/types/Geo.js +2 -2
- package/lib/types/Locale.d.ts +24 -24
- package/lib/types/Locale.js +2 -2
- package/lib/types/Logger.d.ts +5 -5
- package/lib/types/Logger.js +3 -3
- package/lib/types/Polyfill.d.ts +23 -23
- package/lib/types/Polyfill.js +2 -2
- package/lib/types/Port.d.ts +17 -17
- package/lib/types/Port.js +2 -2
- package/lib/types/RowStore.d.ts +12 -12
- package/lib/types/RowStore.js +34 -34
- package/lib/types/Storage.d.ts +56 -56
- package/lib/types/Storage.js +2 -2
- package/lib/types/Timer.d.ts +13 -13
- package/lib/types/Timer.js +2 -2
- package/lib/types/Trigger.d.ts +109 -109
- package/lib/types/Trigger.js +49 -49
- package/lib/types/Txn.d.ts +2 -2
- package/lib/types/Txn.js +3 -3
- package/lib/types/Watcher.d.ts +19 -19
- package/lib/types/Watcher.js +4 -4
- package/lib/types/index.d.ts +21 -21
- package/lib/types/index.js +24 -24
- package/lib/types/schema/DataTypes.d.ts +32 -32
- package/lib/types/schema/DataTypes.js +3 -3
- package/lib/utils/SimpleConnector.d.ts +35 -30
- package/lib/utils/SimpleConnector.js +134 -117
- package/lib/utils/assert.d.ts +5 -5
- package/lib/utils/assert.js +9 -9
- package/lib/utils/concurrent.d.ts +15 -15
- package/lib/utils/concurrent.js +89 -89
- package/lib/utils/cron.d.ts +1 -1
- package/lib/utils/cron.js +18 -18
- package/lib/utils/date.d.ts +1 -1
- package/lib/utils/date.js +18 -18
- package/lib/utils/geo.d.ts +4 -4
- package/lib/utils/geo.js +24 -24
- package/lib/utils/lodash.d.ts +20 -20
- package/lib/utils/lodash.js +55 -55
- package/lib/utils/random/random.d.ts +1 -1
- package/lib/utils/random/random.js +24 -24
- package/lib/utils/random/random.mp.d.ts +1 -1
- package/lib/utils/random/random.mp.js +25 -25
- package/lib/utils/random/random.web.d.ts +1 -1
- package/lib/utils/random/random.web.js +17 -17
- package/lib/utils/string.d.ts +22 -22
- package/lib/utils/string.js +70 -70
- package/lib/utils/url.d.ts +1 -0
- package/lib/utils/url.js +12 -0
- package/lib/utils/uuid.d.ts +12 -12
- package/lib/utils/uuid.js +194 -194
- package/lib/utils/validator.d.ts +23 -23
- package/lib/utils/validator.js +123 -123
- package/package.json +48 -48
- package/src/entities/Modi.ts +68 -68
- package/src/entities/ModiEntity.ts +24 -24
- package/src/entities/Oper.ts +28 -28
- package/src/entities/OperEntity.ts +24 -24
- package/src/entities/User.ts +44 -44
- package/src/entities/UserEntityGrant.ts +24 -24
|
@@ -1,117 +1,134 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SimpleConnector = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
var stream_1 = require("stream");
|
|
7
|
-
var types_1 = require("../types");
|
|
8
|
-
function makeContentTypeAndBody(data) {
|
|
9
|
-
//
|
|
10
|
-
if (process.env.OAK_PLATFORM !== 'wechatMp') {
|
|
11
|
-
if (data instanceof FormData) {
|
|
12
|
-
return {
|
|
13
|
-
contentType: 'multipart/form-data',
|
|
14
|
-
body: data,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
contentType: 'application/json',
|
|
20
|
-
body: JSON.stringify(data),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
var SimpleConnector = /** @class */ (function (_super) {
|
|
24
|
-
tslib_1.__extends(SimpleConnector, _super);
|
|
25
|
-
function SimpleConnector(serverUrl, makeException, contextBuilder) {
|
|
26
|
-
var _this = _super.call(this) || this;
|
|
27
|
-
_this.serverUrl = "".concat(serverUrl).concat(SimpleConnector.ROUTER);
|
|
28
|
-
_this.makeException = makeException;
|
|
29
|
-
_this.contextBuilder = contextBuilder;
|
|
30
|
-
return _this;
|
|
31
|
-
}
|
|
32
|
-
SimpleConnector.prototype.callAspect = function (name, params, context) {
|
|
33
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
34
|
-
var cxtStr, _a, contentType, body, response, err, _b, exception, result, opRecords;
|
|
35
|
-
return tslib_1.__generator(this, function (_c) {
|
|
36
|
-
switch (_c.label) {
|
|
37
|
-
case 0:
|
|
38
|
-
cxtStr = context.toString();
|
|
39
|
-
_a = makeContentTypeAndBody(params), contentType = _a.contentType, body = _a.body;
|
|
40
|
-
return [4 /*yield*/, global.fetch(this.serverUrl, {
|
|
41
|
-
method: 'POST',
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': contentType,
|
|
44
|
-
'oak-cxt': cxtStr,
|
|
45
|
-
'oak-aspect': name,
|
|
46
|
-
},
|
|
47
|
-
body: body,
|
|
48
|
-
})];
|
|
49
|
-
case 1:
|
|
50
|
-
response = _c.sent();
|
|
51
|
-
if (response.status > 299) {
|
|
52
|
-
err = new types_1.OakExternalException("\u7F51\u7EDC\u8BF7\u6C42\u8FD4\u56DE\u5F02\u5E38\uFF0Cstatus\u662F".concat(response.status));
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimpleConnector = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
var stream_1 = require("stream");
|
|
7
|
+
var types_1 = require("../types");
|
|
8
|
+
function makeContentTypeAndBody(data) {
|
|
9
|
+
//
|
|
10
|
+
if (process.env.OAK_PLATFORM !== 'wechatMp') {
|
|
11
|
+
if (data instanceof FormData) {
|
|
12
|
+
return {
|
|
13
|
+
contentType: 'multipart/form-data',
|
|
14
|
+
body: data,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
contentType: 'application/json',
|
|
20
|
+
body: JSON.stringify(data),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var SimpleConnector = /** @class */ (function (_super) {
|
|
24
|
+
tslib_1.__extends(SimpleConnector, _super);
|
|
25
|
+
function SimpleConnector(serverUrl, makeException, contextBuilder) {
|
|
26
|
+
var _this = _super.call(this) || this;
|
|
27
|
+
_this.serverUrl = "".concat(serverUrl).concat(SimpleConnector.ROUTER);
|
|
28
|
+
_this.makeException = makeException;
|
|
29
|
+
_this.contextBuilder = contextBuilder;
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
SimpleConnector.prototype.callAspect = function (name, params, context) {
|
|
33
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
34
|
+
var cxtStr, _a, contentType, body, response, err, message, responseType, _b, exception, result, opRecords, result;
|
|
35
|
+
return tslib_1.__generator(this, function (_c) {
|
|
36
|
+
switch (_c.label) {
|
|
37
|
+
case 0:
|
|
38
|
+
cxtStr = context.toString();
|
|
39
|
+
_a = makeContentTypeAndBody(params), contentType = _a.contentType, body = _a.body;
|
|
40
|
+
return [4 /*yield*/, global.fetch(this.serverUrl, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': contentType,
|
|
44
|
+
'oak-cxt': cxtStr,
|
|
45
|
+
'oak-aspect': name,
|
|
46
|
+
},
|
|
47
|
+
body: body,
|
|
48
|
+
})];
|
|
49
|
+
case 1:
|
|
50
|
+
response = _c.sent();
|
|
51
|
+
if (response.status > 299) {
|
|
52
|
+
err = new types_1.OakExternalException("\u7F51\u7EDC\u8BF7\u6C42\u8FD4\u56DE\u5F02\u5E38\uFF0Cstatus\u662F".concat(response.status));
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
55
|
+
message = response.headers.get('oak-message');
|
|
56
|
+
responseType = response.headers.get('Content-Type');
|
|
57
|
+
if (!(responseType === null || responseType === void 0 ? void 0 : responseType.toLocaleLowerCase().match(/application\/json/i))) return [3 /*break*/, 3];
|
|
58
|
+
return [4 /*yield*/, response.json()];
|
|
59
|
+
case 2:
|
|
60
|
+
_b = _c.sent(), exception = _b.exception, result = _b.result, opRecords = _b.opRecords;
|
|
61
|
+
if (exception) {
|
|
62
|
+
throw this.makeException(exception);
|
|
63
|
+
}
|
|
64
|
+
return [2 /*return*/, {
|
|
65
|
+
result: result,
|
|
66
|
+
opRecords: opRecords,
|
|
67
|
+
message: message,
|
|
68
|
+
}];
|
|
69
|
+
case 3:
|
|
70
|
+
if (!(responseType === null || responseType === void 0 ? void 0 : responseType.toLocaleLowerCase().match(/application\/octet-stream/i))) return [3 /*break*/, 5];
|
|
71
|
+
return [4 /*yield*/, response.arrayBuffer()];
|
|
72
|
+
case 4:
|
|
73
|
+
result = _c.sent();
|
|
74
|
+
return [2 /*return*/, {
|
|
75
|
+
result: result,
|
|
76
|
+
message: message,
|
|
77
|
+
}];
|
|
78
|
+
case 5: throw new Error("\u5C1A\u4E0D\u652F\u6301\u7684content-type\u7C7B\u578B".concat(responseType));
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
SimpleConnector.prototype.getRouter = function () {
|
|
84
|
+
return SimpleConnector.ROUTER;
|
|
85
|
+
};
|
|
86
|
+
SimpleConnector.prototype.parseRequest = function (headers, body, store) {
|
|
87
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var oakCxtStr, aspectName, context;
|
|
89
|
+
return tslib_1.__generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
oakCxtStr = headers["oak-cxt"], aspectName = headers["oak-aspect"];
|
|
93
|
+
(0, assert_1.default)(typeof oakCxtStr === 'string' || oakCxtStr === undefined);
|
|
94
|
+
(0, assert_1.default)(typeof aspectName === 'string');
|
|
95
|
+
return [4 /*yield*/, this.contextBuilder(oakCxtStr)(store)];
|
|
96
|
+
case 1:
|
|
97
|
+
context = _a.sent();
|
|
98
|
+
context.setHeaders(headers);
|
|
99
|
+
return [2 /*return*/, {
|
|
100
|
+
name: aspectName,
|
|
101
|
+
params: body,
|
|
102
|
+
context: context,
|
|
103
|
+
}];
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
SimpleConnector.prototype.serializeResult = function (result, context, headers, body) {
|
|
109
|
+
if (result instanceof stream_1.Stream) {
|
|
110
|
+
return {
|
|
111
|
+
body: result,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
body: {
|
|
116
|
+
result: result,
|
|
117
|
+
opRecords: context.opRecords,
|
|
118
|
+
},
|
|
119
|
+
headers: {
|
|
120
|
+
'oak-message': context.getMessage(),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
SimpleConnector.prototype.serializeException = function (exception, headers, body) {
|
|
125
|
+
return {
|
|
126
|
+
body: {
|
|
127
|
+
exception: exception.toString(),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
SimpleConnector.ROUTER = '/aspect';
|
|
132
|
+
return SimpleConnector;
|
|
133
|
+
}(types_1.Connector));
|
|
134
|
+
exports.SimpleConnector = SimpleConnector;
|
package/lib/utils/assert.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 防止assert打包体积过大,从这里引用
|
|
3
|
-
*/
|
|
4
|
-
import assert from 'assert';
|
|
5
|
-
export { assert, };
|
|
1
|
+
/**
|
|
2
|
+
* 防止assert打包体积过大,从这里引用
|
|
3
|
+
*/
|
|
4
|
+
import assert from 'assert';
|
|
5
|
+
export { assert, };
|
package/lib/utils/assert.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assert = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* 防止assert打包体积过大,从这里引用
|
|
7
|
-
*/
|
|
8
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
9
|
-
exports.assert = assert_1.default;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assert = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* 防止assert打包体积过大,从这里引用
|
|
7
|
+
*/
|
|
8
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
9
|
+
exports.assert = assert_1.default;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
declare type Mode = 'S' | 'X';
|
|
2
|
-
/**
|
|
3
|
-
* 模拟一个读写锁,用于同步。
|
|
4
|
-
* 注意,千万不要发生自己等自己
|
|
5
|
-
*/
|
|
6
|
-
export declare class RWLock {
|
|
7
|
-
private readNumber;
|
|
8
|
-
private writeNumber;
|
|
9
|
-
private readWaiter;
|
|
10
|
-
private writeWaiter;
|
|
11
|
-
constructor();
|
|
12
|
-
acquire(mode: Mode): Promise<void>;
|
|
13
|
-
release(): void;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
1
|
+
declare type Mode = 'S' | 'X';
|
|
2
|
+
/**
|
|
3
|
+
* 模拟一个读写锁,用于同步。
|
|
4
|
+
* 注意,千万不要发生自己等自己
|
|
5
|
+
*/
|
|
6
|
+
export declare class RWLock {
|
|
7
|
+
private readNumber;
|
|
8
|
+
private writeNumber;
|
|
9
|
+
private readWaiter;
|
|
10
|
+
private writeWaiter;
|
|
11
|
+
constructor();
|
|
12
|
+
acquire(mode: Mode): Promise<void>;
|
|
13
|
+
release(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
package/lib/utils/concurrent.js
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RWLock = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
-
/**
|
|
7
|
-
* 模拟一个读写锁,用于同步。
|
|
8
|
-
* 注意,千万不要发生自己等自己
|
|
9
|
-
*/
|
|
10
|
-
var RWLock = /** @class */ (function () {
|
|
11
|
-
function RWLock() {
|
|
12
|
-
this.readNumber = 0;
|
|
13
|
-
this.writeNumber = 0;
|
|
14
|
-
this.readWaiter = [];
|
|
15
|
-
this.writeWaiter = [];
|
|
16
|
-
}
|
|
17
|
-
RWLock.prototype.acquire = function (mode) {
|
|
18
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
19
|
-
var p, p;
|
|
20
|
-
var _this = this;
|
|
21
|
-
return tslib_1.__generator(this, function (_a) {
|
|
22
|
-
switch (_a.label) {
|
|
23
|
-
case 0:
|
|
24
|
-
if (!(mode === 'S')) return [3 /*break*/, 4];
|
|
25
|
-
_a.label = 1;
|
|
26
|
-
case 1:
|
|
27
|
-
if (!(this.writeNumber > 0)) return [3 /*break*/, 3];
|
|
28
|
-
p = new Promise(function (resolve) { return _this.readWaiter.push(resolve); });
|
|
29
|
-
return [4 /*yield*/, p];
|
|
30
|
-
case 2:
|
|
31
|
-
_a.sent();
|
|
32
|
-
return [3 /*break*/, 1];
|
|
33
|
-
case 3:
|
|
34
|
-
this.readNumber++;
|
|
35
|
-
return [3 /*break*/, 7];
|
|
36
|
-
case 4:
|
|
37
|
-
if (!(this.writeNumber || this.readNumber)) return [3 /*break*/, 6];
|
|
38
|
-
p = new Promise(function (resolve) { return _this.writeWaiter.push(resolve); });
|
|
39
|
-
return [4 /*yield*/, p];
|
|
40
|
-
case 5:
|
|
41
|
-
_a.sent();
|
|
42
|
-
return [3 /*break*/, 4];
|
|
43
|
-
case 6:
|
|
44
|
-
this.writeNumber++;
|
|
45
|
-
_a.label = 7;
|
|
46
|
-
case 7: return [2 /*return*/];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
RWLock.prototype.release = function () {
|
|
52
|
-
var e_1, _a;
|
|
53
|
-
if (this.writeNumber) {
|
|
54
|
-
(0, assert_1.default)(this.writeNumber === 1);
|
|
55
|
-
this.writeNumber = 0;
|
|
56
|
-
if (this.readWaiter.length > 0) {
|
|
57
|
-
try {
|
|
58
|
-
for (var _b = tslib_1.__values(this.readWaiter), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
59
|
-
var f = _c.value;
|
|
60
|
-
f(undefined);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64
|
-
finally {
|
|
65
|
-
try {
|
|
66
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
67
|
-
}
|
|
68
|
-
finally { if (e_1) throw e_1.error; }
|
|
69
|
-
}
|
|
70
|
-
this.readWaiter = [];
|
|
71
|
-
}
|
|
72
|
-
else if (this.writeWaiter.length > 0) {
|
|
73
|
-
var f = this.writeWaiter.pop();
|
|
74
|
-
f(undefined);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
(0, assert_1.default)(this.readNumber > 0);
|
|
79
|
-
(0, assert_1.default)(this.readWaiter.length === 0);
|
|
80
|
-
this.readNumber--;
|
|
81
|
-
if (this.readNumber === 0) {
|
|
82
|
-
var f = this.writeWaiter.pop();
|
|
83
|
-
f && f(undefined);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
return RWLock;
|
|
88
|
-
}());
|
|
89
|
-
exports.RWLock = RWLock;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RWLock = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
/**
|
|
7
|
+
* 模拟一个读写锁,用于同步。
|
|
8
|
+
* 注意,千万不要发生自己等自己
|
|
9
|
+
*/
|
|
10
|
+
var RWLock = /** @class */ (function () {
|
|
11
|
+
function RWLock() {
|
|
12
|
+
this.readNumber = 0;
|
|
13
|
+
this.writeNumber = 0;
|
|
14
|
+
this.readWaiter = [];
|
|
15
|
+
this.writeWaiter = [];
|
|
16
|
+
}
|
|
17
|
+
RWLock.prototype.acquire = function (mode) {
|
|
18
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
19
|
+
var p, p;
|
|
20
|
+
var _this = this;
|
|
21
|
+
return tslib_1.__generator(this, function (_a) {
|
|
22
|
+
switch (_a.label) {
|
|
23
|
+
case 0:
|
|
24
|
+
if (!(mode === 'S')) return [3 /*break*/, 4];
|
|
25
|
+
_a.label = 1;
|
|
26
|
+
case 1:
|
|
27
|
+
if (!(this.writeNumber > 0)) return [3 /*break*/, 3];
|
|
28
|
+
p = new Promise(function (resolve) { return _this.readWaiter.push(resolve); });
|
|
29
|
+
return [4 /*yield*/, p];
|
|
30
|
+
case 2:
|
|
31
|
+
_a.sent();
|
|
32
|
+
return [3 /*break*/, 1];
|
|
33
|
+
case 3:
|
|
34
|
+
this.readNumber++;
|
|
35
|
+
return [3 /*break*/, 7];
|
|
36
|
+
case 4:
|
|
37
|
+
if (!(this.writeNumber || this.readNumber)) return [3 /*break*/, 6];
|
|
38
|
+
p = new Promise(function (resolve) { return _this.writeWaiter.push(resolve); });
|
|
39
|
+
return [4 /*yield*/, p];
|
|
40
|
+
case 5:
|
|
41
|
+
_a.sent();
|
|
42
|
+
return [3 /*break*/, 4];
|
|
43
|
+
case 6:
|
|
44
|
+
this.writeNumber++;
|
|
45
|
+
_a.label = 7;
|
|
46
|
+
case 7: return [2 /*return*/];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
RWLock.prototype.release = function () {
|
|
52
|
+
var e_1, _a;
|
|
53
|
+
if (this.writeNumber) {
|
|
54
|
+
(0, assert_1.default)(this.writeNumber === 1);
|
|
55
|
+
this.writeNumber = 0;
|
|
56
|
+
if (this.readWaiter.length > 0) {
|
|
57
|
+
try {
|
|
58
|
+
for (var _b = tslib_1.__values(this.readWaiter), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
59
|
+
var f = _c.value;
|
|
60
|
+
f(undefined);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64
|
+
finally {
|
|
65
|
+
try {
|
|
66
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
67
|
+
}
|
|
68
|
+
finally { if (e_1) throw e_1.error; }
|
|
69
|
+
}
|
|
70
|
+
this.readWaiter = [];
|
|
71
|
+
}
|
|
72
|
+
else if (this.writeWaiter.length > 0) {
|
|
73
|
+
var f = this.writeWaiter.pop();
|
|
74
|
+
f(undefined);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
(0, assert_1.default)(this.readNumber > 0);
|
|
79
|
+
(0, assert_1.default)(this.readWaiter.length === 0);
|
|
80
|
+
this.readNumber--;
|
|
81
|
+
if (this.readNumber === 0) {
|
|
82
|
+
var f = this.writeWaiter.pop();
|
|
83
|
+
f && f(undefined);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return RWLock;
|
|
88
|
+
}());
|
|
89
|
+
exports.RWLock = RWLock;
|
package/lib/utils/cron.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function schedule(cron: string, fn: (date: Date) => any): void;
|
|
1
|
+
export declare function schedule(cron: string, fn: (date: Date) => any): void;
|
package/lib/utils/cron.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.schedule = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var cronjs_matcher_1 = require("@datasert/cronjs-matcher");
|
|
6
|
-
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
7
|
-
function schedule(cron, fn) {
|
|
8
|
-
var futureMatches = (0, cronjs_matcher_1.getFutureMatches)(cron, {
|
|
9
|
-
matchCount: 1,
|
|
10
|
-
});
|
|
11
|
-
var date = (0, dayjs_1.default)(futureMatches[0]);
|
|
12
|
-
var interval = date.diff((0, dayjs_1.default)(), 'ms');
|
|
13
|
-
setTimeout(function () {
|
|
14
|
-
fn(new Date());
|
|
15
|
-
schedule(cron, fn);
|
|
16
|
-
}, interval);
|
|
17
|
-
}
|
|
18
|
-
exports.schedule = schedule;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schedule = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var cronjs_matcher_1 = require("@datasert/cronjs-matcher");
|
|
6
|
+
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
7
|
+
function schedule(cron, fn) {
|
|
8
|
+
var futureMatches = (0, cronjs_matcher_1.getFutureMatches)(cron, {
|
|
9
|
+
matchCount: 1,
|
|
10
|
+
});
|
|
11
|
+
var date = (0, dayjs_1.default)(futureMatches[0]);
|
|
12
|
+
var interval = date.diff((0, dayjs_1.default)(), 'ms');
|
|
13
|
+
setTimeout(function () {
|
|
14
|
+
fn(new Date());
|
|
15
|
+
schedule(cron, fn);
|
|
16
|
+
}, interval);
|
|
17
|
+
}
|
|
18
|
+
exports.schedule = schedule;
|
package/lib/utils/date.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function excelStringToDate(str: string | number): number | undefined;
|
|
1
|
+
export declare function excelStringToDate(str: string | number): number | undefined;
|
package/lib/utils/date.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.excelStringToDate = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
-
function excelStringToDate(str) {
|
|
7
|
-
if (!str) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
if (typeof str === 'number') {
|
|
11
|
-
if (str < 100000) {
|
|
12
|
-
return (0, dayjs_1.default)((((str - 25569) * 24 - 8) * 3600) * 1000).valueOf(); // excel日期可能为1900-1-1至今的天数
|
|
13
|
-
}
|
|
14
|
-
return (0, dayjs_1.default)(str).valueOf();
|
|
15
|
-
}
|
|
16
|
-
return Date.parse(str);
|
|
17
|
-
}
|
|
18
|
-
exports.excelStringToDate = excelStringToDate;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.excelStringToDate = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
6
|
+
function excelStringToDate(str) {
|
|
7
|
+
if (!str) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
if (typeof str === 'number') {
|
|
11
|
+
if (str < 100000) {
|
|
12
|
+
return (0, dayjs_1.default)((((str - 25569) * 24 - 8) * 3600) * 1000).valueOf(); // excel日期可能为1900-1-1至今的天数
|
|
13
|
+
}
|
|
14
|
+
return (0, dayjs_1.default)(str).valueOf();
|
|
15
|
+
}
|
|
16
|
+
return Date.parse(str);
|
|
17
|
+
}
|
|
18
|
+
exports.excelStringToDate = excelStringToDate;
|
package/lib/utils/geo.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 计算地球上两点之间的球面距离
|
|
3
|
-
*/
|
|
4
|
-
export declare function getDistanceBetweenPoints(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
1
|
+
/**
|
|
2
|
+
* 计算地球上两点之间的球面距离
|
|
3
|
+
*/
|
|
4
|
+
export declare function getDistanceBetweenPoints(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
package/lib/utils/geo.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDistanceBetweenPoints = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 计算地球上两点之间的球面距离
|
|
6
|
-
*/
|
|
7
|
-
function getDistanceBetweenPoints(lat1, lon1, lat2, lon2) {
|
|
8
|
-
// 转为弧度
|
|
9
|
-
function toRadians(d) {
|
|
10
|
-
return d * Math.PI / 180;
|
|
11
|
-
}
|
|
12
|
-
var R = 6378137; // 地球长半径
|
|
13
|
-
var φ1 = toRadians(lat1);
|
|
14
|
-
var φ2 = toRadians(lat2);
|
|
15
|
-
var Δφ = toRadians(lat2 - lat1);
|
|
16
|
-
var Δλ = toRadians(lon2 - lon1);
|
|
17
|
-
var a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
|
18
|
-
Math.cos(φ1) * Math.cos(φ2) *
|
|
19
|
-
Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
|
|
20
|
-
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
21
|
-
var d = R * c;
|
|
22
|
-
return d * 1000;
|
|
23
|
-
}
|
|
24
|
-
exports.getDistanceBetweenPoints = getDistanceBetweenPoints;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDistanceBetweenPoints = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 计算地球上两点之间的球面距离
|
|
6
|
+
*/
|
|
7
|
+
function getDistanceBetweenPoints(lat1, lon1, lat2, lon2) {
|
|
8
|
+
// 转为弧度
|
|
9
|
+
function toRadians(d) {
|
|
10
|
+
return d * Math.PI / 180;
|
|
11
|
+
}
|
|
12
|
+
var R = 6378137; // 地球长半径
|
|
13
|
+
var φ1 = toRadians(lat1);
|
|
14
|
+
var φ2 = toRadians(lat2);
|
|
15
|
+
var Δφ = toRadians(lat2 - lat1);
|
|
16
|
+
var Δλ = toRadians(lon2 - lon1);
|
|
17
|
+
var a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
|
|
18
|
+
Math.cos(φ1) * Math.cos(φ2) *
|
|
19
|
+
Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
|
|
20
|
+
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
21
|
+
var d = R * c;
|
|
22
|
+
return d * 1000;
|
|
23
|
+
}
|
|
24
|
+
exports.getDistanceBetweenPoints = getDistanceBetweenPoints;
|