oak-domain 5.0.5 → 5.0.6
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.
|
@@ -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;
|
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
|
@@ -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
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.OakUserException = exports.OakRowUnexistedException = exports.OakOperExistedException = exports.OakNoRelationDefException = exports.OakImportDataParseException = exports.OakUniqueViolationException = exports.OakDataException = exports.OakMakeSureByMySelfException = exports.OakException = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
6
4
|
class OakException extends Error {
|
|
7
5
|
opRecords;
|
|
8
6
|
constructor(message) {
|
|
@@ -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': {
|