oak-domain 1.1.14 → 2.0.1
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/base-app-domain/Modi/Schema.d.ts +22 -22
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +17 -17
- package/lib/base-app-domain/Oper/Schema.d.ts +17 -17
- package/lib/base-app-domain/OperEntity/Schema.d.ts +18 -18
- package/lib/base-app-domain/User/Schema.d.ts +15 -15
- package/lib/checkers/index.d.ts +4 -2
- package/lib/compiler/schemalBuilder.js +10 -10
- package/lib/store/AsyncRowStore.d.ts +45 -0
- package/lib/store/{UniversalContext.js → AsyncRowStore.js} +39 -29
- package/lib/store/CascadeStore.d.ts +46 -20
- package/lib/store/CascadeStore.js +954 -995
- package/lib/store/SyncRowStore.d.ts +26 -0
- package/lib/store/SyncRowStore.js +45 -0
- package/lib/store/TriggerExecutor.d.ts +14 -14
- package/lib/store/TriggerExecutor.js +225 -238
- package/lib/store/actionDef.d.ts +5 -4
- package/lib/store/actionDef.js +44 -134
- package/lib/store/checker.d.ts +6 -0
- package/lib/store/checker.js +165 -0
- package/lib/store/filter.d.ts +5 -0
- package/lib/store/filter.js +394 -2
- package/lib/store/modi.d.ts +7 -6
- package/lib/store/modi.js +35 -46
- package/lib/store/relation.d.ts +1 -1
- package/lib/triggers/index.d.ts +4 -3
- package/lib/triggers/modi.d.ts +2 -2
- package/lib/triggers/modi.js +5 -5
- package/lib/types/AppLoader.d.ts +3 -3
- package/lib/types/Aspect.d.ts +3 -3
- package/lib/types/Auth.d.ts +25 -22
- package/lib/types/Connector.d.ts +7 -7
- package/lib/types/Context.d.ts +4 -14
- package/lib/types/Entity.d.ts +20 -15
- package/lib/types/Entity.js +9 -2
- package/lib/types/Exception.js +11 -11
- package/lib/types/RowStore.d.ts +2 -13
- package/lib/types/RowStore.js +1 -6
- package/lib/types/Trigger.d.ts +32 -48
- package/lib/types/Trigger.js +24 -9
- package/lib/types/Watcher.d.ts +7 -8
- package/lib/utils/SimpleConnector.d.ts +9 -8
- package/lib/utils/SimpleConnector.js +4 -5
- package/lib/utils/random/random.d.ts +1 -0
- package/lib/utils/random/random.js +24 -0
- package/lib/utils/random/random.mp.d.ts +1 -0
- package/lib/utils/random/random.mp.js +25 -0
- package/lib/utils/random/random.web.d.ts +1 -0
- package/lib/utils/random/random.web.js +17 -0
- package/lib/utils/string.d.ts +20 -0
- package/lib/utils/string.js +60 -1
- package/lib/utils/uuid.d.ts +10 -0
- package/lib/utils/uuid.js +172 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +5 -3
- package/lib/OakError.d.ts +0 -7
- package/lib/OakError.js +0 -15
- package/lib/compiler/utils.d.ts +0 -2
- package/lib/compiler/utils.js +0 -11
- package/lib/entities/Action.d.ts +0 -12
- package/lib/entities/Action.js +0 -17
- package/lib/entities/Ooperation.d.ts +0 -12
- package/lib/entities/Ooperation.js +0 -17
- package/lib/entities/Update.d.ts +0 -9
- package/lib/entities/Update.js +0 -44
- package/lib/entities/Uupdate.d.ts +0 -9
- package/lib/entities/Uupdate.js +0 -44
- package/lib/store/UniversalContext.d.ts +0 -32
- package/lib/store/action.d.ts +0 -6
- package/lib/store/action.js +0 -14
- package/lib/store/projection.d.ts +0 -7
- package/lib/store/projection.js +0 -211
- package/lib/store/watchers.d.ts +0 -2
- package/lib/store/watchers.js +0 -32
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRandomValues(length: number): Promise<Uint8Array>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference types="wechat-miniprogram" />
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getRandomValues = void 0;
|
|
5
|
+
var tslib_1 = require("tslib");
|
|
6
|
+
function getRandomValues(length) {
|
|
7
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
8
|
+
var randomValues;
|
|
9
|
+
return tslib_1.__generator(this, function (_a) {
|
|
10
|
+
switch (_a.label) {
|
|
11
|
+
case 0:
|
|
12
|
+
if (length > 65536) {
|
|
13
|
+
throw new Error('Can only request a maximum of 65536 bytes');
|
|
14
|
+
}
|
|
15
|
+
return [4 /*yield*/, wx.getRandomValues({
|
|
16
|
+
length: length,
|
|
17
|
+
})];
|
|
18
|
+
case 1:
|
|
19
|
+
randomValues = (_a.sent()).randomValues;
|
|
20
|
+
return [2 /*return*/, new Uint8Array(randomValues)];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.getRandomValues = getRandomValues;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRandomValues(length: number): Promise<Uint8Array>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomValues = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
function getRandomValues(length) {
|
|
6
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
7
|
+
var randomValues;
|
|
8
|
+
return tslib_1.__generator(this, function (_a) {
|
|
9
|
+
if (length > 65536) {
|
|
10
|
+
throw new Error('Can only request a maximum of 65536 bytes');
|
|
11
|
+
}
|
|
12
|
+
randomValues = window.crypto.getRandomValues(new Uint8Array(length));
|
|
13
|
+
return [2 /*return*/, new Uint8Array(randomValues)];
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.getRandomValues = getRandomValues;
|
package/lib/utils/string.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
export declare function firstLetterLowerCase(s: string): string;
|
|
2
2
|
export declare function firstLetterUpperCase(s: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* 模板字符串 使用 定义const NotFilled = template`${0}未填写`; 调用NotFilled('姓名') 等于姓名未填写
|
|
5
|
+
* @param strings
|
|
6
|
+
* @param keys
|
|
7
|
+
* @returns {function(...[*]): string}
|
|
8
|
+
*/
|
|
9
|
+
export declare const template: (strings: TemplateStringsArray, ...keys: Array<any>) => (...values: Array<any>) => string;
|
|
10
|
+
/**
|
|
11
|
+
* 随机生成字符串
|
|
12
|
+
* @param randomLength
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare const random: (randomLength?: number) => string;
|
|
16
|
+
/**
|
|
17
|
+
* 随机生成带前缀的字符串
|
|
18
|
+
* @param prefix 第一个参数为你想生成的固定的文字开头比如: 微信用户xxxxx
|
|
19
|
+
* @param randomLength 第二个为你想生成出固定开头文字外的随机长度
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare const randomName: (prefix?: string, randomLength?: number) => string;
|
package/lib/utils/string.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firstLetterUpperCase = exports.firstLetterLowerCase = void 0;
|
|
3
|
+
exports.randomName = exports.random = exports.template = exports.firstLetterUpperCase = exports.firstLetterLowerCase = void 0;
|
|
4
4
|
function firstLetterLowerCase(s) {
|
|
5
5
|
return s.slice(0, 1).toLowerCase().concat(s.slice(1));
|
|
6
6
|
}
|
|
@@ -9,3 +9,62 @@ function firstLetterUpperCase(s) {
|
|
|
9
9
|
return s.slice(0, 1).toUpperCase().concat(s.slice(1));
|
|
10
10
|
}
|
|
11
11
|
exports.firstLetterUpperCase = firstLetterUpperCase;
|
|
12
|
+
/**
|
|
13
|
+
* 模板字符串 使用 定义const NotFilled = template`${0}未填写`; 调用NotFilled('姓名') 等于姓名未填写
|
|
14
|
+
* @param strings
|
|
15
|
+
* @param keys
|
|
16
|
+
* @returns {function(...[*]): string}
|
|
17
|
+
*/
|
|
18
|
+
var template = function (strings) {
|
|
19
|
+
var keys = [];
|
|
20
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
21
|
+
keys[_i - 1] = arguments[_i];
|
|
22
|
+
}
|
|
23
|
+
return (function () {
|
|
24
|
+
var values = [];
|
|
25
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
26
|
+
values[_i] = arguments[_i];
|
|
27
|
+
}
|
|
28
|
+
var dict = values[values.length - 1] || {};
|
|
29
|
+
var result = [strings[0]];
|
|
30
|
+
keys.forEach(function (key, i) {
|
|
31
|
+
var value = Number.isInteger(key) ? values[key] : dict[key];
|
|
32
|
+
result.push(value, strings[i + 1]);
|
|
33
|
+
});
|
|
34
|
+
return result.join('');
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
exports.template = template;
|
|
38
|
+
/**
|
|
39
|
+
* 随机生成字符串
|
|
40
|
+
* @param randomLength
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
var random = function (randomLength) {
|
|
44
|
+
if (randomLength === void 0) { randomLength = 16; }
|
|
45
|
+
// 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1
|
|
46
|
+
var DICT = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
|
|
47
|
+
var maxPos = DICT.length;
|
|
48
|
+
var pwd = '';
|
|
49
|
+
for (var i = 0; i < randomLength; i++) {
|
|
50
|
+
pwd += DICT.charAt(Math.floor(Math.random() * maxPos));
|
|
51
|
+
}
|
|
52
|
+
return pwd;
|
|
53
|
+
};
|
|
54
|
+
exports.random = random;
|
|
55
|
+
/**
|
|
56
|
+
* 随机生成带前缀的字符串
|
|
57
|
+
* @param prefix 第一个参数为你想生成的固定的文字开头比如: 微信用户xxxxx
|
|
58
|
+
* @param randomLength 第二个为你想生成出固定开头文字外的随机长度
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
var randomName = function (prefix, randomLength) {
|
|
62
|
+
if (randomLength === void 0) { randomLength = 8; }
|
|
63
|
+
// 默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1
|
|
64
|
+
var DICT = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
|
|
65
|
+
var maxPos = DICT.length;
|
|
66
|
+
var name = prefix === undefined ? '' : prefix;
|
|
67
|
+
name += (0, exports.random)(randomLength);
|
|
68
|
+
return name;
|
|
69
|
+
};
|
|
70
|
+
exports.randomName = randomName;
|
package/lib/utils/uuid.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
export declare function sequentialUuid({ random }: {
|
|
2
|
+
random: Uint8Array;
|
|
3
|
+
}): string;
|
|
1
4
|
export declare function shrinkUuidTo32Bytes(uuid: string): string;
|
|
2
5
|
export declare function expandUuidTo36Bytes(uuidShrinked: string): string;
|
|
6
|
+
export declare type GenerateIdOption = {
|
|
7
|
+
shuffle?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare function generateNewIdAsync(option?: GenerateIdOption): Promise<string>;
|
|
10
|
+
export declare function produceIds(): Promise<void>;
|
|
11
|
+
export declare function setGenerateIdOption(option: GenerateIdOption): Promise<void>;
|
|
12
|
+
export declare function generateNewId(): string;
|
package/lib/utils/uuid.js
CHANGED
|
@@ -1,6 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = void 0;
|
|
3
|
+
exports.generateNewId = exports.setGenerateIdOption = exports.produceIds = exports.generateNewIdAsync = exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = exports.sequentialUuid = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
|
+
var uuid_1 = require("uuid");
|
|
7
|
+
var random_1 = require("./random/random");
|
|
8
|
+
var _nodeId;
|
|
9
|
+
var _clockseq;
|
|
10
|
+
// Previous uuid creation time
|
|
11
|
+
var _lastMSecs = 0;
|
|
12
|
+
var _lastNSecs = 0;
|
|
13
|
+
// 根据uuid v1改的,产生按时间顺序uuid的函数(更优于底层数据库的插入行为)
|
|
14
|
+
// **`v1()` - Generate time-based UUID**
|
|
15
|
+
//
|
|
16
|
+
// Inspired by https://github.com/LiosK/UUID.js
|
|
17
|
+
// and http://docs.python.org/library/uuid.html
|
|
18
|
+
var byteToHex = [];
|
|
19
|
+
for (var i = 0; i < 256; ++i) {
|
|
20
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
21
|
+
}
|
|
22
|
+
function unsafeStringify(arr, offset) {
|
|
23
|
+
if (offset === void 0) { offset = 0; }
|
|
24
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
25
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
26
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
27
|
+
}
|
|
28
|
+
// See https://github.com/uuidjs/uuid for API details
|
|
29
|
+
function sequentialUuid(_a) {
|
|
30
|
+
var random = _a.random;
|
|
31
|
+
var i = 0;
|
|
32
|
+
var b = new Array(16);
|
|
33
|
+
var node = _nodeId;
|
|
34
|
+
var clockseq = _clockseq;
|
|
35
|
+
// node and clockseq need to be initialized to random values if they're not
|
|
36
|
+
// specified. We do this lazily to minimize issues related to insufficient
|
|
37
|
+
// system entropy. See #189
|
|
38
|
+
if (node == null || clockseq == null) {
|
|
39
|
+
var seedBytes = random;
|
|
40
|
+
if (node == null) {
|
|
41
|
+
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
42
|
+
node = _nodeId = [
|
|
43
|
+
seedBytes[0] | 0x01,
|
|
44
|
+
seedBytes[1],
|
|
45
|
+
seedBytes[2],
|
|
46
|
+
seedBytes[3],
|
|
47
|
+
seedBytes[4],
|
|
48
|
+
seedBytes[5],
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
if (clockseq == null) {
|
|
52
|
+
// Per 4.2.2, randomize (14 bit) clockseq
|
|
53
|
+
clockseq = _clockseq = ((seedBytes[6] << 8) | seedBytes[7]) & 0x3fff;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
|
57
|
+
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
|
58
|
+
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
|
59
|
+
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
60
|
+
var msecs = Date.now();
|
|
61
|
+
// Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
62
|
+
// cycle to simulate higher resolution clock
|
|
63
|
+
var nsecs = _lastNSecs + 1;
|
|
64
|
+
// Time since last uuid creation (in msecs)
|
|
65
|
+
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000;
|
|
66
|
+
// Per 4.2.1.2, Bump clockseq on clock regression
|
|
67
|
+
if (dt < 0) {
|
|
68
|
+
clockseq = (clockseq + 1) & 0x3fff;
|
|
69
|
+
}
|
|
70
|
+
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
|
71
|
+
// time interval
|
|
72
|
+
if ((dt < 0 || msecs > _lastMSecs)) {
|
|
73
|
+
nsecs = 0;
|
|
74
|
+
}
|
|
75
|
+
// Per 4.2.1.2 Throw error if too many uuids are requested
|
|
76
|
+
if (nsecs >= 10000) {
|
|
77
|
+
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
78
|
+
}
|
|
79
|
+
_lastMSecs = msecs;
|
|
80
|
+
_lastNSecs = nsecs;
|
|
81
|
+
_clockseq = clockseq;
|
|
82
|
+
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
|
83
|
+
msecs += 12219292800000;
|
|
84
|
+
// `time_high_and_version`
|
|
85
|
+
var tmh = ((msecs / 0x100000000) * 10000) & 0xfffffff;
|
|
86
|
+
b[i++] = ((tmh >>> 24) & 0xf) | 0x10; // include version
|
|
87
|
+
b[i++] = (tmh >>> 16) & 0xff;
|
|
88
|
+
// `time_mid`
|
|
89
|
+
b[i++] = (tmh >>> 8) & 0xff;
|
|
90
|
+
b[i++] = tmh & 0xff;
|
|
91
|
+
// `time_low`
|
|
92
|
+
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
93
|
+
b[i++] = (tl >>> 24) & 0xff;
|
|
94
|
+
b[i++] = (tl >>> 16) & 0xff;
|
|
95
|
+
b[i++] = (tl >>> 8) & 0xff;
|
|
96
|
+
b[i++] = tl & 0xff;
|
|
97
|
+
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
|
98
|
+
b[i++] = (clockseq >>> 8) | 0x80;
|
|
99
|
+
// `clock_seq_low`
|
|
100
|
+
b[i++] = clockseq & 0xff;
|
|
101
|
+
// `node`
|
|
102
|
+
for (var n = 0; n < 6; ++n) {
|
|
103
|
+
b[i + n] = node[n];
|
|
104
|
+
}
|
|
105
|
+
return unsafeStringify(b);
|
|
106
|
+
}
|
|
107
|
+
exports.sequentialUuid = sequentialUuid;
|
|
4
108
|
function shrinkUuidTo32Bytes(uuid) {
|
|
5
109
|
return uuid.replaceAll('-', '');
|
|
6
110
|
}
|
|
@@ -9,3 +113,70 @@ function expandUuidTo36Bytes(uuidShrinked) {
|
|
|
9
113
|
return "".concat(uuidShrinked.slice(0, 8), "-").concat(uuidShrinked.slice(8, 12), "-").concat(uuidShrinked.slice(12, 16), "-").concat(uuidShrinked.slice(16, 20), "-").concat(uuidShrinked.slice(20));
|
|
10
114
|
}
|
|
11
115
|
exports.expandUuidTo36Bytes = expandUuidTo36Bytes;
|
|
116
|
+
// 直接生成uuid的接口,为了适配各种环境,写成异步
|
|
117
|
+
function generateNewIdAsync(option) {
|
|
118
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
119
|
+
var option2, _a, _b;
|
|
120
|
+
var _c, _d;
|
|
121
|
+
return tslib_1.__generator(this, function (_e) {
|
|
122
|
+
switch (_e.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
option2 = option || ID_OPTION;
|
|
125
|
+
if (!((option2 === null || option2 === void 0 ? void 0 : option2.shuffle) || process.env.NODE_ENV === 'development')) return [3 /*break*/, 2];
|
|
126
|
+
_a = uuid_1.v4;
|
|
127
|
+
_c = {};
|
|
128
|
+
return [4 /*yield*/, (0, random_1.getRandomValues)(16)];
|
|
129
|
+
case 1: return [2 /*return*/, _a.apply(void 0, [(_c.random = _e.sent(), _c)])];
|
|
130
|
+
case 2:
|
|
131
|
+
_b = sequentialUuid;
|
|
132
|
+
_d = {};
|
|
133
|
+
return [4 /*yield*/, (0, random_1.getRandomValues)(16)];
|
|
134
|
+
case 3: return [2 /*return*/, _b.apply(void 0, [(_d.random = _e.sent(), _d)])];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
exports.generateNewIdAsync = generateNewIdAsync;
|
|
140
|
+
// 实现同步的id缓存接口,以便于前台使用
|
|
141
|
+
var ID_BUFFER = [];
|
|
142
|
+
var ID_OPTION = {};
|
|
143
|
+
function produceIds() {
|
|
144
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
145
|
+
var iter, _a, _b;
|
|
146
|
+
return tslib_1.__generator(this, function (_c) {
|
|
147
|
+
switch (_c.label) {
|
|
148
|
+
case 0:
|
|
149
|
+
iter = 0;
|
|
150
|
+
_c.label = 1;
|
|
151
|
+
case 1:
|
|
152
|
+
if (!(iter < 128)) return [3 /*break*/, 4];
|
|
153
|
+
_b = (_a = ID_BUFFER).push;
|
|
154
|
+
return [4 /*yield*/, generateNewIdAsync()];
|
|
155
|
+
case 2:
|
|
156
|
+
_b.apply(_a, [_c.sent()]);
|
|
157
|
+
_c.label = 3;
|
|
158
|
+
case 3:
|
|
159
|
+
iter++;
|
|
160
|
+
return [3 /*break*/, 1];
|
|
161
|
+
case 4: return [2 /*return*/];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
exports.produceIds = produceIds;
|
|
167
|
+
produceIds();
|
|
168
|
+
function setGenerateIdOption(option) {
|
|
169
|
+
ID_OPTION = option;
|
|
170
|
+
ID_BUFFER.splice(0, ID_BUFFER.length);
|
|
171
|
+
return produceIds();
|
|
172
|
+
}
|
|
173
|
+
exports.setGenerateIdOption = setGenerateIdOption;
|
|
174
|
+
function generateNewId() {
|
|
175
|
+
(0, assert_1.default)(ID_BUFFER.length > 0, '缓存的id已经用完,请提前调用produceIds以确保缓冲池中有足够的预分配id');
|
|
176
|
+
var id = ID_BUFFER.pop();
|
|
177
|
+
if (ID_BUFFER.length < 64) {
|
|
178
|
+
produceIds();
|
|
179
|
+
}
|
|
180
|
+
return id;
|
|
181
|
+
}
|
|
182
|
+
exports.generateNewId = generateNewId;
|
package/lib/utils/validator.js
CHANGED
|
@@ -101,7 +101,7 @@ var isVehicleNumber = function (str) {
|
|
|
101
101
|
exports.isVehicleNumber = isVehicleNumber;
|
|
102
102
|
function checkAttributesNotNull(entity, data, attributes, allowEmpty) {
|
|
103
103
|
var attrs = attributes.filter(function (attr) {
|
|
104
|
-
if (data[attr] === null || data[attr] === '') {
|
|
104
|
+
if (data[attr] === null || data[attr] === '' || data[attr] === undefined) {
|
|
105
105
|
return true;
|
|
106
106
|
}
|
|
107
107
|
if (!allowEmpty && !data.hasOwnProperty(attr)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-domain",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "XuChang"
|
|
6
6
|
},
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"@types/node": "^14.14.25",
|
|
29
29
|
"@types/react": "^17.0.2",
|
|
30
30
|
"@types/uuid": "^8.3.0",
|
|
31
|
+
"@types/wechat-miniprogram": "^3.4.1",
|
|
31
32
|
"assert": "^2.0.0",
|
|
32
33
|
"cross-env": "^7.0.2",
|
|
33
34
|
"cross-spawn": "^7.0.3",
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
"typescript": "~4.7.4"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"dayjs": "^1.11.
|
|
42
|
-
"lodash": "^4.17.21"
|
|
42
|
+
"dayjs": "^1.11.5",
|
|
43
|
+
"lodash": "^4.17.21",
|
|
44
|
+
"uuid": "^9.0.0"
|
|
43
45
|
}
|
|
44
46
|
}
|
package/lib/OakError.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare type OakErrorDef = [number, string];
|
|
2
|
-
export declare type OakErrorDefDict = Record<string, OakErrorDef>;
|
|
3
|
-
export declare class OakError extends Error {
|
|
4
|
-
$$level: string;
|
|
5
|
-
$$code?: number;
|
|
6
|
-
constructor(level: string, def?: OakErrorDef, message?: string);
|
|
7
|
-
}
|
package/lib/OakError.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OakError = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var OakError = /** @class */ (function (_super) {
|
|
6
|
-
tslib_1.__extends(OakError, _super);
|
|
7
|
-
function OakError(level, def, message) {
|
|
8
|
-
var _this = _super.call(this, message ? message : def && def[1]) || this;
|
|
9
|
-
_this.$$level = level;
|
|
10
|
-
_this.$$code = def && def[0];
|
|
11
|
-
return _this;
|
|
12
|
-
}
|
|
13
|
-
return OakError;
|
|
14
|
-
}(Error));
|
|
15
|
-
exports.OakError = OakError;
|
package/lib/compiler/utils.d.ts
DELETED
package/lib/compiler/utils.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firstLetterUpperCase = exports.firstLetterLowerCase = void 0;
|
|
4
|
-
function firstLetterLowerCase(s) {
|
|
5
|
-
return s.slice(0, 1).toLowerCase().concat(s.slice(1));
|
|
6
|
-
}
|
|
7
|
-
exports.firstLetterLowerCase = firstLetterLowerCase;
|
|
8
|
-
function firstLetterUpperCase(s) {
|
|
9
|
-
return s.slice(0, 1).toUpperCase().concat(s.slice(1));
|
|
10
|
-
}
|
|
11
|
-
exports.firstLetterUpperCase = firstLetterUpperCase;
|
package/lib/entities/Action.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
export interface Schema extends EntityShape {
|
|
4
|
-
action: String<16>;
|
|
5
|
-
data: Object;
|
|
6
|
-
entity?: String<32>;
|
|
7
|
-
entityId?: String<64>;
|
|
8
|
-
filter?: Object;
|
|
9
|
-
extra?: Object;
|
|
10
|
-
operatorId: String<32>;
|
|
11
|
-
operatorInfo?: Object;
|
|
12
|
-
}
|
package/lib/entities/Action.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
;
|
|
4
|
-
var locale = {
|
|
5
|
-
zh_CN: {
|
|
6
|
-
attr: {
|
|
7
|
-
action: '动作',
|
|
8
|
-
data: '数据',
|
|
9
|
-
entity: '关联对象',
|
|
10
|
-
entityId: '关联对象id',
|
|
11
|
-
filter: '选择条件',
|
|
12
|
-
extra: '其它',
|
|
13
|
-
operatorId: '操作者id',
|
|
14
|
-
operatorInfo: '操作者信息'
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
export interface Schema extends EntityShape {
|
|
4
|
-
action: String<16>;
|
|
5
|
-
data: Object;
|
|
6
|
-
entity?: String<32>;
|
|
7
|
-
entityId?: String<64>;
|
|
8
|
-
filter?: Object;
|
|
9
|
-
extra?: Object;
|
|
10
|
-
operatorId: String<32>;
|
|
11
|
-
operatorInfo?: Object;
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
;
|
|
4
|
-
var locale = {
|
|
5
|
-
zh_CN: {
|
|
6
|
-
attr: {
|
|
7
|
-
action: '动作',
|
|
8
|
-
data: '数据',
|
|
9
|
-
entity: '关联对象',
|
|
10
|
-
entityId: '关联对象id',
|
|
11
|
-
filter: '选择条件',
|
|
12
|
-
extra: '其它',
|
|
13
|
-
operatorId: '操作者id',
|
|
14
|
-
operatorInfo: '操作者信息'
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
package/lib/entities/Update.d.ts
DELETED
package/lib/entities/Update.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
;
|
|
4
|
-
var IActionDef = {
|
|
5
|
-
stm: {
|
|
6
|
-
apply: ['active', 'applied'],
|
|
7
|
-
abandon: ['active', 'abandoned'],
|
|
8
|
-
},
|
|
9
|
-
is: 'active',
|
|
10
|
-
};
|
|
11
|
-
var indexes = [
|
|
12
|
-
{
|
|
13
|
-
name: 'index_state',
|
|
14
|
-
attributes: [
|
|
15
|
-
{
|
|
16
|
-
name: 'iState',
|
|
17
|
-
direction: 'ASC',
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
var locale = {
|
|
23
|
-
zh_CN: {
|
|
24
|
-
attr: {
|
|
25
|
-
action: '动作',
|
|
26
|
-
data: '数据',
|
|
27
|
-
entity: '关联对象',
|
|
28
|
-
entityId: '关联对象id',
|
|
29
|
-
extra: '其它',
|
|
30
|
-
iState: '状态',
|
|
31
|
-
},
|
|
32
|
-
action: {
|
|
33
|
-
abandon: '放弃',
|
|
34
|
-
apply: '应用',
|
|
35
|
-
},
|
|
36
|
-
v: {
|
|
37
|
-
iState: {
|
|
38
|
-
active: '活跃的',
|
|
39
|
-
abandoned: '放弃的',
|
|
40
|
-
applied: '应用的',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
};
|
package/lib/entities/Uupdate.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
;
|
|
4
|
-
var IActionDef = {
|
|
5
|
-
stm: {
|
|
6
|
-
apply: ['active', 'applied'],
|
|
7
|
-
abandon: ['active', 'abandoned'],
|
|
8
|
-
},
|
|
9
|
-
is: 'active',
|
|
10
|
-
};
|
|
11
|
-
var indexes = [
|
|
12
|
-
{
|
|
13
|
-
name: 'index_state',
|
|
14
|
-
attributes: [
|
|
15
|
-
{
|
|
16
|
-
name: 'iState',
|
|
17
|
-
direction: 'ASC',
|
|
18
|
-
}
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
];
|
|
22
|
-
var locale = {
|
|
23
|
-
zh_CN: {
|
|
24
|
-
attr: {
|
|
25
|
-
action: '动作',
|
|
26
|
-
data: '数据',
|
|
27
|
-
entity: '关联对象',
|
|
28
|
-
entityId: '关联对象id',
|
|
29
|
-
extra: '其它',
|
|
30
|
-
iState: '状态',
|
|
31
|
-
},
|
|
32
|
-
action: {
|
|
33
|
-
abandon: '放弃',
|
|
34
|
-
apply: '应用',
|
|
35
|
-
},
|
|
36
|
-
v: {
|
|
37
|
-
iState: {
|
|
38
|
-
active: '活跃的',
|
|
39
|
-
abandoned: '放弃的',
|
|
40
|
-
applied: '应用的',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingHttpHeaders } from 'http';
|
|
3
|
-
import { EntityDict, OpRecord, RowStore, TxnOption, Context } from "../types";
|
|
4
|
-
export declare abstract class UniversalContext<ED extends EntityDict> implements Context<ED> {
|
|
5
|
-
rowStore: RowStore<ED, this>;
|
|
6
|
-
uuid?: string;
|
|
7
|
-
opRecords: OpRecord<ED>[];
|
|
8
|
-
private scene?;
|
|
9
|
-
private rwLock;
|
|
10
|
-
private headers?;
|
|
11
|
-
events: {
|
|
12
|
-
commit: Array<() => Promise<void>>;
|
|
13
|
-
rollback: Array<() => Promise<void>>;
|
|
14
|
-
};
|
|
15
|
-
constructor(store: RowStore<ED, UniversalContext<ED>>, headers?: IncomingHttpHeaders);
|
|
16
|
-
setHeaders(headers: IncomingHttpHeaders): void;
|
|
17
|
-
getHeader(key: string): string | string[] | undefined;
|
|
18
|
-
getScene(): string | undefined;
|
|
19
|
-
setScene(scene?: string): void;
|
|
20
|
-
private resetEvents;
|
|
21
|
-
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
|
22
|
-
/**
|
|
23
|
-
* 一个context中不应该有并发的事务,这里将事务串行化,使用的时候千万要注意不要自己等自己
|
|
24
|
-
* @param options
|
|
25
|
-
*/
|
|
26
|
-
begin(options?: TxnOption): Promise<void>;
|
|
27
|
-
commit(): Promise<void>;
|
|
28
|
-
rollback(): Promise<void>;
|
|
29
|
-
getCurrentTxnId(): string | undefined;
|
|
30
|
-
abstract toString(): Promise<string>;
|
|
31
|
-
abstract getCurrentUserId(allowUnloggedIn?: boolean): Promise<string | undefined>;
|
|
32
|
-
}
|
package/lib/store/action.d.ts
DELETED
package/lib/store/action.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLaterAction = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 判断一个action是不是延时性操作,如果是则返回动作本身
|
|
6
|
-
* @param action
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
function isLaterAction(action) {
|
|
10
|
-
if (action.endsWith('-l')) {
|
|
11
|
-
return action.slice(0, action.length - 2);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.isLaterAction = isLaterAction;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { StorageSchema } from '../types';
|
|
2
|
-
import { EntityDict } from '../types/Entity';
|
|
3
|
-
/**
|
|
4
|
-
* 对selection进行一些完善,避免编程人员的疏漏
|
|
5
|
-
* @param selection
|
|
6
|
-
*/
|
|
7
|
-
export declare function reinforceSelection<ED extends EntityDict>(schema: StorageSchema<ED>, entity: keyof ED, selection: ED[keyof ED]['Selection']): void;
|