实现了auth的大量逻辑

This commit is contained in:
Xu Chang 2023-05-24 14:56:32 +08:00
parent 681e4dcf18
commit a69d11855e
150 changed files with 434 additions and 2538 deletions

View File

@ -1,11 +0,0 @@
{
"component": true,
"usingComponents": {
"l-dialog": "../../miniprogram_npm/lin-ui/dialog/index",
"l-button": "../../miniprogram_npm/lin-ui/button/index",
"l-popup": "../../miniprogram_npm/lin-ui/popup/index",
"oak-icon": "../icon/index",
"popover": "../../miniprogram_npm/popover/popover",
"popover-item": "../../miniprogram_npm/popover/popover-item"
}
}

View File

@ -1,9 +0,0 @@
{
"component": true,
"usingComponents": {
"l-dialog": "../../miniprogram_npm/lin-ui/dialog/index",
"l-button": "../../miniprogram_npm/lin-ui/button/index",
"popover": "../../miniprogram_npm/popover/popover",
"popover-item": "../../miniprogram_npm/popover/popover-item"
}
}

View File

@ -1,17 +0,0 @@
/// <reference types="react" />
import { ButtonProps } from 'antd';
export declare type Item = {
icon?: string | React.ReactNode;
label?: string;
action?: string;
type?: 'a' | 'button';
alerted?: boolean;
alertTitle?: string;
alertContent?: string;
confirmText?: string;
cancelText?: string;
render?: React.ReactNode;
onClick?: (item: Item) => void | Promise<void>;
buttonProps?: Omit<ButtonProps, 'onClick'>;
show?: boolean;
};

View File

@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"oak-icon": "../../icon/index",
"l-dialog": "../../miniprogram_npm/lin-ui/dialog/index"
}
}

View File

@ -1,10 +0,0 @@
{
"component": true,
"usingComponents": {
"l-dialog": "../../miniprogram_npm/lin-ui/dialog/index",
"l-button": "../../miniprogram_npm/lin-ui/button/index",
"l-tag": "../../miniprogram_npm/lin-ui/tag/index",
"popover": "../../miniprogram_npm/popover/popover",
"popover-item": "../../miniprogram_npm/popover/popover-item"
}
}

View File

@ -1,23 +0,0 @@
{
"placeholder": {
"input": "请输入",
"select": "请选择"
},
"attr": {
"id": "编号",
"$$createAt$$": "创建时间",
"$$updateAt$$": "更新时间",
"$$deleteAt$$": "删除时间",
"$$seq$$": "序号",
"$text": "全文检索"
},
"tip": {
"yes": "是",
"no": "否",
"unselected": "未选"
},
"op": {
"$includes": "包含"
}
}

View File

@ -1,14 +0,0 @@
{
"component": true,
"usingComponents": {
"l-button": "../../miniprogram_npm/lin-ui/button/index",
"l-search-bar": "../../miniprogram_npm/lin-ui/search-bar/index",
"l-popup": "../../miniprogram_npm/lin-ui/popup/index",
"l-icon": "../../miniprogram_npm/lin-ui/icon/index",
"l-input": "../../miniprogram_npm/lin-ui/input/index",
"l-checkbox": "../../miniprogram_npm/lin-ui/checkbox/index",
"l-checkbox-group": "../../miniprogram_npm/lin-ui/checkbox-group/index",
"l-calendar": "../../miniprogram_npm/lin-ui/calendar/index",
"l-form-item": "../../miniprogram_npm/lin-ui/form-item/index"
}
}

View File

@ -1,23 +0,0 @@
{
"placeholder": {
"input": "请输入",
"select": "请选择"
},
"attr": {
"id": "编号",
"$$createAt$$": "创建时间",
"$$updateAt$$": "更新时间",
"$$deleteAt$$": "删除时间",
"$$seq$$": "序号",
"$text": "全文检索"
},
"tip": {
"yes": "是",
"no": "否",
"unselected": "未选"
},
"op": {
"$includes": "包含"
}
}

View File

@ -1,9 +0,0 @@
{
"component": true,
"usingComponents": {
"oak-filter": "../filter2/index",
"l-collapse": "../../miniprogram_npm/lin-ui/collapse/index",
"l-button": "../../miniprogram_npm/lin-ui/button/index",
"l-collapse-item": "../../miniprogram_npm/lin-ui/collapse-item/index"
}
}

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,10 +0,0 @@
{
"component": true,
"usingComponents": {
"l-dialog": "../../miniprogram_npm/lin-ui/dialog/index",
"l-button": "../../miniprogram_npm/lin-ui/button/index",
"action-btn": "../actionBtn/index",
"popover": "../../miniprogram_npm/popover/popover",
"popover-item": "../../miniprogram_npm/popover/popover-item"
}
}

View File

@ -1,19 +0,0 @@
{
"component": true,
"usingComponents": {
"l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",
"l-list": "@oak-frontend-base/miniprogram_npm/lin-ui/list/index",
"l-input": "@oak-frontend-base/miniprogram_npm/lin-ui/input/index",
"l-icon": "@oak-frontend-base/miniprogram_npm/lin-ui/icon/index",
"l-textarea": "@oak-frontend-base/miniprogram_npm/lin-ui/textarea/index",
"l-form": "@oak-frontend-base/miniprogram_npm/lin-ui/form/index",
"l-form-item": "@oak-frontend-base/miniprogram_npm/lin-ui/form-item/index",
"l-radio-group": "@oak-frontend-base/miniprogram_npm/lin-ui/radio-group/index",
"l-radio": "@oak-frontend-base/miniprogram_npm/lin-ui/radio/index",
"l-checkbox-group": "@oak-frontend-base/miniprogram_npm/lin-ui/checkbox-group/index",
"l-checkbox": "@oak-frontend-base/miniprogram_npm/lin-ui/checkbox/index",
"l-counter": "@oak-frontend-base/miniprogram_npm/lin-ui/counter/index",
"l-loading": "@oak-frontend-base/miniprogram_npm/lin-ui/loading/index",
"l-notice-bar": "@oak-frontend-base/miniprogram_npm/lin-ui/notice-bar/index"
}
}

View File

