checkOperation仍然可能返回OakException
This commit is contained in:
parent
44101a5fc5
commit
d9fe9f2e3c
|
|
@ -3,6 +3,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { Feature } from '../types/Feature';
|
||||
import { CacheStore } from '../cacheStore/CacheStore';
|
||||
import { OakUserException } from 'oak-domain/lib/types/Exception';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { LocalStorage } from './localStorage';
|
||||
|
|
@ -93,7 +94,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends A
|
|||
action: ED[T]['Action'];
|
||||
data?: ED[T]['Operation']['data'];
|
||||
filter?: ED[T]['Operation']['filter'];
|
||||
}, checkerTypes?: CheckerType[]): boolean;
|
||||
}, checkerTypes?: CheckerType[]): true | OakUserException<ED>;
|
||||
redoOperation(opers: Array<{
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ export class Cache extends Feature {
|
|||
if (!(err instanceof OakUserException)) {
|
||||
throw err;
|
||||
}
|
||||
return false;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
redoOperation(opers) {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ export class ContextMenuFactory extends Feature {
|
|||
'row',
|
||||
]);
|
||||
if (checkResult) {
|
||||
result = checkResult;
|
||||
result = checkResult === true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1889,14 +1889,6 @@ export class RunningTree extends Feature {
|
|||
assert(node instanceof ListNode || node instanceof SingleNode);
|
||||
return node.getIntrinsticFilters();
|
||||
}
|
||||
/* tryExecute(path: string) {
|
||||
const node = this.findNode(path);
|
||||
const operations = node?.composeOperations();
|
||||
if (operations && operations.length > 0) {
|
||||
return this.cache.tryRedoOperations(operations);
|
||||
}
|
||||
return false;
|
||||
} */
|
||||
getOperations(path) {
|
||||
const node = this.findNode(path);
|
||||
const operations = node?.composeOperations();
|
||||
|
|
|
|||
|
|
@ -217,8 +217,9 @@ const oakBehavior = Behavior({
|
|||
if (operations) {
|
||||
for (const oper of operations) {
|
||||
const { entity, operation } = oper;
|
||||
if (!this.checkOperation(entity, operation)) {
|
||||
return false;
|
||||
const result = this.checkOperation(entity, operation);
|
||||
if (result !== true) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
|
|||
}[] | undefined): Promise<void>;
|
||||
isDirty(path?: string | undefined): boolean;
|
||||
getFreshValue(path?: string | undefined): Partial<ED[keyof ED]["Schema"]> | Partial<ED[keyof ED]["Schema"]>[] | undefined;
|
||||
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean;
|
||||
tryExecute(path?: string | undefined): boolean;
|
||||
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean | import("oak-domain/lib/types").OakUserException<ED>;
|
||||
tryExecute(path?: string | undefined): boolean | import("oak-domain/lib/types").OakUserException<ED>;
|
||||
getOperations<T_5 extends keyof ED>(path?: string | undefined): {
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]["Operation"];
|
||||
|
|
|
|||
|
|
@ -188,8 +188,9 @@ class OakComponentBase extends React.PureComponent {
|
|||
if (operations) {
|
||||
for (const oper of operations) {
|
||||
const { entity, operation } = oper;
|
||||
if (!this.checkOperation(entity, operation)) {
|
||||
return false;
|
||||
const result = this.checkOperation(entity, operation);
|
||||
if (result !== true) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference types="wechat-miniprogram" />
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
import { Aspect, EntityDict, CheckerType, AggregationResult, OpRecord } from "oak-domain/lib/types";
|
||||
import { Aspect, EntityDict, CheckerType, AggregationResult, OpRecord, OakUserException } from "oak-domain/lib/types";
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { Feature } from './Feature';
|
||||
|
|
@ -168,8 +168,8 @@ export type OakCommonComponentMethods<ED extends EntityDict & BaseEntityDict, T
|
|||
action: ED[T2]['Action'];
|
||||
data?: ED[T2]['Operation']['data'];
|
||||
filter?: ED[T2]['Operation']['filter'];
|
||||
}, checkerTypes?: (CheckerType | 'relation')[]) => boolean;
|
||||
tryExecute: (path?: string) => boolean | Error;
|
||||
}, checkerTypes?: (CheckerType | 'relation')[]) => boolean | OakUserException<ED>;
|
||||
tryExecute: (path?: string) => boolean | OakUserException<ED>;
|
||||
getOperations: (path?: string) => {
|
||||
operation: ED[T]['Operation'];
|
||||
entity: T;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { Feature } from '../types/Feature';
|
||||
import { CacheStore } from '../cacheStore/CacheStore';
|
||||
import { OakUserException } from 'oak-domain/lib/types/Exception';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { LocalStorage } from './localStorage';
|
||||
|
|
@ -93,7 +94,7 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict, Cxt extends A
|
|||
action: ED[T]['Action'];
|
||||
data?: ED[T]['Operation']['data'];
|
||||
filter?: ED[T]['Operation']['filter'];
|
||||
}, checkerTypes?: CheckerType[]): boolean;
|
||||
}, checkerTypes?: CheckerType[]): true | OakUserException<ED>;
|
||||
redoOperation(opers: Array<{
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]['Operation'];
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ class Cache extends Feature_1.Feature {
|
|||
if (!(err instanceof Exception_1.OakUserException)) {
|
||||
throw err;
|
||||
}
|
||||
return false;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
redoOperation(opers) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class ContextMenuFactory extends Feature_1.Feature {
|
|||
'row',
|
||||
]);
|
||||
if (checkResult) {
|
||||
result = checkResult;
|
||||
result = checkResult === true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1892,14 +1892,6 @@ class RunningTree extends Feature_1.Feature {
|
|||
(0, assert_1.assert)(node instanceof ListNode || node instanceof SingleNode);
|
||||
return node.getIntrinsticFilters();
|
||||
}
|
||||
/* tryExecute(path: string) {
|
||||
const node = this.findNode(path);
|
||||
const operations = node?.composeOperations();
|
||||
if (operations && operations.length > 0) {
|
||||
return this.cache.tryRedoOperations(operations);
|
||||
}
|
||||
return false;
|
||||
} */
|
||||
getOperations(path) {
|
||||
const node = this.findNode(path);
|
||||
const operations = node?.composeOperations();
|
||||
|
|
|
|||
|
|
@ -220,8 +220,9 @@ const oakBehavior = Behavior({
|
|||
if (operations) {
|
||||
for (const oper of operations) {
|
||||
const { entity, operation } = oper;
|
||||
if (!this.checkOperation(entity, operation)) {
|
||||
return false;
|
||||
const result = this.checkOperation(entity, operation);
|
||||
if (result !== true) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
|
|||
}[] | undefined): Promise<void>;
|
||||
isDirty(path?: string | undefined): boolean;
|
||||
getFreshValue(path?: string | undefined): Partial<ED[keyof ED]["Schema"]> | Partial<ED[keyof ED]["Schema"]>[] | undefined;
|
||||
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean;
|
||||
tryExecute(path?: string | undefined): boolean;
|
||||
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean | import("oak-domain/lib/types").OakUserException<ED>;
|
||||
tryExecute(path?: string | undefined): boolean | import("oak-domain/lib/types").OakUserException<ED>;
|
||||
getOperations<T_5 extends keyof ED>(path?: string | undefined): {
|
||||
entity: keyof ED;
|
||||
operation: ED[keyof ED]["Operation"];
|
||||
|
|
|
|||
|
|
@ -193,8 +193,9 @@ class OakComponentBase extends react_1.default.PureComponent {
|
|||
if (operations) {
|
||||
for (const oper of operations) {
|
||||
const { entity, operation } = oper;
|
||||
if (!this.checkOperation(entity, operation)) {
|
||||
return false;
|
||||
const result = this.checkOperation(entity, operation);
|
||||
if (result !== true) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/// <reference types="wechat-miniprogram" />
|
||||
/// <reference types="wechat-miniprogram" />
|
||||
import { Aspect, EntityDict, CheckerType, AggregationResult, OpRecord } from "oak-domain/lib/types";
|
||||
import { Aspect, EntityDict, CheckerType, AggregationResult, OpRecord, OakUserException } from "oak-domain/lib/types";
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { Feature } from './Feature';
|
||||
|
|
@ -168,8 +168,8 @@ export type OakCommonComponentMethods<ED extends EntityDict & BaseEntityDict, T
|
|||
action: ED[T2]['Action'];
|
||||
data?: ED[T2]['Operation']['data'];
|
||||
filter?: ED[T2]['Operation']['filter'];
|
||||
}, checkerTypes?: (CheckerType | 'relation')[]) => boolean;
|
||||
tryExecute: (path?: string) => boolean | Error;
|
||||
}, checkerTypes?: (CheckerType | 'relation')[]) => boolean | OakUserException<ED>;
|
||||
tryExecute: (path?: string) => boolean | OakUserException<ED>;
|
||||
getOperations: (path?: string) => {
|
||||
operation: ED[T]['Operation'];
|
||||
entity: T;
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ export class Cache<
|
|||
if (!(err instanceof OakUserException)) {
|
||||
throw err;
|
||||
}
|
||||
return false;
|
||||
return err as OakUserException<ED>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ export class ContextMenuFactory<
|
|||
);
|
||||
|
||||
if (checkResult) {
|
||||
result = checkResult;
|
||||
result = checkResult === true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2341,15 +2341,6 @@ export class RunningTree<
|
|||
return node.getIntrinsticFilters();
|
||||
}
|
||||
|
||||
/* tryExecute(path: string) {
|
||||
const node = this.findNode(path);
|
||||
const operations = node?.composeOperations();
|
||||
if (operations && operations.length > 0) {
|
||||
return this.cache.tryRedoOperations(operations);
|
||||
}
|
||||
return false;
|
||||
} */
|
||||
|
||||
getOperations(path: string) {
|
||||
const node = this.findNode(path);
|
||||
const operations = node?.composeOperations();
|
||||
|
|
|
|||
|
|
@ -363,8 +363,9 @@ const oakBehavior = Behavior<
|
|||
if (operations) {
|
||||
for (const oper of operations) {
|
||||
const { entity, operation } = oper;
|
||||
if (!this.checkOperation(entity, operation)) {
|
||||
return false;
|
||||
const result = this.checkOperation(entity, operation);
|
||||
if (result !== true) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -366,8 +366,9 @@ abstract class OakComponentBase<
|
|||
if (operations) {
|
||||
for (const oper of operations) {
|
||||
const { entity, operation } = oper;
|
||||
if (!this.checkOperation(entity, operation)) {
|
||||
return false;
|
||||
const result = this.checkOperation(entity, operation);
|
||||
if (result !== true) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Aspect, EntityDict, CheckerType, AggregationResult, SubDataDef, OpRecord } from "oak-domain/lib/types";
|
||||
import { Aspect, EntityDict, CheckerType, AggregationResult, SubDataDef, OpRecord, OakUserException } from "oak-domain/lib/types";
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { Feature } from './Feature';
|
||||
|
|
@ -397,8 +397,8 @@ export type OakCommonComponentMethods<
|
|||
filter?: ED[T2]['Operation']['filter'],
|
||||
},
|
||||
checkerTypes?: (CheckerType | 'relation')[]
|
||||
) => boolean;
|
||||
tryExecute: (path?: string) => boolean | Error;
|
||||
) => boolean | OakUserException<ED>;
|
||||
tryExecute: (path?: string) => boolean | OakUserException<ED>;
|
||||
getOperations: (
|
||||
path?: string
|
||||
) => { operation: ED[T]['Operation']; entity: T }[] | undefined;
|
||||
|
|
|
|||
Loading…
Reference in New Issue