oak-domain 5.0.5 → 5.0.7
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/compiler/schemalBuilder.js +42 -39
- package/lib/store/AsyncRowStore.js +1 -1
- package/lib/store/IntrinsicCheckers.js +0 -1
- package/lib/store/RelationAuth.js +1 -1
- package/lib/store/checker.js +7 -7
- package/lib/store/filter.js +12 -7
- package/lib/types/Entity.d.ts +1 -1
- package/lib/types/Exception.d.ts +15 -16
- package/lib/types/Exception.js +21 -27
- 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/package.json +1 -1
|
@@ -572,51 +572,54 @@ function analyzeImportDeclaration(node, referencedSchemas, additionalImports, fi
|
|
|
572
572
|
* @param filename
|
|
573
573
|
* @returns
|
|
574
574
|
*/
|
|
575
|
-
function
|
|
576
|
-
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
575
|
+
function getImportedFilePath(path, fileSpecifierPath, filename) {
|
|
576
|
+
let importedFilepath = '';
|
|
577
|
+
const getExistedFileName = () => {
|
|
578
|
+
if ((0, fs_1.existsSync)(`${importedFilepath}.ts`)) {
|
|
579
|
+
return `${importedFilepath}.ts`;
|
|
580
|
+
}
|
|
581
|
+
else if ((0, fs_1.existsSync)(`${importedFilepath}.d.ts`)) {
|
|
582
|
+
return `${importedFilepath}.d.ts`;
|
|
583
|
+
}
|
|
584
|
+
return '';
|
|
585
|
+
};
|
|
586
|
+
if (fileSpecifierPath.startsWith('.')) {
|
|
587
|
+
importedFilepath = path_1.default.join(process.cwd(), path, fileSpecifierPath);
|
|
588
|
+
const importedFilename = getExistedFileName();
|
|
589
|
+
(0, assert_1.default)(importedFilename, `「${filename}」中import路径${fileSpecifierPath}找不到对应的声明`);
|
|
590
|
+
return importedFilename;
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
const cwd = process.cwd();
|
|
594
|
+
const fileSpecifierPaths = fileSpecifierPath.split('/');
|
|
595
|
+
const moduleName = fileSpecifierPaths[0] || fileSpecifierPaths[1];
|
|
596
|
+
(0, assert_1.default)(moduleName);
|
|
597
|
+
// 从path向外找package.json -> node_modules直至找到fileSpecifier
|
|
598
|
+
const paths = path.split('/');
|
|
599
|
+
for (let iter = paths.length; iter >= 0; iter--) {
|
|
600
|
+
const paths2 = paths.slice(0, iter);
|
|
601
|
+
const pkgJsonPath = path_1.default.join(cwd, ...paths2, 'package.json');
|
|
602
|
+
if ((0, fs_1.existsSync)(pkgJsonPath)) {
|
|
603
|
+
const pkgJson = require(pkgJsonPath);
|
|
604
|
+
if (pkgJson.dependencies?.hasOwnProperty(moduleName)) {
|
|
605
|
+
const dependentPath = pkgJson.dependencies[moduleName];
|
|
606
|
+
if (dependentPath.trimStart().startsWith('file:')) {
|
|
607
|
+
const dependentFilePath = dependentPath.trimStart().slice(5);
|
|
608
|
+
importedFilepath = path_1.default.join(pkgJsonPath, '..', dependentFilePath, ...(fileSpecifierPaths[0] ? fileSpecifierPaths.slice(1) : (fileSpecifierPaths.slice(2))));
|
|
609
|
+
}
|
|
610
|
+
else {
|
|
611
|
+
importedFilepath = path_1.default.join(pkgJsonPath, '..', 'node_modules', fileSpecifierPath);
|
|
612
|
+
}
|
|
613
|
+
const importedFilename = getExistedFileName();
|
|
614
|
+
if (importedFilename) {
|
|
615
|
+
return importedFilename;
|
|
616
|
+
}
|
|
595
617
|
}
|
|
596
618
|
}
|
|
597
619
|
}
|
|
598
620
|
}
|
|
599
621
|
(0, assert_1.default)(false, `「${filename}」中import路径${fileSpecifierPath}找不到对应的声明`);
|
|
600
622
|
}
|
|
601
|
-
/**
|
|
602
|
-
* 获得import的某个文件的绝对路径
|
|
603
|
-
* @param path
|
|
604
|
-
* @param fileSpecifierPath
|
|
605
|
-
* @returns
|
|
606
|
-
*/
|
|
607
|
-
function getImportedFilePath(path, fileSpecifierPath, filename) {
|
|
608
|
-
let importedFilename = fileSpecifierPath.startsWith('.') ? path_1.default.join(process.cwd(), path, fileSpecifierPath) : searchImportedPath(path, fileSpecifierPath, filename);
|
|
609
|
-
if ((0, fs_1.existsSync)(`${importedFilename}.ts`)) {
|
|
610
|
-
return `${importedFilename}.ts`;
|
|
611
|
-
}
|
|
612
|
-
else if ((0, fs_1.existsSync)(`${importedFilename}.d.ts`)) {
|
|
613
|
-
return `${importedFilename}.d.ts`;
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
// 目前不可能引用js文件
|
|
617
|
-
(0, assert_1.default)(false, `「${filename}」import路径${fileSpecifierPath}找不到对应的文件`);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
623
|
function analyzeSchemaDefinition(node, moduleName, filename, path, program, referencedSchemas, schemaAttrs, enumAttributes, importAttrFrom, relativePath) {
|
|
621
624
|
let hasEntityAttr = false;
|
|
622
625
|
let hasEntityIdAttr = false;
|
|
@@ -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/store/checker.js
CHANGED
|
@@ -63,7 +63,7 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|
|
63
63
|
dontCollect: true,
|
|
64
64
|
blockTrigger: true,
|
|
65
65
|
});
|
|
66
|
-
const e = new Exception_1.OakRowInconsistencyException(
|
|
66
|
+
const e = new Exception_1.OakRowInconsistencyException(errMsg);
|
|
67
67
|
e.addData(entity2, rows2);
|
|
68
68
|
throw e;
|
|
69
69
|
}
|
|
@@ -78,7 +78,7 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|
|
78
78
|
dontCollect: true,
|
|
79
79
|
blockTrigger: true,
|
|
80
80
|
}); */
|
|
81
|
-
const e = new Exception_1.OakRowInconsistencyException(
|
|
81
|
+
const e = new Exception_1.OakRowInconsistencyException(errMsg);
|
|
82
82
|
// e.addData(entity, rows2);
|
|
83
83
|
throw e;
|
|
84
84
|
}
|
|
@@ -156,7 +156,7 @@ function translateCheckerInSyncContext(checker, schema) {
|
|
|
156
156
|
if ((0, filter_1.checkFilterContains)(entity, context, filter2, operationFilter2, true)) {
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
|
-
const e = new Exception_1.OakRowInconsistencyException(
|
|
159
|
+
const e = new Exception_1.OakRowInconsistencyException(errMsg || 'row checker condition illegal');
|
|
160
160
|
throw e;
|
|
161
161
|
};
|
|
162
162
|
return {
|
|
@@ -258,7 +258,7 @@ function createRemoveCheckers(schema) {
|
|
|
258
258
|
if (result instanceof Promise) {
|
|
259
259
|
promises.push(result.then(([row]) => {
|
|
260
260
|
if (row) {
|
|
261
|
-
const err = new Exception_1.OakRowInconsistencyException(
|
|
261
|
+
const err = new Exception_1.OakRowInconsistencyException(`您无法删除存在有效数据「${e}」关联的行`);
|
|
262
262
|
err.addData(e, [row]);
|
|
263
263
|
throw err;
|
|
264
264
|
}
|
|
@@ -267,7 +267,7 @@ function createRemoveCheckers(schema) {
|
|
|
267
267
|
else {
|
|
268
268
|
const [row] = result;
|
|
269
269
|
if (row) {
|
|
270
|
-
const err = new Exception_1.OakRowInconsistencyException(
|
|
270
|
+
const err = new Exception_1.OakRowInconsistencyException(`您无法删除存在有效数据「${e}」关联的行`);
|
|
271
271
|
err.addData(e, [row]);
|
|
272
272
|
throw err;
|
|
273
273
|
}
|
|
@@ -293,7 +293,7 @@ function createRemoveCheckers(schema) {
|
|
|
293
293
|
if (result instanceof Promise) {
|
|
294
294
|
promises.push(result.then(([row]) => {
|
|
295
295
|
if (row) {
|
|
296
|
-
const e = new Exception_1.OakRowInconsistencyException(
|
|
296
|
+
const e = new Exception_1.OakRowInconsistencyException(`您无法删除存在有效数据「${otm}」关联的行`);
|
|
297
297
|
e.addData(otm, [row]);
|
|
298
298
|
throw e;
|
|
299
299
|
}
|
|
@@ -310,7 +310,7 @@ function createRemoveCheckers(schema) {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
|
-
const e = new Exception_1.OakRowInconsistencyException(
|
|
313
|
+
const e = new Exception_1.OakRowInconsistencyException(`您无法删除存在有效数据「${otm}」关联的行`);
|
|
314
314
|
e.addData(otm, [row]);
|
|
315
315
|
throw e;
|
|
316
316
|
}
|
package/lib/store/filter.js
CHANGED
|
@@ -12,7 +12,16 @@ function translateCreateDataToFilter(schema, entity, data, allowUnrecoganized) {
|
|
|
12
12
|
const rel = (0, relation_1.judgeRelation)(schema, entity, attr, allowUnrecoganized);
|
|
13
13
|
if (rel === 1) {
|
|
14
14
|
// 只需要记住id和各种外键属性,不这样处理有些古怪的属性比如coordinate,其作为createdata和作为filter并不同构
|
|
15
|
-
if (![
|
|
15
|
+
if (![
|
|
16
|
+
'geometry',
|
|
17
|
+
'geography',
|
|
18
|
+
'st_geometry',
|
|
19
|
+
'st_point',
|
|
20
|
+
'function',
|
|
21
|
+
'sequence',
|
|
22
|
+
'array',
|
|
23
|
+
'object'
|
|
24
|
+
].includes(schema[entity].attributes[attr]?.type)) {
|
|
16
25
|
data2[attr] = data[attr];
|
|
17
26
|
}
|
|
18
27
|
}
|
|
@@ -1602,9 +1611,7 @@ function checkDeduceFilters(dfc, context) {
|
|
|
1602
1611
|
* @returns
|
|
1603
1612
|
*/
|
|
1604
1613
|
function checkFilterContains(entity, context, contained, filter, dataCompare, warningOnDataCompare) {
|
|
1605
|
-
|
|
1606
|
-
throw new types_1.OakRowInconsistencyException();
|
|
1607
|
-
}
|
|
1614
|
+
(0, assert_1.default)(filter);
|
|
1608
1615
|
const schema = context.getSchema();
|
|
1609
1616
|
const result = contains(entity, schema, filter, contained);
|
|
1610
1617
|
if (typeof result === 'boolean') {
|
|
@@ -1620,9 +1627,7 @@ function checkFilterContains(entity, context, contained, filter, dataCompare, wa
|
|
|
1620
1627
|
}
|
|
1621
1628
|
exports.checkFilterContains = checkFilterContains;
|
|
1622
1629
|
function checkFilterRepel(entity, context, filter1, filter2, dataCompare, warningOnDataCompare) {
|
|
1623
|
-
|
|
1624
|
-
throw new types_1.OakRowInconsistencyException();
|
|
1625
|
-
}
|
|
1630
|
+
(0, assert_1.default)(filter2);
|
|
1626
1631
|
const schema = context.getSchema();
|
|
1627
1632
|
const result = repel(entity, schema, filter2, filter1);
|
|
1628
1633
|
if (typeof result === 'boolean') {
|
package/lib/types/Entity.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ export type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
|
153
153
|
};
|
|
154
154
|
export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
155
155
|
id: string;
|
|
156
|
-
a:
|
|
156
|
+
a: string;
|
|
157
157
|
e: T;
|
|
158
158
|
d: UpdateOperationData;
|
|
159
159
|
f?: Filter;
|
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
|
*/
|
|
@@ -67,7 +67,6 @@ export declare class OakServerProxyException<ED extends EntityDict> extends OakE
|
|
|
67
67
|
*
|
|
68
68
|
*/
|
|
69
69
|
export declare class OakRowInconsistencyException<ED extends EntityDict> extends OakUserException<ED> {
|
|
70
|
-
constructor(data?: OpRecord<ED>, message?: string);
|
|
71
70
|
toString(): string;
|
|
72
71
|
}
|
|
73
72
|
/**
|
package/lib/types/Exception.js
CHANGED
|
@@ -1,8 +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.
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
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;
|
|
6
4
|
class OakException extends Error {
|
|
7
5
|
opRecords;
|
|
8
6
|
constructor(message) {
|
|
@@ -53,25 +51,6 @@ exports.OakMakeSureByMySelfException = OakMakeSureByMySelfException;
|
|
|
53
51
|
class OakDataException extends OakException {
|
|
54
52
|
}
|
|
55
53
|
exports.OakDataException = OakDataException;
|
|
56
|
-
class OakUniqueViolationException extends OakException {
|
|
57
|
-
rows;
|
|
58
|
-
constructor(rows, message) {
|
|
59
|
-
super(message || '您更新的数据违反了唯一性约束');
|
|
60
|
-
this.rows = rows;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
exports.OakUniqueViolationException = OakUniqueViolationException;
|
|
64
|
-
class OakImportDataParseException extends OakException {
|
|
65
|
-
line;
|
|
66
|
-
header;
|
|
67
|
-
// message必传,描述具体错误的数据内容
|
|
68
|
-
constructor(message, line, header) {
|
|
69
|
-
super(message);
|
|
70
|
-
this.line = line;
|
|
71
|
-
this.header = header;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.OakImportDataParseException = OakImportDataParseException;
|
|
75
54
|
class OakNoRelationDefException extends OakDataException {
|
|
76
55
|
entity;
|
|
77
56
|
actions;
|
|
@@ -119,6 +98,25 @@ class OakUserException extends OakException {
|
|
|
119
98
|
}
|
|
120
99
|
exports.OakUserException = OakUserException;
|
|
121
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;
|
|
122
120
|
/**
|
|
123
121
|
* 网络中断异常
|
|
124
122
|
*/
|
|
@@ -135,10 +133,6 @@ exports.OakServerProxyException = OakServerProxyException;
|
|
|
135
133
|
*
|
|
136
134
|
*/
|
|
137
135
|
class OakRowInconsistencyException extends OakUserException {
|
|
138
|
-
constructor(data, message) {
|
|
139
|
-
super(message);
|
|
140
|
-
(0, assert_1.default)(!data, '现在使用addData接口来传数据');
|
|
141
|
-
}
|
|
142
136
|
toString() {
|
|
143
137
|
const data = super.getSerialData();
|
|
144
138
|
return JSON.stringify(data);
|
|
@@ -354,7 +348,7 @@ function makeException(data) {
|
|
|
354
348
|
break;
|
|
355
349
|
}
|
|
356
350
|
case 'OakRowInconsistencyException': {
|
|
357
|
-
e = new OakRowInconsistencyException(data.
|
|
351
|
+
e = new OakRowInconsistencyException(data.message);
|
|
358
352
|
break;
|
|
359
353
|
}
|
|
360
354
|
case 'OakInputIllegalException': {
|
|
@@ -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 = '';
|