@ -26,19 +26,22 @@ exports.default = OakComponent({
filter: function () {
var _a = this.props, entity = _a.entity, actions = _a.actions;
(0, assert_1.default)(entity);
if (!actions || actions.length === 0) {
return {
destEntity: entity,
};
}
else {
return {
destEntity: entity,
deActions: {
$overlaps: actions,
},
};
}
return {
destEntity: entity,
};
/* if (!actions || actions.length === 0) {
return {
destEntity: entity as string,
};
}
else {
return {
destEntity: entity as string,
deActions: {
$overlaps: actions,
},
};
} */
}
}
],
@ -103,6 +106,23 @@ exports.default = OakComponent({
});
}
},
listeners: {
actions: function (prev, next) {
var _this = this;
var actionAuths = this.features.runningTree.getFreshValue(this.state.oakFullpath);
if (actionAuths) {
actionAuths.forEach(function (actionAuth) {
if (actionAuth.$$createAt$$ === 1) {
var id = actionAuth.id, deActions = actionAuth.deActions;
_this.updateItem({
deActions: next.actions,
}, id);
}
});
}
this.reRender();
}
},
methods: {
onChange: function (checked, relationId, path, actionAuth) {
var actions = this.props.actions;

View File

@ -1,6 +0,0 @@
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "directActionAuth", true, {
entity: string | number;
actions: string[];
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,81 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var assert_1 = tslib_1.__importDefault(require("assert"));
var lodash_1 = require("oak-domain/lib/utils/lodash");
exports.default = OakComponent({
entity: 'directActionAuth',
isList: true,
projection: {
id: 1,
deActions: 1,
path: 1,
destEntity: 1,
sourceEntity: 1,
},
properties: {
entity: '',
actions: [],
},
filters: [
{
filter: function () {
var _a = this.props, entity = _a.entity, actions = _a.actions;
if (!actions || actions.length === 0) {
return {
destEntity: entity,
};
}
return {
destEntity: entity,
deActions: {
$overlaps: actions,
},
};
}
}
],
formData: function (_a) {
var data = _a.data;
var entity = this.props.entity;
var paths = this.features.relationAuth.getCascadeActionAuths(entity, false);
return {
paths: paths,
directActionAuths: data,
};
},
methods: {
onChange: function (checked, path, directActionAuth) {
var actions = this.props.actions;
(0, assert_1.default)(actions.length > 0);
if (checked) {
if (directActionAuth) {
var deActions = directActionAuth.deActions;
var deActions2 = (0, lodash_1.union)(deActions, actions);
this.updateItem({
deActions: deActions2,
}, directActionAuth.id);
}
else {
this.addItem({
destEntity: path[0],
sourceEntity: path[2],
path: path[1],
deActions: actions,
});
}
}
else {
(0, assert_1.default)(directActionAuth);
var deActions_1 = directActionAuth.deActions;
actions === null || actions === void 0 ? void 0 : actions.forEach(function (action) { return (0, lodash_1.pull)(deActions_1, action); });
this.updateItem({
deActions: deActions_1,
}, directActionAuth.id);
}
},
confirm: function () {
this.execute();
},
}
});

View File

@ -1,14 +0,0 @@
/// <reference types="react" />
import { WebComponentProps } from '../../../types/Page';
import { AuthCascadePath, EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
declare type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, 'directActionAuth', true, {
paths: AuthCascadePath<ED>[];
directActionAuths?: ED['directActionAuth']['OpSchema'][];
actions: string[];
}, {
onChange: (checked: boolean, path: AuthCascadePath<ED>, directActionAuth?: ED['directActionAuth']['OpSchema']) => void;
confirm: () => void;
}>): JSX.Element;
export {};

View File

@ -1,65 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var lodash_1 = require("oak-domain/lib/utils/lodash");
function render(props) {
var _a = props.data, paths = _a.paths, directActionAuths = _a.directActionAuths, actions = _a.actions, oakDirty = _a.oakDirty;
var _b = props.methods, onChange = _b.onChange, confirm = _b.confirm, t = _b.t, clean = _b.clean;
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { columns: [
{
key: '2',
title: t('directActionAuth:attr.sourceEntity'),
width: 100,
render: function (value, record) {
return record[2];
},
},
{
key: '1',
title: t('directActionAuth:attr.path'),
width: 200,
render: function (value, record) {
return record[1];
},
},
{
fixed: 'right',
title: t('authority'),
key: 'operation',
width: 300,
render: function (value, record) {
var e_1, _a;
var checked = false, indeterminate = false;
if (directActionAuths && actions.length > 0) {
try {
for (var directActionAuths_1 = tslib_1.__values(directActionAuths), directActionAuths_1_1 = directActionAuths_1.next(); !directActionAuths_1_1.done; directActionAuths_1_1 = directActionAuths_1.next()) {
var daa = directActionAuths_1_1.value;
if (!daa.$$deleteAt$$ && daa.path === record[1]) {
var deActions = daa.deActions;
checked = (0, lodash_1.difference)(actions, deActions).length === 0;
indeterminate = !checked && (0, lodash_1.intersection)(actions, deActions).length > 0;
break;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (directActionAuths_1_1 && !directActionAuths_1_1.done && (_a = directActionAuths_1.return)) _a.call(directActionAuths_1);
}
finally { if (e_1) throw e_1.error; }
}
}
return ((0, jsx_runtime_1.jsx)(antd_1.Checkbox, tslib_1.__assign({ disabled: actions.length === 0, checked: checked, indeterminate: indeterminate, onChange: function (_a) {
var target = _a.target;
var checked = target.checked;
var daa = directActionAuths === null || directActionAuths === void 0 ? void 0 : directActionAuths.find(function (daa) { return daa.path === record[1]; });
onChange(checked, record, daa);
} }, { children: t('allowed') })));
}
}
], dataSource: paths, pagination: false }), (0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ justify: "end", style: { marginTop: 20, padding: 5 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ style: { marginRight: 10 }, type: 'primary', disabled: !oakDirty, onClick: function () { return confirm(); } }, { children: t("confirm") })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ disabled: !oakDirty, onClick: function () { return clean(); } }, { children: t("reset") }))] }))] }));
}
exports.default = render;

View File

@ -1,6 +0,0 @@
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "directRelationAuth", true, {
entity: string | number;
relationIds: string[];
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,89 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
// attention! 这个组件没有测试过因为jichuang项目没有存在directRelationAuth的entity. by Xc 2023.05.06
var assert_1 = tslib_1.__importDefault(require("assert"));
var lodash_1 = require("oak-domain/lib/utils/lodash");
exports.default = OakComponent({
entity: 'directRelationAuth',
isList: true,
projection: {
id: 1,
path: 1,
destRelationId: 1,
},
properties: {
entity: '',
relationIds: [],
},
filters: [
{
filter: function () {
var _a = this.props, entity = _a.entity, relationIds = _a.relationIds;
if (relationIds && relationIds.length > 0) {
return {
destRelationId: {
$in: relationIds,
},
};
}
else {
return {
destRelation: {
entity: entity,
entityId: {
$exists: false,
},
},
};
}
},
}
],
formData: function (_a) {
var data = _a.data;
var entity = this.props.entity;
var auths = this.features.relationAuth.getCascadeRelationAuths(entity, false);
return {
auths: auths,
directRelationAuths: data,
};
},
methods: {
onChange: function (checked, path, directRelationAuths) {
var _this = this;
var relationIds = this.props.relationIds;
(0, assert_1.default)(relationIds);
if (checked) {
if (directRelationAuths) {
var includedRelationIds_1 = [];
directRelationAuths.forEach(function (dra) {
if (dra.$$deleteAt$$) {
_this.recoverItem(dra.id);
}
includedRelationIds_1.push(dra.destRelationId);
});
var restRelationIds = (0, lodash_1.difference)(relationIds, includedRelationIds_1);
restRelationIds.forEach(function (relationId) { return _this.addItem({
path: path[1],
destRelationId: relationId,
}); });
}
else {
relationIds.forEach(function (relationId) { return _this.addItem({
path: path[1],
destRelationId: relationId,
}); });
;
}
}
else {
(0, assert_1.default)(directRelationAuths && directRelationAuths.length > 0);
directRelationAuths.forEach(function (dra) { return _this.removeItem(dra.id); });
}
},
confirm: function () {
this.execute();
},
}
});

View File

@ -1,14 +0,0 @@
/// <reference types="react" />
import { WebComponentProps } from '../../../types/Page';
import { AuthCascadePath, EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
declare type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, 'directRelationAuth', true, {
paths: AuthCascadePath<ED>[];
directRelationAuths?: ED['directRelationAuth']['OpSchema'][];
relationIds: string[];
}, {
onChange: (checked: boolean, path: AuthCascadePath<ED>, directRelationAuths?: ED['directRelationAuth']['OpSchema'][]) => void;
confirm: () => void;
}>): JSX.Element;
export {};

View File

@ -1,66 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var lodash_1 = require("oak-domain/lib/utils/lodash");
function render(props) {
var _a = props.data, paths = _a.paths, directRelationAuths = _a.directRelationAuths, relationIds = _a.relationIds, oakDirty = _a.oakDirty;
var _b = props.methods, onChange = _b.onChange, confirm = _b.confirm, t = _b.t, clean = _b.clean;
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { columns: [
{
key: '2',
title: t('directActionAuth:attr.sourceEntity'),
width: 100,
render: function (value, record) {
return record[2];
},
},
{
key: '1',
title: t('directActionAuth:attr.path'),
width: 200,
render: function (value, record) {
return record[1];
},
},
{
fixed: 'right',
title: t('authority'),
key: 'operation',
width: 300,
render: function (value, record) {
var e_1, _a;
var disabled = relationIds.length === 0;
var checked = false, indeterminate = false;
if (!disabled && directRelationAuths) {
var includedRelationIds = [];
try {
for (var directRelationAuths_1 = tslib_1.__values(directRelationAuths), directRelationAuths_1_1 = directRelationAuths_1.next(); !directRelationAuths_1_1.done; directRelationAuths_1_1 = directRelationAuths_1.next()) {
var dra = directRelationAuths_1_1.value;
if (!dra.$$deleteAt$$ && dra.path === record[1]) {
includedRelationIds.push(dra.destRelationId);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (directRelationAuths_1_1 && !directRelationAuths_1_1.done && (_a = directRelationAuths_1.return)) _a.call(directRelationAuths_1);
}
finally { if (e_1) throw e_1.error; }
}
checked = (0, lodash_1.difference)(relationIds, includedRelationIds).length === 0;
indeterminate = !checked && (0, lodash_1.intersection)(relationIds, includedRelationIds).length > 0;
}
return ((0, jsx_runtime_1.jsx)(antd_1.Checkbox, tslib_1.__assign({ disabled: disabled, checked: checked, indeterminate: indeterminate, onChange: function (_a) {
var target = _a.target;
var checked = target.checked;
var dras = directRelationAuths === null || directRelationAuths === void 0 ? void 0 : directRelationAuths.filter(function (daa) { return daa.path === record[1]; });
onChange(checked, record, dras);
} }, { children: t('allowed') })));
}
}
], dataSource: paths, pagination: false }), (0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ justify: "end", style: { marginTop: 20, padding: 5 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ style: { marginRight: 10 }, type: 'primary', disabled: !oakDirty, onClick: function () { return confirm(); } }, { children: t("confirm") })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ disabled: !oakDirty, onClick: function () { return clean(); } }, { children: t("reset") }))] }))] }));
}
exports.default = render;

View File

