oak-domain 5.0.8 → 5.0.9
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.
|
@@ -124,7 +124,13 @@ class LocaleBuilder {
|
|
|
124
124
|
const content = fs_1.default.readFileSync(filepath, {
|
|
125
125
|
encoding: 'utf-8',
|
|
126
126
|
});
|
|
127
|
-
|
|
127
|
+
try {
|
|
128
|
+
return JSON.parse(content);
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
console.error(`parse ${filepath} error`, err);
|
|
132
|
+
throw err;
|
|
133
|
+
}
|
|
128
134
|
}
|
|
129
135
|
parseFile(module, namespace, position, filename, filepath, watch) {
|
|
130
136
|
const language = (filename.split('.')[0]).replace('_', '-'); // 历史原因,会命名成zh_CN.json
|
|
@@ -584,7 +584,7 @@ function getImportedFilePath(path, fileSpecifierPath, filename) {
|
|
|
584
584
|
return '';
|
|
585
585
|
};
|
|
586
586
|
if (fileSpecifierPath.startsWith('.')) {
|
|
587
|
-
importedFilepath = path_1.default.join(
|
|
587
|
+
importedFilepath = path_1.default.join(path, fileSpecifierPath);
|
|
588
588
|
const importedFilename = getExistedFileName();
|
|
589
589
|
(0, assert_1.default)(importedFilename, `「${filename}」中import路径${fileSpecifierPath}找不到对应的声明`);
|
|
590
590
|
return importedFilename;
|
|
@@ -2236,7 +2236,7 @@ function constructOperations(statements, entity) {
|
|
|
2236
2236
|
}
|
|
2237
2237
|
if (manyToOneSet) {
|
|
2238
2238
|
for (const one of manyToOneSet) {
|
|
2239
|
-
if (
|
|
2239
|
+
if (one[1] !== 'entity') {
|
|
2240
2240
|
foreignKeyAttr.push(`${one[1]}Id`);
|
|
2241
2241
|
}
|
|
2242
2242
|
}
|
|
@@ -2260,7 +2260,7 @@ function constructOperations(statements, entity) {
|
|
|
2260
2260
|
*/
|
|
2261
2261
|
const upsertOneNodes = [];
|
|
2262
2262
|
for (const one of manyToOneSet) {
|
|
2263
|
-
if (
|
|
2263
|
+
if (one[1] !== 'entity') {
|
|
2264
2264
|
const oneEntity = one[0];
|
|
2265
2265
|
const cascadeCreateNode = factory.createTypeLiteralNode([
|
|
2266
2266
|
factory.createPropertySignature(undefined, factory.createIdentifier(`${one[1]}Id`), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)),
|
|
@@ -2472,7 +2472,7 @@ function constructOperations(statements, entity) {
|
|
|
2472
2472
|
}
|
|
2473
2473
|
if (manyToOneSet) {
|
|
2474
2474
|
for (const one of manyToOneSet) {
|
|
2475
|
-
if (
|
|
2475
|
+
if (one[1] !== 'entity') {
|
|
2476
2476
|
foreignKeyAttr.push(`${one[1]}Id`);
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
@@ -2494,7 +2494,7 @@ function constructOperations(statements, entity) {
|
|
|
2494
2494
|
*/
|
|
2495
2495
|
const upsertOneNodes = [];
|
|
2496
2496
|
for (const one of manyToOneSet) {
|
|
2497
|
-
if (
|
|
2497
|
+
if (one[1] !== 'entity') {
|
|
2498
2498
|
const cascadeCreateNode = factory.createTypeLiteralNode([
|
|
2499
2499
|
factory.createPropertySignature(undefined, factory.createIdentifier(one[1]), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(createForeignRef(entity, one[0], 'CreateSingleOperation'))),
|
|
2500
2500
|
factory.createPropertySignature(undefined, factory.createIdentifier(`${one[1]}Id`), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.NeverKeyword)),
|
|
@@ -2777,7 +2777,7 @@ function constructOperations(statements, entity) {
|
|
|
2777
2777
|
*/
|
|
2778
2778
|
const upsertOneNodes = [];
|
|
2779
2779
|
for (const one of manyToOneSet) {
|
|
2780
|
-
if (
|
|
2780
|
+
if (one[1] !== 'entity') {
|
|
2781
2781
|
if (!Schema[one[0]].static) {
|
|
2782
2782
|
switch (Schema[one[0]].actionType) {
|
|
2783
2783
|
case 'crud': {
|
package/lib/store/checker.js
CHANGED
|
@@ -48,6 +48,9 @@ function translateCheckerInAsyncContext(checker, schema) {
|
|
|
48
48
|
const fn = (async ({ operation }, context, option) => {
|
|
49
49
|
const { filter: operationFilter, data, action, bornAt } = operation;
|
|
50
50
|
const filter2 = typeof filter === 'function' ? await filter(operation, context, option) : filter;
|
|
51
|
+
if (!filter2) {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
51
54
|
if (['select', 'count', 'stat'].includes(action)) {
|
|
52
55
|
operation.filter = (0, filter_1.combineFilters)(entity, context.getSchema(), [operationFilter, filter2]);
|
|
53
56
|
return 0;
|
|
@@ -142,6 +145,9 @@ function translateCheckerInSyncContext(checker, schema) {
|
|
|
142
145
|
const fn = (operation, context, option) => {
|
|
143
146
|
const { filter: operationFilter, data, action, bornAt } = operation;
|
|
144
147
|
const filter2 = typeof filter === 'function' ? filter(operation, context, option) : filter;
|
|
148
|
+
if (!filter2) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
145
151
|
let operationFilter2 = operationFilter;
|
|
146
152
|
if (action === 'create') {
|
|
147
153
|
if (data) {
|
package/lib/types/Watcher.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReadOnlyAction } from "../actions/action";
|
|
1
2
|
import { AsyncContext } from "../store/AsyncRowStore";
|
|
2
3
|
import { EntityDict, OperationResult } from "./Entity";
|
|
3
4
|
type ActionData<ED extends EntityDict, T extends keyof ED> = ED[T]['Update']['data'] | ED[T]['Remove']['data'];
|
|
@@ -5,7 +6,7 @@ export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
|
|
5
6
|
name: string;
|
|
6
7
|
entity: T;
|
|
7
8
|
filter: ED[T]['Selection']['filter'] | (() => ED[T]['Selection']['filter']);
|
|
8
|
-
action: ED[T]['
|
|
9
|
+
action: Omit<ED[T]['Action'], 'create' | ReadOnlyAction>;
|
|
9
10
|
actionData: ActionData<ED, T> | (() => Promise<ActionData<ED, T>>);
|
|
10
11
|
}
|
|
11
12
|
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>> {
|