重构了checkOperation的缓存机制

This commit is contained in:
Xu Chang 2024-09-15 17:58:27 +08:00
parent 16ce411444
commit 6a93675892
26 changed files with 109 additions and 239 deletions

View File

@ -2,12 +2,12 @@ import { ED, OakAbsAttrDef } from '../../types/AbstractComponent';
import { ReactComponentProps } from '../../types/Page';
import { Breakpoint } from 'antd';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
column?: number | Record<Breakpoint, number>;
column?: number | Record<Breakpoint, number> | undefined;
entity: T2;
attributes: OakAbsAttrDef[];
data: Partial<ED2[T2]['Schema']>;
title?: string;
bordered?: boolean;
layout?: 'horizontal' | 'vertical';
data: Partial<ED2[T2]["Schema"]>;
title?: string | undefined;
bordered?: boolean | undefined;
layout?: "horizontal" | "vertical" | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -3,8 +3,8 @@ import { ReactComponentProps } from '../../types/Page';
import { ECode } from '../../types/ErrorPage';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
code: ECode;
title?: string;
desc?: string;
title?: string | undefined;
desc?: string | undefined;
children?: React.ReactNode;
icon?: React.ReactNode;
}>) => React.ReactElement;

View File

@ -10,13 +10,18 @@ declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactCompo
data: RowWithActions<ED2, T2>[];
loading: boolean;
tablePagination?: React.ReactNode | false;
rowSelection?: TableProps<RowWithActions<ED2, T2>>['rowSelection'];
hideHeader?: boolean;
disableSerialNumber?: boolean;
size?: 'large' | 'middle' | 'small';
scroll?: TableProps<RowWithActions<ED2, T2>>['scroll'];
rowSelection?: import("antd/es/table/interface").TableRowSelection<RowWithActions<ED2, T2>> | undefined;
hideHeader?: boolean | undefined;
disableSerialNumber?: boolean | undefined;
size?: "small" | "large" | "middle" | undefined;
scroll?: ({
x?: string | number | true | undefined;
y?: string | number | undefined;
} & {
scrollToFirstRowOnChange?: boolean | undefined;
}) | undefined;
empty?: React.ReactNode;
opWidth?: number;
ellipsis?: boolean;
opWidth?: number | undefined;
ellipsis?: boolean | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,20 +1,21 @@
/// <reference types="react" />
import { ReactComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
style?: React.CSSProperties;
className?: string;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
title?: React.ReactNode;
showBack?: boolean;
onBack?: () => void;
showBack?: boolean | undefined;
onBack?: (() => void) | undefined;
backIcon?: React.ReactNode;
delta?: number;
delta?: number | undefined;
extra?: React.ReactNode;
subTitle?: React.ReactNode;
contentMargin?: boolean;
contentStyle?: React.CSSProperties;
contentClassName?: string;
contentMargin?: boolean | undefined;
contentStyle?: import("react").CSSProperties | undefined;
contentClassName?: string | undefined;
tags?: React.ReactNode;
children?: React.ReactNode;
showHeader?: boolean;
showHeader?: boolean | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,22 +1,23 @@
/// <reference types="react" />
import { ReactComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
style?: React.CSSProperties;
className?: string;
showHeader?: boolean;
showBack?: boolean;
onBack?: () => void;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
showHeader?: boolean | undefined;
showBack?: boolean | undefined;
onBack?: (() => void) | undefined;
backIcon?: React.ReactNode;
delta?: number;
delta?: number | undefined;
title?: React.ReactNode;
subTitle?: React.ReactNode;
tags?: React.ReactNode;
extra?: React.ReactNode;
children?: React.ReactNode;
content: React.ReactNode;
contentStyle?: React.CSSProperties;
contentClassName?: string;
bodyStyle?: React.CSSProperties;
bodyClassName?: string;
contentStyle?: import("react").CSSProperties | undefined;
contentClassName?: string | undefined;
bodyStyle?: import("react").CSSProperties | undefined;
bodyClassName?: string | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -1,12 +1,13 @@
/// <reference types="react" />
import { ReactComponentProps } from '../../types/Page';
import { ED } from '../../types/AbstractComponent';
declare const _default: <ED2 extends ED, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, false, {
entity: T2;
style?: React.CSSProperties;
className?: string;
showQuickJumper?: boolean;
size?: 'default' | 'small';
showSizeChanger?: boolean;
showTotal?: (total: number, range: [number, number]) => React.ReactNode;
style?: import("react").CSSProperties | undefined;
className?: string | undefined;
showQuickJumper?: boolean | undefined;
size?: "small" | "default" | undefined;
showSizeChanger?: boolean | undefined;
showTotal?: ((total: number, range: [number, number]) => React.ReactNode) | undefined;
}>) => React.ReactElement;
export default _default;

View File

@ -4,7 +4,7 @@ declare const _default: <ED2 extends ED, T2 extends keyof ED2, T3 extends string
helps: Record<string, string>;
entity: T2;
attributes: OakAbsAttrUpsertDef<ED2, T2, T3>[];
data: ED2[T2]['Schema'];
data: ED2[T2]["Schema"];
layout: 'horizontal' | 'vertical';
mode: 'default' | 'card';
}>) => React.ReactElement;