@ -34,6 +34,8 @@ exports.default = OakComponent({
return {
relations: relations,
actions: actions,
daas: daas,
dras: dras,
hasDirectActionAuth: daas.length > 0,
hasDirectRelationAuth: dras.length > 0,
deduceRelationAttr: deduceRelationAttr,

View File

@ -1,11 +1,13 @@
/// <reference types="react" />
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { AuthCascadePath, EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { WebComponentProps } from '../../../types/Page';
declare type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, keyof ED, false, {
entity: keyof ED;
actions: string[];
daas: AuthCascadePath<ED>[];
dras: AuthCascadePath<ED>[];
checkedActions: string[];
relations: ED['relation']['OpSchema'][];
relationIds: string[];

View File

@ -6,15 +6,12 @@ var antd_1 = require("antd");
var antd_2 = require("antd");
var Title = antd_2.Typography.Title, Text = antd_2.Typography.Text;
var actionAuth_1 = tslib_1.__importDefault(require("../actionAuth"));
var directActionAuth_1 = tslib_1.__importDefault(require("../directActionAuth"));
var freeActionAuth_1 = tslib_1.__importDefault(require("../freeActionAuth"));
var relationAuth_1 = tslib_1.__importDefault(require("../relationAuth"));
var directRelationAuth_1 = tslib_1.__importDefault(require("../directRelationAuth"));
var react_1 = require("react");
function render(props) {
var _a = props.data, oakFullpath = _a.oakFullpath, entity = _a.entity, actions = _a.actions, checkedActions = _a.checkedActions, hasDirectActionAuth = _a.hasDirectActionAuth, hasDirectRelationAuth = _a.hasDirectRelationAuth, relationIds = _a.relationIds, relations = _a.relations, deduceRelationAttr = _a.deduceRelationAttr;
var _a = props.data, oakFullpath = _a.oakFullpath, entity = _a.entity, actions = _a.actions, checkedActions = _a.checkedActions, hasDirectActionAuth = _a.hasDirectActionAuth, hasDirectRelationAuth = _a.hasDirectRelationAuth, dras = _a.dras, daas = _a.daas, relationIds = _a.relationIds, relations = _a.relations, deduceRelationAttr = _a.deduceRelationAttr;
var _b = props.methods, onActionsSelected = _b.onActionsSelected, onRelationsSelected = _b.onRelationsSelected, t = _b.t;
var _c = tslib_1.__read((0, react_1.useState)('freeActionAuth'), 2), tab = _c[0], setTab = _c[1];
var _c = tslib_1.__read((0, react_1.useState)('actionAuth'), 2), tab = _c[0], setTab = _c[1];
var items = deduceRelationAttr ? [
{
label: 'deduceRelation',
@ -29,11 +26,6 @@ function render(props) {
} }, { children: ["\u5BF9\u8C61\u7684actionAuth\u5DF2\u88ABdeduce\u5230[", (0, jsx_runtime_1.jsx)("b", { children: deduceRelationAttr }), "]\u5C5E\u6027\u4E0A"] })))
},
] : [
{
label: 'freeActionAuth',
key: 'freeActionAuth',
children: ((0, jsx_runtime_1.jsx)(freeActionAuth_1.default, { entity: entity, oakPath: oakFullpath && "".concat(oakFullpath, ".freeActionAuths") }))
},
{
label: 'actionAuth',
key: 'actionAuth',
@ -44,7 +36,24 @@ function render(props) {
items.push({
label: 'directActionAuth',
key: 'directActionAuth',
children: ((0, jsx_runtime_1.jsx)(directActionAuth_1.default, { entity: entity, oakPath: oakFullpath && "".concat(oakFullpath, ".directActionAuths"), actions: checkedActions }))
children: ((0, jsx_runtime_1.jsx)(antd_1.Table, { columns: [
{
key: '2',
title: t('sourceEntity'),
width: 100,
render: function (value, record) {
return record[2];
},
},
{
key: '1',
title: t('path'),
width: 200,
render: function (value, record) {
return record[1];
},
},
], dataSource: daas, pagination: false }))
});
}
if ((relations === null || relations === void 0 ? void 0 : relations.length) > 0) {
@ -58,11 +67,34 @@ function render(props) {
items.push({
label: 'directRelationAuth',
key: 'directRelationAuth',
children: ((0, jsx_runtime_1.jsx)(directRelationAuth_1.default, { entity: entity, oakPath: oakFullpath && "".concat(oakFullpath, ".directRelationAuths"), relationIds: relationIds }))
children: ((0, jsx_runtime_1.jsx)(antd_1.Table, { columns: [
{
key: '2',
title: t('sourceEntity'),
width: 100,
render: function (value, record) {
return record[2];
},
},
{
key: '1',
title: t('path'),
width: 200,
render: function (value, record) {
return record[1];
},
},
], dataSource: daas, pagination: false }))
});
}
var ActionSelector = actions && ((0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ style: { width: '100%' }, justify: "center", align: "middle" }, { children: [(0, jsx_runtime_1.jsxs)(Text, tslib_1.__assign({ strong: true }, { children: [t('action'), ":"] })), (0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ style: { flex: 1, marginLeft: 10 }, justify: "start", align: "middle", wrap: true }, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox.Group, { options: actions, value: checkedActions, onChange: function (value) { return onActionsSelected(value); } }) }))] })));
var RelationSelector = relations && ((0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ style: { width: '100%' }, justify: "center", align: "middle" }, { children: [(0, jsx_runtime_1.jsxs)(Text, tslib_1.__assign({ strong: true }, { children: [t('relation'), ":"] })), (0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ style: { flex: 1, marginLeft: 10 }, justify: "start", align: "middle", wrap: true }, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox.Group, { options: relations.map(function (ele) { return ({ label: ele.name, value: ele.id }); }), value: relationIds, onChange: function (value) { return onRelationsSelected(value); } }) }))] })));
var ActionSelector = actions && ((0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ style: { width: '100%' }, justify: "center", align: "middle" }, { children: [(0, jsx_runtime_1.jsxs)(Text, tslib_1.__assign({ strong: true }, { children: [t('action'), ":"] })), (0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ style: { flex: 1, marginLeft: 10 }, justify: "start", align: "middle", wrap: true }, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox.Group, { options: actions, value: checkedActions, onChange: function (value) { return onActionsSelected(value); }, style: {
display: 'flex',
flexWrap: 'wrap',
} }) }))] })));
var RelationSelector = relations && ((0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ style: { width: '100%' }, justify: "center", align: "middle" }, { children: [(0, jsx_runtime_1.jsxs)(Text, tslib_1.__assign({ strong: true }, { children: [t('relation'), ":"] })), (0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ style: { flex: 1, marginLeft: 10 }, justify: "start", align: "middle", wrap: true }, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox.Group, { options: relations.map(function (ele) { return ({ label: ele.name, value: ele.id }); }), value: relationIds, onChange: function (value) { return onRelationsSelected(value); }, style: {
display: 'flex',
flexWrap: 'wrap',
} }) }))] })));
var showActionSelector = ['actionAuth', 'directActionAuth'].includes(tab);
var showRelationSelector = ['relationAuth', 'directRelationAuth'].includes(tab);
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ justify: "center", style: { margin: 20, padding: 10, minHeight: 100 }, align: "middle" }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 8 }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ style: { width: '100%' }, justify: "center", align: "middle" }, { children: [(0, jsx_runtime_1.jsxs)(Text, tslib_1.__assign({ strong: true }, { children: [t('actionAuth:attr.destEntity'), ":"] })), (0, jsx_runtime_1.jsx)(Text, tslib_1.__assign({ code: true, style: { marginLeft: 10 } }, { children: entity }))] })) })), (0, jsx_runtime_1.jsx)(antd_1.Col, tslib_1.__assign({ span: 12 }, { children: showActionSelector ? ActionSelector : (showRelationSelector && RelationSelector) }))] })), (0, jsx_runtime_1.jsx)(antd_1.Tabs, { defaultActiveKey: "1", type: "card", size: "large", items: items, onChange: function (key) { return setTab(key); } })] }));

View File

