oak-domain 5.0.6 → 5.0.8
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/store/IntrinsicCheckers.js +0 -1
- package/lib/store/RelationAuth.js +1 -1
- package/lib/types/Exception.d.ts +15 -15
- package/lib/types/Exception.js +20 -20
- package/lib/utils/executor.d.ts +5 -0
- package/lib/utils/executor.js +22 -0
- package/lib/utils/money.d.ts +1 -1
- package/lib/utils/money.js +1 -1
- package/lib/utils/uuid.d.ts +2 -0
- package/lib/utils/uuid.js +15 -1
- package/package.json +1 -1
|
@@ -340,7 +340,6 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
if (f) {
|
|
343
|
-
const rr = (0, filter_1.contains)(entity, context.getSchema(), data, f);
|
|
344
343
|
const result = (0, filter_1.checkFilterContains)(entity, context, f, filter, true);
|
|
345
344
|
if (result instanceof Promise) {
|
|
346
345
|
return result.then((v) => {
|
|
@@ -475,7 +475,7 @@ class RelationAuth {
|
|
|
475
475
|
// extraFilter?: ED[T2]['Selection']['filter'],
|
|
476
476
|
path, child, hasParent, extraFilter) => {
|
|
477
477
|
const { action, data, filter } = operation;
|
|
478
|
-
const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : (0, lodash_1.cloneDeep)(filter);
|
|
478
|
+
const filter2 = action === 'create' ? makeCreateFilter(entity, operation) : filter ? (0, lodash_1.cloneDeep)(filter) : {};
|
|
479
479
|
(0, assert_1.default)(filter2);
|
|
480
480
|
if (extraFilter) {
|
|
481
481
|
Object.assign(filter2, extraFilter);
|
package/lib/types/Exception.d.ts
CHANGED
|
@@ -15,21 +15,6 @@ export declare class OakMakeSureByMySelfException<ED extends EntityDict> extends
|
|
|
15
15
|
}
|
|
16
16
|
export declare class OakDataException<ED extends EntityDict> extends OakException<ED> {
|
|
17
17
|
}
|
|
18
|
-
export declare class OakUniqueViolationException<ED extends EntityDict> extends OakException<ED> {
|
|
19
|
-
rows: Array<{
|
|
20
|
-
id?: string;
|
|
21
|
-
attrs: string[];
|
|
22
|
-
}>;
|
|
23
|
-
constructor(rows: Array<{
|
|
24
|
-
id?: string;
|
|
25
|
-
attrs: string[];
|
|
26
|
-
}>, message?: string);
|
|
27
|
-
}
|
|
28
|
-
export declare class OakImportDataParseException<ED extends EntityDict> extends OakException<ED> {
|
|
29
|
-
line: number;
|
|
30
|
-
header?: string;
|
|
31
|
-
constructor(message: string, line: number, header?: string);
|
|
32
|
-
}
|
|
33
18
|
export declare class OakNoRelationDefException<ED extends EntityDict, T extends keyof ED> extends OakDataException<ED> {
|
|
34
19
|
entity: T;
|
|
35
20
|
actions: ED[T]['Action'][];
|
|
@@ -55,6 +40,21 @@ export declare class OakRowUnexistedException<ED extends EntityDict> extends Oak
|
|
|
55
40
|
*/
|
|
56
41
|
export declare class OakUserException<ED extends EntityDict> extends OakException<ED> {
|
|
57
42
|
}
|
|
43
|
+
export declare class OakUniqueViolationException<ED extends EntityDict> extends OakUserException<ED> {
|
|
44
|
+
rows: Array<{
|
|
45
|
+
id?: string;
|
|
46
|
+
attrs: string[];
|
|
47
|
+
}>;
|
|
48
|
+
constructor(rows: Array<{
|
|
49
|
+
id?: string;
|
|
50
|
+
attrs: string[];
|
|
51
|
+
}>, message?: string);
|
|
52
|
+
}
|
|
53
|
+
export declare class OakImportDataParseException<ED extends EntityDict> extends OakUserException<ED> {
|
|
54
|
+
line: number;
|
|
55
|
+
header?: string;
|
|
56
|
+
constructor(message: string, line: number, header?: string);
|
|
57
|
+
}
|
|
58
58
|
/**
|
|
59
59
|
* 网络中断异常
|
|
60
60
|
*/
|
package/lib/types/Exception.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserInvisibleException = exports.OakUserUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakServerProxyException = exports.OakNetworkException = exports.
|
|
3
|
+
exports.makeException = exports.OakExternalException = exports.OakPreConditionUnsetException = exports.OakDeadlock = exports.OakCongruentRowExists = exports.OakRowLockedException = exports.OakUnloggedInException = exports.OakUserInvisibleException = exports.OakUserUnpermittedException = exports.OakAttrCantUpdateException = exports.OakAttrNotNullException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakServerProxyException = exports.OakNetworkException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakDataException = exports.OakMakeSureByMySelfException = exports.OakException = void 0;
|
|
4
4
|
class OakException extends Error {
|
|
5
5
|
opRecords;
|
|
6
6
|
constructor(message) {
|
|
@@ -51,25 +51,6 @@ exports.OakMakeSureByMySelfException = OakMakeSureByMySelfException;
|
|
|
51
51
|
class OakDataException extends OakException {
|
|
52
52
|
}
|
|
53
53
|
exports.OakDataException = OakDataException;
|
|
54
|
-
class OakUniqueViolationException extends OakException {
|
|
55
|
-
rows;
|
|
56
|
-
constructor(rows, message) {
|
|
57
|
-
super(message || '您更新的数据违反了唯一性约束');
|
|
58
|
-
this.rows = rows;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.OakUniqueViolationException = OakUniqueViolationException;
|
|
62
|
-
class OakImportDataParseException extends OakException {
|
|
63
|
-
line;
|
|
64
|
-
header;
|
|
65
|
-
// message必传,描述具体错误的数据内容
|
|
66
|
-
constructor(message, line, header) {
|
|
67
|
-
super(message);
|
|
68
|
-
this.line = line;
|
|
69
|
-
this.header = header;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.OakImportDataParseException = OakImportDataParseException;
|
|
73
54
|
class OakNoRelationDefException extends OakDataException {
|
|
74
55
|
entity;
|
|
75
56
|
actions;
|
|
@@ -117,6 +98,25 @@ class OakUserException extends OakException {
|
|
|
117
98
|
}
|
|
118
99
|
exports.OakUserException = OakUserException;
|
|
119
100
|
;
|
|
101
|
+
class OakUniqueViolationException extends OakUserException {
|
|
102
|
+
rows;
|
|
103
|
+
constructor(rows, message) {
|
|
104
|
+
super(message || '您更新的数据违反了唯一性约束');
|
|
105
|
+
this.rows = rows;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.OakUniqueViolationException = OakUniqueViolationException;
|
|
109
|
+
class OakImportDataParseException extends OakUserException {
|
|
110
|
+
line;
|
|
111
|
+
header;
|
|
112
|
+
// message必传,描述具体错误的数据内容
|
|
113
|
+
constructor(message, line, header) {
|
|
114
|
+
super(message);
|
|
115
|
+
this.line = line;
|
|
116
|
+
this.header = header;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.OakImportDataParseException = OakImportDataParseException;
|
|
120
120
|
/**
|
|
121
121
|
* 网络中断异常
|
|
122
122
|
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pipeline = void 0;
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param units 各个执行单元,需要流水线执行,可能是同步也可能是异步
|
|
7
|
+
*/
|
|
8
|
+
function pipeline(...units) {
|
|
9
|
+
const exec = (idx, resultPrev) => {
|
|
10
|
+
const unit = units[idx];
|
|
11
|
+
if (!unit) {
|
|
12
|
+
return resultPrev;
|
|
13
|
+
}
|
|
14
|
+
const result = unit(resultPrev);
|
|
15
|
+
if (result instanceof Promise) {
|
|
16
|
+
return result.then((resultSync) => exec(idx + 1, resultSync));
|
|
17
|
+
}
|
|
18
|
+
return exec(idx + 1, result);
|
|
19
|
+
};
|
|
20
|
+
return exec(0);
|
|
21
|
+
}
|
|
22
|
+
exports.pipeline = pipeline;
|
package/lib/utils/money.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ declare const ToCent: (float: number) => number;
|
|
|
2
2
|
declare const ToYuan: (int: number) => number;
|
|
3
3
|
declare const StringToCent: (value: string, allowNegative?: true) => number | undefined;
|
|
4
4
|
declare const CentToString: (value: number, fixed?: number) => string | undefined;
|
|
5
|
-
declare const ThousandCont: (value: number, decimalPlaces?: number) => string | undefined;
|
|
5
|
+
declare const ThousandCont: (value: number | string, decimalPlaces?: number) => string | undefined;
|
|
6
6
|
export { ToCent, ToYuan, StringToCent, CentToString, ThousandCont };
|
package/lib/utils/money.js
CHANGED
|
@@ -23,7 +23,7 @@ const CentToString = (value, fixed) => {
|
|
|
23
23
|
};
|
|
24
24
|
exports.CentToString = CentToString;
|
|
25
25
|
const ThousandCont = (value, decimalPlaces) => {
|
|
26
|
-
let value1 = `${value}
|
|
26
|
+
let value1 = typeof value === 'number' ? `${value}` : value;
|
|
27
27
|
const numArr = value1.split('.');
|
|
28
28
|
value1 = numArr[0];
|
|
29
29
|
let result = '';
|
package/lib/utils/uuid.d.ts
CHANGED
|
@@ -15,3 +15,5 @@ export declare function generateNewId(): string;
|
|
|
15
15
|
* @param: input: 输入的数据数组,应保证唯一性
|
|
16
16
|
*/
|
|
17
17
|
export declare function formUuid(...input: string[]): string;
|
|
18
|
+
export declare function compressTo32(uuid: string): string;
|
|
19
|
+
export declare function decompressFrom32(compressed: string): string;
|
package/lib/utils/uuid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formUuid = exports.generateNewId = exports.setGenerateIdOption = exports.produceIds = exports.generateNewIdAsync = exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = exports.sequentialUuid = void 0;
|
|
3
|
+
exports.decompressFrom32 = exports.compressTo32 = exports.formUuid = exports.generateNewId = exports.setGenerateIdOption = exports.produceIds = exports.generateNewIdAsync = exports.expandUuidTo36Bytes = exports.shrinkUuidTo32Bytes = exports.sequentialUuid = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const random_1 = require("./random/random");
|
|
6
6
|
let _nodeId;
|
|
@@ -216,3 +216,17 @@ function formUuid(...input) {
|
|
|
216
216
|
return unsafeStringify(b);
|
|
217
217
|
}
|
|
218
218
|
exports.formUuid = formUuid;
|
|
219
|
+
function compressTo32(uuid) {
|
|
220
|
+
return uuid.replace(/-/g, '');
|
|
221
|
+
}
|
|
222
|
+
exports.compressTo32 = compressTo32;
|
|
223
|
+
function decompressFrom32(compressed) {
|
|
224
|
+
return [
|
|
225
|
+
compressed.slice(0, 8),
|
|
226
|
+
compressed.slice(8, 12),
|
|
227
|
+
compressed.slice(12, 16),
|
|
228
|
+
compressed.slice(16, 20),
|
|
229
|
+
compressed.slice(20)
|
|
230
|
+
].join('-');
|
|
231
|
+
}
|
|
232
|
+
exports.decompressFrom32 = decompressFrom32;
|