View File

@ -137,7 +137,6 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict> extends Featu
value: number;
}[];
};
checkRelation<T extends keyof ED>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>): boolean;
getRelationIdByName(entity: keyof ED, name: string, entityId?: string): Promise<ED["relation"]["Schema"]["id"] | undefined>;
}
export {};

View File

@ -337,19 +337,21 @@ export class Cache extends Feature {
const { action, data, filter } = operation;
let id;
let ts;
const checkTypeString = checkerTypes ? checkerTypes.join('-') : '$$all';
if (filter && !data && typeof filter.id === 'string') {
id = filter.id;
ts = this.cacheStore.getLastUpdateTs();
if (this.entityActionAuthDict[ts]?.[entity]?.[id]?.hasOwnProperty(action)) {
return this.entityActionAuthDict[ts][entity][id][action];
if (this.entityActionAuthDict[ts]?.[entity]?.[id]?.[checkTypeString].hasOwnProperty(action)) {
return this.entityActionAuthDict[ts][entity][id][checkTypeString][action];
}
}
const rollback = this.begin(true);
try {
checkerTypes?.includes('relation') && this.baseRelationAuth.checkRelationSync(entity, operation, this.context);
this.cacheStore.check(entity, operation, this.context, checkerTypes);
rollback && rollback();
if (id && ts) {
set(this.entityActionAuthDict, `${ts}.${entity}.${id}.${action}`, true);
set(this.entityActionAuthDict, `${ts}.${entity}.${id}.${checkTypeString}.${action}`, true);
}
return true;
}
@ -359,7 +361,7 @@ export class Cache extends Feature {
// 有外键缺失,尝试发一下请求
this.fetchRows(err.getRows());
if (id && ts) {
set(this.entityActionAuthDict, `${ts}.${entity}.${id}.${action}`, false);
set(this.entityActionAuthDict, `${ts}.${entity}.${id}.${checkTypeString}.${action}`, false);
}
return false;
}
@ -371,7 +373,7 @@ export class Cache extends Feature {
throw err;
} */
if (id && ts) {
set(this.entityActionAuthDict, `${ts}.${entity}.${id}.${action}`, err);
set(this.entityActionAuthDict, `${ts}.${entity}.${id}.${checkTypeString}.${action}`, err);
}
return err;
}
@ -607,27 +609,6 @@ export class Cache extends Feature {
links,
};
}
checkRelation(entity, operation) {
const rollback = this.begin(true);
try {
this.baseRelationAuth.checkRelationSync(entity, operation, this.context);
rollback && rollback();
}
catch (err) {
rollback && rollback();
if (err instanceof OakRowUnexistedException) {
// 发现缓存中缺失项的话要协助获取
const missedRows = err.getRows();
this.fetchRows(missedRows);
return false;
}
if (!(err instanceof OakUserException)) {
throw err;
}
return false;
}
return true;
}
async getRelationIdByName(entity, name, entityId) {
const filter = {
entity: entity,

View File

@ -94,17 +94,14 @@ export class ContextMenuFactory extends Feature {
if (action instanceof Array) {
for (let i = 0; i < action.length; i++) {
// action有一个满足就行了
const checkResult = this.cache.checkRelation(destEntity, {
const checkResult = this.cache.checkOperation(destEntity, {
action: action[i],
filter,
}) &&
this.cache.checkOperation(destEntity, {
action: action[i],
filter: filter,
}, [
'logical',
'row',
]);
filter: filter,
}, [
'logical',
'row',
'relation'
]);
if (checkResult) {
result = checkResult === true;
break;
@ -112,17 +109,14 @@ export class ContextMenuFactory extends Feature {
}
return result;
}
return (this.cache.checkRelation(destEntity, {
return (this.cache.checkOperation(destEntity, {
action,
filter,
}) &&
this.cache.checkOperation(destEntity, {
action,
filter: filter,
}, [
'logical',
'row',
]));
filter: filter,
}, [
'logical',
'row',
'relation'
]));
});
if (allows.indexOf(true) >= 0) {
return true;

View File

@ -183,18 +183,6 @@ const oakBehavior = Behavior({
return getFreshValue.call(this, path2);
},
checkOperation(entity, { action, data, filter }, checkerTypes) {
if (checkerTypes?.includes('relation')) {
return (this.features.cache.checkRelation(entity, {
action,
data,
filter,
}) &&
this.features.cache.checkOperation(entity, {
action,
data,
filter,
}, checkerTypes));
}
return this.features.cache.checkOperation(entity, {
action,
data,

2
es/page.react.d.ts vendored
View File

@ -75,7 +75,7 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
}[] | undefined): Promise<void>;
isDirty(path?: string | undefined): boolean;
getFreshValue(path?: string | undefined): Partial<import("oak-domain/lib/types").GeneralEntityShape> | Partial<import("oak-domain/lib/types").GeneralEntityShape>[] | undefined;
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean | { [A in ED[T2_2]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[T2_2]["Action"]];
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: CheckerType[] | undefined): boolean | { [A in ED[T2_2]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[T2_2]["Action"]];
tryExecute(path?: string | undefined, action?: string | undefined): boolean | { [A_1 in ED[keyof ED]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[keyof ED]["Action"]];
getOperations<T_6 extends keyof ED>(path?: string | undefined): {
entity: keyof ED;

View File

@ -177,9 +177,6 @@ class OakComponentBase extends React.PureComponent {
return getFreshValue.call(this, path2);
}
checkOperation(entity, operation, checkerTypes) {
if (checkerTypes?.includes('relation')) {
return this.features.cache.checkRelation(entity, operation) && this.features.cache.checkOperation(entity, operation, checkerTypes);
}
return this.features.cache.checkOperation(entity, operation, checkerTypes);
}
tryExecute(path, action) {

2
es/types/Page.d.ts vendored
View File

@ -176,7 +176,7 @@ 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 | OakUserException<ED>;
}, checkerTypes?: CheckerType[]) => boolean | OakUserException<ED>;
tryExecute: (path?: string, action?: ED[T]['Action']) => boolean | OakUserException<ED>;
getOperations: (path?: string) => {
operation: ED[T]['Operation'];

View File

@ -137,7 +137,6 @@ export declare class Cache<ED extends EntityDict & BaseEntityDict> extends Featu
value: number;
}[];
};
checkRelation<T extends keyof ED>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>): boolean;
getRelationIdByName(entity: keyof ED, name: string, entityId?: string): Promise<ED["relation"]["Schema"]["id"] | undefined>;
}
export {};

View File

@ -340,19 +340,21 @@ class Cache extends Feature_1.Feature {
const { action, data, filter } = operation;
let id;
let ts;
const checkTypeString = checkerTypes ? checkerTypes.join('-') : '$$all';
if (filter && !data && typeof filter.id === 'string') {
id = filter.id;
ts = this.cacheStore.getLastUpdateTs();
if (this.entityActionAuthDict[ts]?.[entity]?.[id]?.hasOwnProperty(action)) {
return this.entityActionAuthDict[ts][entity][id][action];
if (this.entityActionAuthDict[ts]?.[entity]?.[id]?.[checkTypeString].hasOwnProperty(action)) {
return this.entityActionAuthDict[ts][entity][id][checkTypeString][action];
}
}
const rollback = this.begin(true);
try {
checkerTypes?.includes('relation') && this.baseRelationAuth.checkRelationSync(entity, operation, this.context);
this.cacheStore.check(entity, operation, this.context, checkerTypes);
rollback && rollback();
if (id && ts) {
(0, lodash_1.set)(this.entityActionAuthDict, `${ts}.${entity}.${id}.${action}`, true);
(0, lodash_1.set)(this.entityActionAuthDict, `${ts}.${entity}.${id}.${checkTypeString}.${action}`, true);
}
return true;
}
@ -362,7 +364,7 @@ class Cache extends Feature_1.Feature {
// 有外键缺失,尝试发一下请求
this.fetchRows(err.getRows());
if (id && ts) {
(0, lodash_1.set)(this.entityActionAuthDict, `${ts}.${entity}.${id}.${action}`, false);
(0, lodash_1.set)(this.entityActionAuthDict, `${ts}.${entity}.${id}.${checkTypeString}.${action}`, false);
}
return false;
}
@ -374,7 +376,7 @@ class Cache extends Feature_1.Feature {
throw err;
} */
if (id && ts) {
(0, lodash_1.set)(this.entityActionAuthDict, `${ts}.${entity}.${id}.${action}`, err);
(0, lodash_1.set)(this.entityActionAuthDict, `${ts}.${entity}.${id}.${checkTypeString}.${action}`, err);
}
return err;
}
@ -610,27 +612,6 @@ class Cache extends Feature_1.Feature {
links,
};
}
checkRelation(entity, operation) {
const rollback = this.begin(true);
try {
this.baseRelationAuth.checkRelationSync(entity, operation, this.context);
rollback && rollback();
}
catch (err) {
rollback && rollback();
if (err instanceof Exception_1.OakRowUnexistedException) {
// 发现缓存中缺失项的话要协助获取
const missedRows = err.getRows();
this.fetchRows(missedRows);
return false;
}
if (!(err instanceof Exception_1.OakUserException)) {
throw err;
}
return false;
}
return true;
}
async getRelationIdByName(entity, name, entityId) {
const filter = {
entity: entity,

View File

@ -97,17 +97,14 @@ class ContextMenuFactory extends Feature_1.Feature {
if (action instanceof Array) {
for (let i = 0; i < action.length; i++) {
// action有一个满足就行了
const checkResult = this.cache.checkRelation(destEntity, {
const checkResult = this.cache.checkOperation(destEntity, {
action: action[i],
filter,
}) &&
this.cache.checkOperation(destEntity, {
action: action[i],
filter: filter,
}, [
'logical',
'row',
]);
filter: filter,
}, [
'logical',
'row',
'relation'
]);
if (checkResult) {
result = checkResult === true;
break;
@ -115,17 +112,14 @@ class ContextMenuFactory extends Feature_1.Feature {
}
return result;
}
return (this.cache.checkRelation(destEntity, {
return (this.cache.checkOperation(destEntity, {
action,
filter,
}) &&
this.cache.checkOperation(destEntity, {
action,
filter: filter,
}, [
'logical',
'row',
]));
filter: filter,
}, [
'logical',
'row',
'relation'
]));
});
if (allows.indexOf(true) >= 0) {
return true;

View File

@ -186,18 +186,6 @@ const oakBehavior = Behavior({
return page_common_1.getFreshValue.call(this, path2);
},
checkOperation(entity, { action, data, filter }, checkerTypes) {
if (checkerTypes?.includes('relation')) {
return (this.features.cache.checkRelation(entity, {
action,
data,
filter,
}) &&
this.features.cache.checkOperation(entity, {
action,
data,
filter,
}, checkerTypes));
}
return this.features.cache.checkOperation(entity, {
action,
data,

2
lib/page.react.d.ts vendored
View File

@ -75,7 +75,7 @@ export declare function createComponent<IsList extends boolean, ED extends Entit
}[] | undefined): Promise<void>;
isDirty(path?: string | undefined): boolean;
getFreshValue(path?: string | undefined): Partial<import("oak-domain/lib/types").GeneralEntityShape> | Partial<import("oak-domain/lib/types").GeneralEntityShape>[] | undefined;
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: (CheckerType | "relation")[] | undefined): boolean | { [A in ED[T2_2]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[T2_2]["Action"]];
checkOperation<T2_2 extends keyof ED>(entity: T2_2, operation: Omit<ED[T2_2]["Operation"], "id">, checkerTypes?: CheckerType[] | undefined): boolean | { [A in ED[T2_2]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[T2_2]["Action"]];
tryExecute(path?: string | undefined, action?: string | undefined): boolean | { [A_1 in ED[keyof ED]["Action"]]: boolean | import("oak-domain/lib/types").OakUserException<ED>; }[ED[keyof ED]["Action"]];
getOperations<T_6 extends keyof ED>(path?: string | undefined): {
entity: keyof ED;

View File

@ -182,9 +182,6 @@ class OakComponentBase extends react_1.default.PureComponent {
return page_common_1.getFreshValue.call(this, path2);
}
checkOperation(entity, operation, checkerTypes) {
if (checkerTypes?.includes('relation')) {
return this.features.cache.checkRelation(entity, operation) && this.features.cache.checkOperation(entity, operation, checkerTypes);
}
return this.features.cache.checkOperation(entity, operation, checkerTypes);
}
tryExecute(path, action) {

2
lib/types/Page.d.ts vendored
View File

@ -176,7 +176,7 @@ 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 | OakUserException<ED>;
}, checkerTypes?: CheckerType[]) => boolean | OakUserException<ED>;
tryExecute: (path?: string, action?: ED[T]['Action']) => boolean | OakUserException<ED>;
getOperations: (path?: string) => {
operation: ED[T]['Operation'];

View File

@ -55,7 +55,9 @@ export class Cache<ED extends EntityDict & BaseEntityDict> extends Feature {
[ts: number]: {
[T in keyof ED]?: {
[I: string]: {
[A in ED[T]['Action']]: boolean | OakUserException<ED>;
[cts: string]: {
[A in ED[T]['Action']]: boolean | OakUserException<ED>;
}
}
};
};
@ -477,20 +479,23 @@ export class Cache<ED extends EntityDict & BaseEntityDict> extends Feature {
const { action, data, filter } = operation;
let id: string | undefined;
let ts: number | undefined;
const checkTypeString = checkerTypes ? checkerTypes.join('-') : '$$all';
if (filter && !data && typeof filter.id === 'string') {
id = filter.id;
ts = this.cacheStore.getLastUpdateTs();
if (this.entityActionAuthDict[ts]?.[entity]?.[id]?.hasOwnProperty(action)) {
return this.entityActionAuthDict[ts]![entity]![id]![action]!;
if (this.entityActionAuthDict[ts]?.[entity]?.[id]?.[checkTypeString].hasOwnProperty(action)) {
return this.entityActionAuthDict[ts]![entity]![id]![checkTypeString]![action]!;
}
}
const rollback = this.begin(true);
try {
checkerTypes?.includes('relation') && this.baseRelationAuth.checkRelationSync(entity, operation as Omit<ED[T]['Operation'], 'id'>, this.context!);
this.cacheStore!.check(entity, operation, this.context!, checkerTypes);
rollback && rollback();
if (id && ts) {
set(this.entityActionAuthDict, `${ts}.${entity as string}.${id}.${action}`, true);
set(this.entityActionAuthDict, `${ts}.${entity as string}.${id}.${checkTypeString}.${action}`, true);
}
return true;
}
@ -500,7 +505,7 @@ export class Cache<ED extends EntityDict & BaseEntityDict> extends Feature {
// 有外键缺失,尝试发一下请求
this.fetchRows(err.getRows());
if (id && ts) {
set(this.entityActionAuthDict, `${ts}.${entity as string}.${id}.${action}`, false);
set(this.entityActionAuthDict, `${ts}.${entity as string}.${id}.${checkTypeString}.${action}`, false);
}
return false;
}
@ -512,7 +517,7 @@ export class Cache<ED extends EntityDict & BaseEntityDict> extends Feature {
throw err;
} */
if (id && ts) {
set(this.entityActionAuthDict, `${ts}.${entity as string}.${id}.${action}`, err);
set(this.entityActionAuthDict, `${ts}.${entity as string}.${id}.${checkTypeString}.${action}`, err);
}
return err as OakUserException<ED>;
}
@ -809,27 +814,6 @@ export class Cache<ED extends EntityDict & BaseEntityDict> extends Feature {
links,
};
}
checkRelation<T extends keyof ED>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>) {
const rollback = this.begin(true);
try {
this.baseRelationAuth.checkRelationSync(entity, operation, this.context!);
rollback && rollback();
}
catch (err) {
rollback && rollback();
if (err instanceof OakRowUnexistedException) {
// 发现缓存中缺失项的话要协助获取
const missedRows = err.getRows();
this.fetchRows(missedRows);
return false;
}
if (!(err instanceof OakUserException)) {
throw err;
}
return false;
}
return true;
}
async getRelationIdByName(entity: keyof ED, name: string, entityId?: string) {
const filter: ED['relation']['Selection']['filter'] = {

View File

@ -140,16 +140,6 @@ export class ContextMenuFactory<
for (let i = 0; i < action.length; i++) {
// action有一个满足就行了
const checkResult =
this.cache.checkRelation(
destEntity,
{
action: action[i],
filter,
} as Omit<
ED[keyof ED]['Operation'],
'id'
>
) &&
this.cache.checkOperation(
destEntity,
{
@ -159,6 +149,7 @@ export class ContextMenuFactory<
[
'logical',
'row',
'relation'
]
);
@ -170,10 +161,6 @@ export class ContextMenuFactory<
return result;
}
return (
this.cache.checkRelation(destEntity, {
action,
filter,
} as Omit<ED[keyof ED]['Operation'], 'id'>) &&
this.cache.checkOperation(
destEntity,
{
@ -183,6 +170,7 @@ export class ContextMenuFactory<
[
'logical',
'row',
'relation'
]
)
);

View File

@ -310,24 +310,6 @@ const oakBehavior = Behavior<
},
checkOperation(entity, { action, data, filter }, checkerTypes) {
if (checkerTypes?.includes('relation')) {
return (
this.features.cache.checkRelation(entity, {
action,
data,
filter,
} as Omit<EDD[keyof EDD]['Operation'], 'id'>) &&
this.features.cache.checkOperation(
entity,
{
action,
data,
filter,
},
checkerTypes as CheckerType[]
)
);
}
return this.features.cache.checkOperation(
entity,
{

View File

@ -349,18 +349,8 @@ abstract class OakComponentBase<
checkOperation<T2 extends keyof ED>(
entity: T2,
operation: Omit<ED[T2]['Operation'], 'id'>,
checkerTypes?: (CheckerType | 'relation')[]
checkerTypes?: CheckerType[]
) {
if (checkerTypes?.includes('relation')) {
return this.features.cache.checkRelation(
entity,
operation
) && this.features.cache.checkOperation(
entity,
operation,
checkerTypes as CheckerType[]
);
}
return this.features.cache.checkOperation(
entity,
operation,

View File

@ -400,7 +400,7 @@ export type OakCommonComponentMethods<
data?: ED[T2]['Operation']['data'],
filter?: ED[T2]['Operation']['filter'],
},
checkerTypes?: (CheckerType | 'relation')[]
checkerTypes?: CheckerType[]
) => boolean | OakUserException<ED>;
tryExecute: (path?: string, action?: ED[T]['Action']) => boolean | OakUserException<ED>;
getOperations: (