@ -1,5 +0,0 @@
/// <reference types="react" />
declare const _default: (props: import("../../..").ReactComponentProps<import("oak-domain/lib/types").EntityDict & import("oak-domain/lib/base-app-domain").EntityDict, "freeActionAuth", true, {
entity: string | number;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -1,66 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var assert_1 = tslib_1.__importDefault(require("assert"));
var lodash_1 = require("oak-domain/lib/utils/lodash");
exports.default = OakComponent({
entity: 'freeActionAuth',
isList: true,
projection: {
id: 1,
deActions: 1,
destEntity: 1,
},
properties: {
entity: '',
},
filters: [
{
filter: function () {
var entity = this.props.entity;
return {
destEntity: entity,
};
}
}
],
formData: function (_a) {
var data = _a.data;
var entity = this.props.entity;
var actions = this.features.relationAuth.getActions(entity);
return {
actions: actions,
freeActionAuths: data,
};
},
methods: {
onChange: function (checked, action, freeActionAuth) {
if (checked) {
if (freeActionAuth) {
var deActions = freeActionAuth.deActions;
deActions.push(action);
this.updateItem({
deActions: deActions,
}, freeActionAuth.id);
}
else {
this.addItem({
destEntity: this.props.entity,
deActions: [action],
});
}
}
else {
(0, assert_1.default)(freeActionAuth);
var deActions = freeActionAuth.deActions;
(0, lodash_1.pull)(deActions, action);
this.updateItem({
deActions: deActions,
}, freeActionAuth.id);
}
},
confirm: function () {
this.execute();
},
}
});

View File

@ -1,14 +0,0 @@
/// <reference types="react" />
import { WebComponentProps } from '../../../types/Page';
import { EntityDict } from 'oak-domain/lib/types/Entity';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
declare type ED = EntityDict & BaseEntityDict;
export default function render(props: WebComponentProps<ED, 'freeActionAuth', true, {
entity: keyof ED;
actions: string[];
freeActionAuths?: ED['freeActionAuth']['OpSchema'][];
}, {
onChange: (checked: boolean, action: string, freeActionAuth?: ED['freeActionAuth']['OpSchema']) => void;
confirm: () => void;
}>): JSX.Element;
export {};

View File

@ -1,19 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
function render(props) {
var _a = props.data, entity = _a.entity, freeActionAuths = _a.freeActionAuths, actions = _a.actions, oakDirty = _a.oakDirty;
var _b = props.methods, onChange = _b.onChange, confirm = _b.confirm, t = _b.t, clean = _b.clean;
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ wrap: true, justify: "start", style: { paddingLeft: 40 } }, { children: actions === null || actions === void 0 ? void 0 : actions.map(function (action) {
var checked = !!(freeActionAuths === null || freeActionAuths === void 0 ? void 0 : freeActionAuths.find(function (ele) { return ele.deActions.includes(action) && !ele.$$deleteAt$$; }));
return ((0, jsx_runtime_1.jsx)(antd_1.Row, tslib_1.__assign({ style: { padding: 10 } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Checkbox, tslib_1.__assign({ checked: checked, onChange: function (_a) {
var target = _a.target;
var checked = target.checked;
var freeActionAuth = freeActionAuths === null || freeActionAuths === void 0 ? void 0 : freeActionAuths.find(function (ele) { return ele.deActions.includes(action); });
onChange(checked, action, freeActionAuth);
} }, { children: action })) })));
}) })), (0, jsx_runtime_1.jsxs)(antd_1.Row, tslib_1.__assign({ justify: "end", style: { marginTop: 20, padding: 5 } }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ style: { marginRight: 10 }, type: 'primary', disabled: !oakDirty, onClick: function () { return confirm(); } }, { children: t("confirm") })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ disabled: !oakDirty, onClick: function () { return clean(); } }, { children: t("reset") }))] }))] }));
}
exports.default = render;

View File

@ -20,7 +20,16 @@ exports.default = OakComponent({
{
filter: function () {
var _a = this.props, entity = _a.entity, relationIds = _a.relationIds;
if (relationIds && relationIds.length > 0) {
// 这里不能用relationIds过滤否则没法处理relationId的反选
return {
destRelation: {
entity: entity,
entityId: {
$exists: false,
},
},
};
/* if (relationIds && relationIds.length > 0) {
return {
destRelationId: {
$in: relationIds,
@ -30,13 +39,13 @@ exports.default = OakComponent({
else {
return {
destRelation: {
entity: entity,
entity: entity as string,
entityId: {
$exists: false,
},
},
};
}
} */
},
}
],
@ -46,7 +55,7 @@ exports.default = OakComponent({
},
formData: function (_a) {
var data = _a.data;
var entity = this.props.entity;
var _b = this.props, entity = _b.entity, relationIds = _b.relationIds;
var auths = this.features.relationAuth.getCascadeRelationAuths(entity, true);
var sourceEntities = auths.map(function (ele) { return ele[2]; });
var sourceRelations = this.features.cache.get('relation', {
@ -72,6 +81,22 @@ exports.default = OakComponent({
sourceRelations: sourceRelations,
};
},
listeners: {
relationIds: function (prev, next) {
var _this = this;
var relationAuths = this.features.runningTree.getFreshValue(this.state.oakFullpath);
if (relationAuths) {
var relationIds_1 = next.relationIds;
relationAuths.forEach(function (relationAuth) {
if (relationAuth.$$createAt$$ === 1 && !relationIds_1.includes(relationAuth.destRelationId)) {
var id = relationAuth.id;
_this.removeItem(id);
}
});
}
this.reRender();
},
},
lifetimes: {
ready: function () {
var entity = this.props.entity;

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-search-bar": "../../miniprogram_npm/lin-ui/search-bar/index"
}
}

View File

@ -1,58 +0,0 @@
.container {
padding: 20rpx;
display: flex;
flex: 1;
align-items: center;
}
.btn {
display: flex;
flex: 1;
justify-content: center;
align-items: center;
padding: 4px 15px;
}
.btn-icon {
display: flex;
justify-content: center;
align-items: center;
padding: 4px 15px;
}
.btn-text {
font-size: 28rpx;
color: var(--oak-color-primary);
}
.divider {
width: 2rpx;
height: 20rpx;
background-color: #e0e0e0;
}
.draw-container {
border-radius: 20rpx;
width: 500rpx;
background-color: #fff;
.title-view {
width: 100%;
height: 80rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
border-bottom: 1px solid rgba(200, 200, 200, 0.2);
}
.border {
border-bottom: 1px solid rgba(200, 200, 200, 0.2);
}
.draw-content {
max-height: 480rpx;
overflow-y: scroll;
}
.draw-cell {
color: var(--oak-color-primary);
width: 100%;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
}
}

View File

@ -1,12 +0,0 @@
.container {
display: flex;
flex: 1;
align-items: center;
}
.btn {
display: flex;
flex: 1;
justify-content: center;
align-items: center;
padding: 4px 15px;
}

View File

@ -1,14 +0,0 @@
.panelContainer {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 10px 5px;
}
.more {
white-space: nowrap;
font-size: 14px;
color: #000;
padding: 5px;
}

View File

@ -1,17 +0,0 @@
{
"component": true,
"usingComponents": {
"l-button": "@oak-frontend-base/miniprogram_npm/lin-ui/button/index",
"l-list": "@oak-frontend-base/miniprogram_npm/lin-ui/list/index",
"l-input": "@oak-frontend-base/miniprogram_npm/lin-ui/input/index",
"l-icon": "@oak-frontend-base/miniprogram_npm/lin-ui/icon/index",
"l-textarea": "@oak-frontend-base/miniprogram_npm/lin-ui/textarea/index",
"l-form": "@oak-frontend-base/miniprogram_npm/lin-ui/form/index",
"l-form-item": "@oak-frontend-base/miniprogram_npm/lin-ui/form-item/index",
"l-radio-group": "@oak-frontend-base/miniprogram_npm/lin-ui/radio-group/index",
"l-radio": "@oak-frontend-base/miniprogram_npm/lin-ui/radio/index",
"l-counter": "@oak-frontend-base/miniprogram_npm/lin-ui/counter/index",
"l-notice-bar": "@oak-frontend-base/miniprogram_npm/lin-ui/notice-bar/index",
"refAttr": "../refAttr/index"
}
}

View File

@ -1,5 +0,0 @@
{
"moneySymbol": "¥",
"chooseDate": "选择日期",
"chooseDatetime": "选择时间"
}

View File

@ -12,11 +12,7 @@ interface DebugStoreSelectOption extends TreeStoreSelectOption {
export declare class DebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> extends TreeStore<ED> implements AsyncRowStore<ED, Cxt> {
private executor;
private relationAuth;
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>, actionCascadeGraph: AuthCascadePath<ED>[], relationCascadeGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>);
/**
* relationAuth中需要缓存一些维表的数据
*/
private initRelationAuthTriggers;
constructor(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>, actionCascadeGraph: AuthCascadePath<ED>[], relationCascadeGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities: (keyof ED)[]);
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]["Aggregation"], context: Cxt, option: OP): Promise<AggregationResult<ED[T]["Schema"]>>;
begin(option?: TxnOption): Promise<string>;
commit(txnId: string): Promise<void>;

View File

@ -10,64 +10,12 @@ var RelationAuth_1 = require("oak-domain/lib/store/RelationAuth");
;
var DebugStore = /** @class */ (function (_super) {
tslib_1.__extends(DebugStore, _super);
function DebugStore(storageSchema, contextBuilder, actionCascadeGraph, relationCascadeGraph, authDeduceRelationMap) {
function DebugStore(storageSchema, contextBuilder, actionCascadeGraph, relationCascadeGraph, authDeduceRelationMap, selectFreeEntities) {
var _this = _super.call(this, storageSchema) || this;
_this.executor = new TriggerExecutor_1.TriggerExecutor(function (cxtString) { return contextBuilder(cxtString)(_this); });
_this.relationAuth = new RelationAuth_1.RelationAuth(storageSchema, actionCascadeGraph, relationCascadeGraph, authDeduceRelationMap);
_this.initRelationAuthTriggers(contextBuilder);
_this.relationAuth = new RelationAuth_1.RelationAuth(storageSchema, actionCascadeGraph, relationCascadeGraph, authDeduceRelationMap, selectFreeEntities);
return _this;
}
/**
* relationAuth中需要缓存一些维表的数据
*/
DebugStore.prototype.initRelationAuthTriggers = function (contextBuilder) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var context, directActionAuths, freeActionAuths, triggers;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, contextBuilder()(this)];
case 1:
context = _a.sent();
return [4 /*yield*/, context.begin()];
case 2:
_a.sent();
return [4 /*yield*/, this.select('directActionAuth', {
data: {
id: 1,
sourceEntity: 1,
path: 1,
deActions: 1,
destEntity: 1,
},
}, context, {
dontCollect: true,
})];
case 3:
directActionAuths = _a.sent();
this.relationAuth.setDirectionActionAuths(directActionAuths);
return [4 /*yield*/, this.select('freeActionAuth', {
data: {
id: 1,
deActions: 1,
destEntity: 1,
},
}, context, {
dontCollect: true,
})];
case 4:
freeActionAuths = _a.sent();
this.relationAuth.setFreeActionAuths(freeActionAuths);
return [4 /*yield*/, context.commit()];
case 5:
_a.sent();
triggers = this.relationAuth.getAuthDataTriggers();
triggers.forEach(function (trigger) { return _this.registerTrigger(trigger); });
return [2 /*return*/];
}
});
});
};
DebugStore.prototype.aggregate = function (entity, aggregation, context, option) {
return this.aggregateAsync(entity, aggregation, context, option);
};
@ -91,18 +39,15 @@ var DebugStore = /** @class */ (function (_super) {
case 1:
_a.sent();
_a.label = 2;
case 2: return [4 /*yield*/, this.relationAuth.checkRelationAsync(entity, operation, context)];
case 2: return [4 /*yield*/, _super.prototype.cascadeUpdateAsync.call(this, entity, operation, context, option)];
case 3:
_a.sent();
return [4 /*yield*/, _super.prototype.cascadeUpdateAsync.call(this, entity, operation, context, option)];
case 4:
result = _a.sent();
if (!!option.blockTrigger) return [3 /*break*/, 6];
if (!!option.blockTrigger) return [3 /*break*/, 5];
return [4 /*yield*/, this.executor.postOperation(entity, operation, context, option)];
case 5:
case 4:
_a.sent();
_a.label = 6;
case 6: return [2 /*return*/, result];
_a.label = 5;
case 5: return [2 /*return*/, result];
}
});
});
@ -110,8 +55,14 @@ var DebugStore = /** @class */ (function (_super) {
DebugStore.prototype.operate = function (entity, operation, context, option) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
(0, assert_1.default)(context.getCurrentTxnId());
return [2 /*return*/, _super.prototype.operateAsync.call(this, entity, operation, context, option)];
switch (_a.label) {
case 0:
(0, assert_1.default)(context.getCurrentTxnId());
return [4 /*yield*/, this.relationAuth.checkRelationAsync(entity, operation, context)];
case 1:
_a.sent();
return [2 /*return*/, _super.prototype.operateAsync.call(this, entity, operation, context, option)];
}
});
});
};
@ -130,18 +81,21 @@ var DebugStore = /** @class */ (function (_super) {
case 1:
_a.sent();
_a.label = 2;
case 2: return [4 /*yield*/, this.relationAuth.checkRelationAsync(entity, selection, context)];
case 2:
if (!!option.dontCollect) return [3 /*break*/, 4];
return [4 /*yield*/, this.relationAuth.checkRelationAsync(entity, selection, context)];
case 3:
_a.sent();
return [4 /*yield*/, _super.prototype.selectAsync.call(this, entity, selection, context, option)];
case 4:
result = _a.sent();
if (!!option.blockTrigger) return [3 /*break*/, 6];
return [4 /*yield*/, this.executor.postOperation(entity, selection, context, option, result)];
_a.label = 4;
case 4: return [4 /*yield*/, _super.prototype.selectAsync.call(this, entity, selection, context, option)];
case 5:
result = _a.sent();
if (!!option.blockTrigger) return [3 /*break*/, 7];
return [4 /*yield*/, this.executor.postOperation(entity, selection, context, option, result)];
case 6:
_a.sent();
_a.label = 6;
case 6: return [2 /*return*/, result];
_a.label = 7;
case 7: return [2 /*return*/, result];
}
});
});

View File

@ -5,4 +5,4 @@ import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
export declare function clearMaterializedData(): void;
export declare function createDebugStore<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(storageSchema: StorageSchema<ED>, contextBuilder: (cxtString?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>, triggers: Array<Trigger<ED, keyof ED, Cxt>>, checkers: Array<Checker<ED, keyof ED, Cxt>>, watchers: Array<Watcher<ED, keyof ED, Cxt>>, timers: Array<Timer<ED, Cxt>>, startRoutines: Array<Routine<ED, Cxt>>, initialData: {
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
}, actionDict: ActionDictOfEntityDict<ED>, actionCascadePathGraph: AuthCascadePath<ED>[], relationCascadePathGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>): DebugStore<ED, Cxt>;
}, actionDict: ActionDictOfEntityDict<ED>, actionCascadePathGraph: AuthCascadePath<ED>[], relationCascadePathGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities: (keyof ED)[]): DebugStore<ED, Cxt>;

View File

@ -382,8 +382,8 @@ function doRoutines(store, contextBuilder, routines) {
});
});
}
function createDebugStore(storageSchema, contextBuilder, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap) {
var store = new DebugStore_1.DebugStore(storageSchema, contextBuilder, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap);
function createDebugStore(storageSchema, contextBuilder, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities) {
var store = new DebugStore_1.DebugStore(storageSchema, contextBuilder, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities);
triggers.forEach(function (ele) { return store.registerTrigger(ele); });
checkers.forEach(function (ele) { return store.registerChecker(ele); });
(0, assert_1.assert)(actionDict);

View File

@ -19,7 +19,7 @@ import { Style } from './style';
import { Geo } from './geo';
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>>(aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, storageSchema: StorageSchema<ED>, contextBuilder: () => FrontCxt, store: CacheStore<ED, FrontCxt>, actionCascadePathGraph: AuthCascadePath<ED>[], relationCascadePathGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>, colorDict: ColorDict<ED>): BasicFeatures<ED, Cxt, FrontCxt, AD>;
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>>(aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, storageSchema: StorageSchema<ED>, contextBuilder: () => FrontCxt, store: CacheStore<ED, FrontCxt>, actionCascadePathGraph: AuthCascadePath<ED>[], relationCascadePathGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities: (keyof ED)[], colorDict: ColorDict<ED>): BasicFeatures<ED, Cxt, FrontCxt, AD>;
export declare type BasicFeatures<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>> = {
cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
location: Location;

View File

@ -14,10 +14,10 @@ var port_1 = require("./port");
var relationAuth_1 = require("./relationAuth");
var style_1 = require("./style");
var geo_1 = require("./geo");
function initialize(aspectWrapper, storageSchema, contextBuilder, store, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, colorDict) {
function initialize(aspectWrapper, storageSchema, contextBuilder, store, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities, colorDict) {
var cache = new cache_1.Cache(aspectWrapper, contextBuilder, store);
var location = new location_1.Location();
var relationAuth = new relationAuth_1.RelationAuth(aspectWrapper, cache, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap);
var relationAuth = new relationAuth_1.RelationAuth(aspectWrapper, cache, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities);
var runningTree = new runningTree_1.RunningTree(cache, storageSchema, relationAuth);
var locales = new locales_1.Locales(aspectWrapper);
var geo = new geo_1.Geo(aspectWrapper);

View File

@ -14,7 +14,7 @@ export declare class RelationAuth<ED extends EntityDict & BaseEntityDict, Cxt ex
private baseRelationAuth;
private authDeduceRelationMap;
static IgnoredActions: string[];
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>, cache: Cache<ED, Cxt, FrontCxt, AD>, actionCascadePathGraph: AuthCascadePath<ED>[], relationCascadePathGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>);
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>, cache: Cache<ED, Cxt, FrontCxt, AD>, actionCascadePathGraph: AuthCascadePath<ED>[], relationCascadePathGraph: AuthCascadePath<ED>[], authDeduceRelationMap: AuthDeduceRelationMap<ED>, selectFreeEntities: (keyof ED)[]);
private judgeRelation;
getHasRelationEntities(): string[];
getDeduceRelationAttribute(entity: keyof ED): string | undefined;
@ -29,18 +29,4 @@ export declare class RelationAuth<ED extends EntityDict & BaseEntityDict, Cxt ex
getCascadeRelationAuthsBySource(entity: keyof ED): AuthCascadePath<ED>[];
getCascadeRelationAuths(entity: keyof ED, ir: boolean): AuthCascadePath<ED>[];
checkRelation<T extends keyof ED>(entity: T, operation: ED[T]['Operation'] | ED[T]['Selection'], context: FrontCxt): void;
private freeActionAuthDict;
private directActionAuthDict;
/**
* free和direct访问权限
* @param entity
*/
private tryGetFreeAndDirectActionAuthInfo;
/**
* actionrelation结构的数据
* @param entity
* @param userId
* @param actions
*/
getRelationalProjection<T extends keyof ED>(entity: T, userId: string, actions: ED[T]['Action'][]): ED[T]["Selection"]["data"] | undefined;
}

View File

@ -3,16 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.RelationAuth = void 0;
var tslib_1 = require("tslib");
var Feature_1 = require("../types/Feature");
var lodash_1 = require("oak-domain/lib/utils/lodash");
var RelationAuth_1 = require("oak-domain/lib/store/RelationAuth");
var assert_1 = tslib_1.__importDefault(require("assert"));
var relation_1 = require("oak-domain/lib/store/relation");
var RelationAuth = /** @class */ (function (_super) {
tslib_1.__extends(RelationAuth, _super);
function RelationAuth(aspectWrapper, cache, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap) {
function RelationAuth(aspectWrapper, cache, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities) {
var _this = _super.call(this) || this;
_this.freeActionAuthDict = {};
_this.directActionAuthDict = {};
_this.aspectWrapper = aspectWrapper,
_this.cache = cache;
_this.actionCascadePathGraph = actionCascadePathGraph;
@ -28,7 +24,7 @@ var RelationAuth = /** @class */ (function (_super) {
}
});
_this.authDeduceRelationMap = authDeduceRelationMap;
_this.baseRelationAuth = new RelationAuth_1.RelationAuth(cache.getSchema(), actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap);
_this.baseRelationAuth = new RelationAuth_1.RelationAuth(cache.getSchema(), actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities);
return _this;
}
RelationAuth.prototype.judgeRelation = function (entity, attr) {
@ -75,115 +71,6 @@ var RelationAuth = /** @class */ (function (_super) {
RelationAuth.prototype.checkRelation = function (entity, operation, context) {
this.baseRelationAuth.checkRelationSync(entity, operation, context);
};
/**
* 对目标对象的free和direct访问权限每次需要的时候去后台取到缓存中
* @param entity
*/
RelationAuth.prototype.tryGetFreeAndDirectActionAuthInfo = function (entity) {
if (!this.freeActionAuthDict[entity]) {
this.freeActionAuthDict[entity] = true; // 先假设后台不会更新这些数据
this.cache.refresh('freeActionAuth', {
data: {
id: 1,
deActions: 1,
destEntity: 1,
},
filter: {
destEntity: entity,
},
});
}
if (!this.directActionAuthDict[entity]) {
this.directActionAuthDict[entity] = true;
this.cache.refresh('directActionAuth', {
data: {
id: 1,
path: 1,
deActions: 1,
destEntity: 1,
},
filter: {
destEntity: entity,
},
});
}
};
/**
* 根据对目标对象可能的action去获取相关可能的relation结构的数据
* @param entity
* @param userId
* @param actions
*/
RelationAuth.prototype.getRelationalProjection = function (entity, userId, actions) {
var _this = this;
var paths = this.actionCascadePathMap[entity];
var irurProjection = {
$entity: 'userRelation',
data: {
id: 1,
relationId: 1,
relation: {
id: 1,
name: 1,
display: 1,
actionAuth$relation: {
$entity: 'actionAuth',
data: {
id: 1,
path: 1,
destEntity: 1,
deActions: 1,
relationId: 1,
},
filter: {
path: '',
destEntity: entity,
deActions: {
$overlaps: actions,
}
}
}
},
entity: 1,
entityId: 1,
},
filter: {
userId: userId,
},
};
this.tryGetFreeAndDirectActionAuthInfo(entity);
if (paths) {
var projection_1 = {};
paths.forEach(function (_a) {
var _b = tslib_1.__read(_a, 4), e = _b[0], p = _b[1], r = _b[2], ir = _b[3];
var ps = p.split('.');
if (ps.length === 0) {
(0, assert_1.default)(ir);
Object.assign(projection_1, {
userRelation$entity: irurProjection
});
}
else if (ir) {
(0, lodash_1.set)(projection_1, p ? "".concat(p, ".userRelation$entity") : 'userRelation$entity', irurProjection);
}
else {
// 这里最好不要产生user: { id: 1 }的格式,在倒数第二层进行处理
var entity_1 = r;
var attr = ps.pop();
(0, assert_1.default)(attr);
var rel = _this.judgeRelation(entity_1, attr);
if (rel === 2) {
(0, lodash_1.set)(projection_1, "".concat(ps.join('.'), ".entity"), 1);
(0, lodash_1.set)(projection_1, "".concat(ps.join('.'), ".entityId"), 1);
}
else {
(0, lodash_1.set)(projection_1, "".concat(ps.join('.'), ".").concat(attr, "Id"), 1);
}
}
});
return projection_1;
}
};
RelationAuth.IgnoredActions = ['download', 'aggregate', 'count', 'stat'];
return RelationAuth;
}(Feature_1.Feature));

View File

@ -128,13 +128,14 @@ declare class ListNode<ED extends EntityDict & BaseEntityDict, T extends keyof E
setCurrentPage(currentPage: number, append?: boolean): void;
clean(): void;
getChildOperation(child: SingleNode<ED, T, Cxt, FrontCxt, AD>): ED[T]["CreateSingle"] | ED[T]["Update"] | ED[T]["Remove"] | undefined;
getIntrinsticFilters(): ED[T]["Selection"]["filter"];
getIntrinsticFilters(): ED[T]["Selection"]["filter"] | undefined;
}
declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt>> extends Node<ED, T, Cxt, FrontCxt, AD> {
private id?;
private children;
private filters?;
private operation?;
constructor(entity: T, schema: StorageSchema<ED>, cache: Cache<ED, Cxt, FrontCxt, AD>, relationAuth: RelationAuth<ED, Cxt, FrontCxt, AD>, projection?: ED[T]['Selection']['data'] | (() => Promise<ED[T]['Selection']['data']>), parent?: SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, T, Cxt, FrontCxt, AD> | VirtualNode<ED, Cxt, FrontCxt, AD>, path?: string, id?: string, actions?: ActionDef<ED, T>[] | (() => ActionDef<ED, T>[]), cascadeActions?: () => {
constructor(entity: T, schema: StorageSchema<ED>, cache: Cache<ED, Cxt, FrontCxt, AD>, relationAuth: RelationAuth<ED, Cxt, FrontCxt, AD>, projection?: ED[T]['Selection']['data'] | (() => Promise<ED[T]['Selection']['data']>), parent?: SingleNode<ED, keyof ED, Cxt, FrontCxt, AD> | ListNode<ED, T, Cxt, FrontCxt, AD> | VirtualNode<ED, Cxt, FrontCxt, AD>, path?: string, id?: string, filters?: NamedFilterItem<ED, T>[], actions?: ActionDef<ED, T>[] | (() => ActionDef<ED, T>[]), cascadeActions?: () => {
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
});
protected getChildPath(child: Node<ED, keyof ED, Cxt, FrontCxt, AD>): string;
@ -163,7 +164,8 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
getProjection(context?: FrontCxt, withDecendants?: boolean): ED[T]["Selection"]["data"] | undefined;
refresh(): Promise<void>;
clean(): void;
getFilter(): ED[T]['Selection']['filter'] | undefined;
private getFilter;
getIntrinsticFilters(): ED[T]["Selection"]["filter"] | undefined;
/**
* getParentFilter不能假设一定已经有数据filter的条件去构造
* @param childNode
@ -266,7 +268,7 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict, Cxt ext
addNamedSorter<T extends keyof ED>(path: string, sorter: NamedSorterItem<ED, T>, refresh?: boolean): void;
removeNamedSorter<T extends keyof ED>(path: string, sorter: NamedSorterItem<ED, T>, refresh?: boolean): void;
removeNamedSorterByName(path: string, name: string, refresh?: boolean): void;
getIntrinsticFilters(path: string): ED[keyof ED]["Selection"]["filter"];
getIntrinsticFilters(path: string): ED[keyof ED]["Selection"]["filter"] | undefined;
tryExecute(path: string): boolean | Error;
getOperations(path: string): {
entity: keyof ED;

View File

@ -9,119 +9,6 @@ var modi_1 = require("oak-domain/lib/store/modi");
var relation_1 = require("oak-domain/lib/store/relation");
var Feature_1 = require("../types/Feature");
var uuid_1 = require("oak-domain/lib/utils/uuid");
var string_1 = require("oak-domain/lib/utils/string");
function translateAuthItemToProjection(schema, entity, item, userId, prefix) {
var cascadePath = item.cascadePath, relations = item.relations;
var paths = cascadePath.split('.');
var makeUserEntityProjection = function (entity2) {
var _a, _b;
(0, assert_1.assert)(entity2 !== 'user');
var filter = {
userId: userId,
};
// 数组目前不太好merge
/* if (relations) {
Object.assign(filter, {
relation: {
$in: relations,
}
});
} */
var projection = (_a = {
id: 1
},
_a["user".concat((0, string_1.firstLetterUpperCase)(entity2), "$").concat(entity2, "$244")] = {
$entity: "user".concat((0, string_1.firstLetterUpperCase)(entity2)),
data: (_b = {
id: 1,
userId: 1
},
_b["".concat(entity2, "Id")] = 1,
_b.relation = 1,
_b),
filter: filter,
},
_a);
return projection;
};
var translateIter = function (entity2, iter) {
var _a, _b, _c, _d;
var attr = paths[iter];
var rel = (0, relation_1.judgeRelation)(schema, entity2, attr);
if (iter === paths.length - 1) {
if (rel === 2) {
if (attr === 'user') {
return {
id: 1,
entity: 1,
entityId: 1,
};
}
else {
return _a = {
id: 1
},
_a[attr] = makeUserEntityProjection(attr),
_a;
}
}
else {
if (rel === 'user') {
return _b = {
id: 1
},
_b["".concat(attr, "Id")] = 1,
_b;
}
else {
return _c = {
id: 1
},
_c[attr] = makeUserEntityProjection(rel),
_c;
}
}
}
else {
var proj2 = translateIter(rel === 2 ? attr : rel, iter + 1);
return _d = {
id: 1
},
_d[attr] = proj2,
_d;
}
};
if (!cascadePath) {
return makeUserEntityProjection(entity);
}
if (prefix && paths[0] !== prefix) {
// 不在相关路径上的关系在这里不查
return {};
}
return translateIter(entity, 0);
}
function makeRelationRefProjection(schema, authDict, entity, action, userId, prefix) {
var _a, _b, _c;
var proj = {};
if (authDict[entity] && ((_a = authDict[entity]) === null || _a === void 0 ? void 0 : _a.actionAuth) && ((_b = authDict[entity]) === null || _b === void 0 ? void 0 : _b.actionAuth[action])) {
var actionDef = (_c = authDict[entity]) === null || _c === void 0 ? void 0 : _c.actionAuth[action];
if (actionDef instanceof Array) {
var proj2 = actionDef.map(function (ad) {
if (ad instanceof Array) {
var proj3 = ad.map(function (add) { return translateAuthItemToProjection(schema, entity, add, userId, prefix); }).reduce(function (prev, current) { return (0, lodash_1.merge)(prev, current); }, {});
return proj3;
}
return translateAuthItemToProjection(schema, entity, ad, userId, prefix);
}).reduce(function (prev, current) { return (0, lodash_1.merge)(prev, current); }, {});
(0, lodash_1.merge)(proj, proj2);
}
else {
var proj2 = translateAuthItemToProjection(schema, entity, actionDef, userId);
(0, lodash_1.merge)(proj, proj2);
}
}
return proj;
}
var Node = /** @class */ (function (_super) {
tslib_1.__extends(Node, _super);
function Node(entity, schema, cache, relationAuth, projection, parent, path, actions, cascadeActions) {
@ -219,46 +106,7 @@ var Node = /** @class */ (function (_super) {
};
Node.prototype.getProjection = function (context) {
var projection = typeof this.projection === 'function' ? this.projection() : (this.projection && (0, lodash_1.cloneDeep)(this.projection));
// 根据actions和cascadeActions的定义将对应的projection构建出来
var userId = context ? context.getCurrentUserId(true) : this.cache.getCurrentUserId(true);
var actions = typeof this.actions === 'function' ? this.actions() : this.actions;
if (userId && projection && (actions === null || actions === void 0 ? void 0 : actions.length)) {
var actions2 = actions.map(function (a) { return typeof a === 'object' ? a.action : a; });
var projection2 = this.relationAuth.getRelationalProjection(this.entity, userId, actions2);
(0, lodash_1.merge)(projection, projection2);
}
return projection;
// 老的数据结构下的getProjection代码留一段时间作参照 by Xc 20230426
/* if (userId && projection) {
if (this.actions) {
const actions = typeof this.actions === 'function' ? this.actions() : this.actions;
for (const a of actions) {
const action = typeof a === 'object' ? a.action : a;
const proj = makeRelationRefProjection(this.schema, this.authDict, this.entity!, action, userId);
merge(projection, proj);
}
}
if (this.cascadeActions) {
const cas = this.cascadeActions();
for (const attr in cas) {
const rel = this.judgeRelation(attr);
assert(rel instanceof Array);
for (const a of cas[attr]!) {
const action = typeof a === 'object' ? a.action : a;
if (rel[1]) {
const proj = makeRelationRefProjection(this.schema, this.authDict, rel[0], action, this.entity as string);
merge(projection, proj[rel[1].slice(0, rel[1].length - 2)]);
}
else {
const proj = makeRelationRefProjection(this.schema, this.authDict, rel[0], action, this.entity as string);
merge(projection, proj[this.entity as string]);
}
}
}
}
} */
};
Node.prototype.setProjection = function (projection) {
(0, assert_1.assert)(!this.projection);
@ -569,18 +417,26 @@ var ListNode = /** @class */ (function (_super) {
* 修改memeory-tree当属性缺失不再报missedRow改回直接用filter去取数据的逻辑
*/
var _a = this.constructSelection(true, context, true), data = _a.data, sorter = _a.sorter, filter = _a.filter;
var result = this.cache.get(this.entity, {
data: data,
filter: {
if (filter || this.ids) {
var filter2 = filter && this.ids ? {
$or: [filter, {
id: {
$in: this.ids || [],
}
}]
},
sorter: sorter,
}, context, this.isLoading());
return result.filter(function (ele) { var _a; return ele.$$createAt$$ === 1 || ((_a = _this.ids) === null || _a === void 0 ? void 0 : _a.includes(ele.id)); });
} : filter || {
id: {
$in: this.ids,
}
};
var result = this.cache.get(this.entity, {
data: data,
filter: filter2,
sorter: sorter,
}, context, this.isLoading());
return result.filter(function (ele) { var _a; return ele.$$createAt$$ === 1 || ((_a = _this.ids) === null || _a === void 0 ? void 0 : _a.includes(ele.id)); });
}
return [];
/* const finalIds = result.filter(
ele => ele.$$createAt$$ === 1
).map(ele => ele.id).concat(this.ids);
@ -1007,9 +863,10 @@ var ListNode = /** @class */ (function (_super) {
}(Node));
var SingleNode = /** @class */ (function (_super) {
tslib_1.__extends(SingleNode, _super);
function SingleNode(entity, schema, cache, relationAuth, projection, parent, path, id, actions, cascadeActions) {
function SingleNode(entity, schema, cache, relationAuth, projection, parent, path, id, filters, actions, cascadeActions) {
var _this = _super.call(this, entity, schema, cache, relationAuth, projection, parent, path, actions, cascadeActions) || this;
_this.children = {};
_this.filters = filters;
if (!id) {
// 不传id先假设是创建动作
_this.create({});
@ -1336,50 +1193,55 @@ var SingleNode = /** @class */ (function (_super) {
return projection;
};
SingleNode.prototype.refresh = function () {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var projection, filter, _b, value, modi$entity, err_2;
var projection, filter, _a, value, err_2;
var _this = this;
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
// SingleNode如果是ListNode的子结点则不必refresh优化ListNode有义务负责子层对象的数据
if (this.parent && this.parent instanceof ListNode && this.parent.getEntity() === this.getEntity()) {
this.publish();
return [2 /*return*/];
}
// 如果是新建也不用refresh
if (((_a = this.operation) === null || _a === void 0 ? void 0 : _a.operation.action) === 'create') {
return [2 /*return*/];
}
projection = this.getProjection(undefined, true);
filter = this.getFilter();
if (!(projection && filter)) return [3 /*break*/, 4];
this.setLoading(true);
this.publish();
_c.label = 1;
_b.label = 1;
case 1:
_c.trys.push([1, 3, , 4]);
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.cache.refresh(this.entity, {
data: projection,
filter: filter,
}, undefined, undefined, function () {
// 刷新后所有的更新都应当被丢弃子层上可能会自动建立了this.create动作 这里可能会有问题 by Xc 20230329
if (_this.schema[_this.entity].toModi) {
// 对于modi对象在此缓存modiIds
var rows = _this.cache.get('modi', {
data: {
id: 1,
},
filter: {
entity: _this.entity,
entityId: _this.id,
iState: 'active',
}
});
if (rows.length > 0) {
_this.modiIds = rows.map(function (ele) { return ele.id; });
}
}
_this.setFiltersAndSortedApplied();
_this.setLoading(false);
_this.clean();
})];
case 2:
_b = tslib_1.__read.apply(void 0, [(_c.sent()).data, 1]), value = _b[0];
// 对于modi对象在此缓存modiIds
if (this.schema[this.entity].toModi && value) {
modi$entity = value.modi$entity;
this.modiIds = modi$entity.map(function (ele) { return ele.id; });
this.publish();
}
_a = tslib_1.__read.apply(void 0, [(_b.sent()).data, 1]), value = _a[0];
return [3 /*break*/, 4];
case 3:
err_2 = _c.sent();
err_2 = _b.sent();
this.setLoading(false);
throw err_2;
case 4: return [2 /*return*/];
@ -1398,9 +1260,24 @@ var SingleNode = /** @class */ (function (_super) {
}
};
SingleNode.prototype.getFilter = function () {
return {
var _a;
// 如果是新建等于没有filter
if (((_a = this.operation) === null || _a === void 0 ? void 0 : _a.operation.action) === 'create') {
return;
}
// singleNode的filter可以减枝权限的路径判断
var filter = {
id: this.id,
};
if (this.filters) {
this.filters.forEach(function (f) {
filter = (0, filter_1.addFilterSegment)(filter, f.filter);
});
}
return filter;
};
SingleNode.prototype.getIntrinsticFilters = function () {
return this.getFilter();
};
/**
* getParentFilter不能假设一定已经有数据只能根据当前filter的条件去构造
@ -1787,7 +1664,7 @@ var RunningTree = /** @class */ (function (_super) {
}
else {
node = new SingleNode(entity, this.schema, this.cache, this.relationAuth, projection, parentNode, // 过编译
path, id, actions, cascadeActions);
path, id, filters, actions, cascadeActions);
}
}
else {
@ -2059,7 +1936,7 @@ var RunningTree = /** @class */ (function (_super) {
};
RunningTree.prototype.getIntrinsticFilters = function (path) {
var node = this.findNode(path);
(0, assert_1.assert)(node instanceof ListNode);
(0, assert_1.assert)(node instanceof ListNode || node instanceof SingleNode);
return node.getIntrinsticFilters();
};
RunningTree.prototype.tryExecute = function (path) {

View File

@ -1,11 +0,0 @@
import { BasicFeatures } from '../features';
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
import { Aspect, EntityDict } from 'oak-domain/lib/types';
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
declare type ED = EntityDict & BaseEntityDict;
declare type Cxt = AsyncContext<ED>;
declare type FrontCxt = SyncContext<ED>;
declare type AD = Record<string, Aspect<ED, Cxt>>;
export default function useFeatures(): BasicFeatures<ED, Cxt, FrontCxt, AD>;
export {};

View File

@ -1,9 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var features_1 = require("../platforms/web/features");
// react 独有
function useFeatures() {
return (0, features_1.useFeatures)();
}
exports.default = useFeatures;
;

View File

@ -26,7 +26,7 @@ var CacheStore_1 = require("./cacheStore/CacheStore");
*/
function initialize(storageSchema, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, option) {
var _this = this;
var cascadeRemoveDict = option.cascadeRemoveDict, actionCascadePathGraph = option.actionCascadePathGraph, actionDict = option.actionDict, relationCascadePathGraph = option.relationCascadePathGraph, authDeduceRelationMap = option.authDeduceRelationMap, colorDict = option.colorDict, importations = option.importations, exportations = option.exportations;
var cascadeRemoveDict = option.cascadeRemoveDict, actionCascadePathGraph = option.actionCascadePathGraph, actionDict = option.actionDict, relationCascadePathGraph = option.relationCascadePathGraph, authDeduceRelationMap = option.authDeduceRelationMap, colorDict = option.colorDict, importations = option.importations, exportations = option.exportations, selectFreeEntities = option.selectFreeEntities;
var intersected = (0, lodash_1.intersection)(Object.keys(oak_common_aspect_1.default), Object.keys(aspectDict));
if (intersected.length > 0) {
throw new Error("\u7528\u6237\u5B9A\u4E49\u7684aspect\u4E2D\u4E0D\u80FD\u548C\u7CFB\u7EDFaspect\u540C\u540D\uFF1A\u300C".concat(intersected.join(','), "\u300D"));
@ -34,7 +34,7 @@ function initialize(storageSchema, frontendContextBuilder, backendContextBuilder
var aspectDict2 = Object.assign({}, aspectDict, oak_common_aspect_1.default);
var checkers2 = (checkers).concat((0, index_1.createDynamicCheckers)(storageSchema, cascadeRemoveDict || {}));
var triggers2 = (0, index_2.createDynamicTriggers)(storageSchema).concat(triggers);
var debugStore = (0, debugStore_1.createDebugStore)(storageSchema, backendContextBuilder, triggers2, checkers2, watchers, timers, startRoutines, initialData, actionDict, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap);
var debugStore = (0, debugStore_1.createDebugStore)(storageSchema, backendContextBuilder, triggers2, checkers2, watchers, timers, startRoutines, initialData, actionDict, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities);
var cacheStore = new CacheStore_1.CacheStore(storageSchema, function () { return debugStore.getCurrentData(); }, function () { return (0, debugStore_1.clearMaterializedData)(); });
var wrapper = {
exec: function (name, params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
@ -75,7 +75,7 @@ function initialize(storageSchema, frontendContextBuilder, backendContextBuilder
});
}); },
};
var features = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder()(cacheStore); }, cacheStore, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, colorDict);
var features = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder()(cacheStore); }, cacheStore, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities, colorDict);
checkers2.forEach(function (checker) { return cacheStore.registerChecker(checker); });
if (actionDict) {
var adCheckers = (0, actionDef_1.analyzeActionDefDict)(storageSchema, actionDict).checkers;

View File

@ -21,7 +21,7 @@ var checkers_1 = require("oak-domain/lib/checkers");
*/
function initialize(storageSchema, frontendContextBuilder, connector, checkers, option) {
var _this = this;
var cascadeRemoveDict = option.cascadeRemoveDict, actionCascadePathGraph = option.actionCascadePathGraph, relationCascadePathGraph = option.relationCascadePathGraph, authDeduceRelationMap = option.authDeduceRelationMap, actionDict = option.actionDict, colorDict = option.colorDict;
var cascadeRemoveDict = option.cascadeRemoveDict, actionCascadePathGraph = option.actionCascadePathGraph, relationCascadePathGraph = option.relationCascadePathGraph, authDeduceRelationMap = option.authDeduceRelationMap, actionDict = option.actionDict, selectFreeEntities = option.selectFreeEntities, colorDict = option.colorDict;
var checkers2 = (checkers || []).concat((0, checkers_1.createDynamicCheckers)(storageSchema, cascadeRemoveDict || {}));
var cacheStore = new CacheStore_1.CacheStore(storageSchema);
var wrapper = {
@ -43,7 +43,7 @@ function initialize(storageSchema, frontendContextBuilder, connector, checkers,
});
}); },
};
var features = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder()(cacheStore); }, cacheStore, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, colorDict);
var features = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder()(cacheStore); }, cacheStore, actionCascadePathGraph, relationCascadePathGraph, authDeduceRelationMap, selectFreeEntities, colorDict);
checkers2.forEach(function (checker) { return cacheStore.registerChecker(checker); });
if (actionDict) {
var adCheckers = (0, actionDef_1.analyzeActionDefDict)(storageSchema, actionDict).checkers;

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,8 +0,0 @@
type Options = {
width?: number,
height?: number,
devicePixelRatio?: number // 像素
}
export declare function init(dom: any, theme?: string | null, options?: Options): any;

View File

@ -1,8 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index",
"l-popup":"../popup/index",
"l-button":"../button/index"
}
}

View File

@ -1,5 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-popup": "../popup/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index"
}
}

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"day":"../day/index"
}
}

View File

@ -1,10 +0,0 @@
{
"component": true,
"usingComponents": {
"header":"./components/header/index",
"mounth":"./components/mounth/index",
"l-toast": "../toast/index",
"l-popup": "../popup/index",
"l-button": "../button/index"
}
}

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-error-tip":"../error-tip/index",
"l-checkbox": "../checkbox/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-button": "../button/index"
}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-list": "../list/index",
"l-icon": "../icon/index"
}
}

View File

@ -1,5 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index",
"l-badge":"../badge/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index"
}
}

View File

@ -1,3 +0,0 @@
{
"component": true
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-popup": "../popup/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-error-tip":"../error-tip/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-grid-item":"../grid-item/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {
"l-icon": "../icon/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-index-list": "../index-list/index"
}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon": "../icon/index",
"l-error-tip":"../error-tip/index"
}
}

View File

@ -1,8 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon": "../icon/index",
"l-badge": "../badge/index",
"l-tag": "../tag/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-loading":"../loading/index"
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index"
}
}

View File

@ -1,8 +0,0 @@
{
"component": true,
"usingComponents":
{
"l-icon": "../icon/index"
}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon": "../icon/index",
"l-error-tip": "../error-tip/index"
}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-error-tip": "../error-tip/index",
"l-radio":"../radio/index"
}
}

View File

@ -1,4 +0,0 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -1,6 +0,0 @@
{
"component": true,
"usingComponents": {
"l-icon":"../icon/index"
}
}

View File

@ -1,7 +0,0 @@
{
"component": true,
"usingComponents": {
"l-input": "../input/index",
"l-icon": "../icon/index"
}
}

Some files were not shown because too many files have changed in this diff Show More