actionAuth的初始数据改变

This commit is contained in:
Xu Chang 2023-10-26 11:59:55 +08:00
parent 03dafed548
commit 7cbd4a23b9
50 changed files with 1124 additions and 249 deletions

View File

@ -1,38 +1,32 @@
const actionAuths = [
{
id: 'message-user',
paths: ['user'],
destEntity: 'message',
pathId: 'msg-user',
deActions: ['select', 'remove', 'update'],
},
{
id: 'mobile-user',
paths: ['user'],
destEntity: 'mobile',
pathId: 'mobile-user',
deActions: ['create', 'update', 'remove', 'select'],
},
{
id: 'token-user',
paths: ['user'],
destEntity: 'token',
pathId: 'token-user',
deActions: ['create', 'update', 'remove', 'select'],
},
{
id: 'wechatLogin-user',
paths: ['user'],
destEntity: 'wechatLogin',
pathId: 'wchL-user',
deActions: ['create', 'update', 'select'],
},
{
id: 'wechatUser-user',
paths: ['user'],
destEntity: 'wechatUser',
pathId: 'wchU-user',
deActions: ['create', 'update', 'select'],
},
{
id: 'passwordChangeTemp-user',
paths: ['user'],
destEntity: 'passwordChangeTemp',
pathId: 'pwdCT-user',
deActions: ['create', 'select'],
},
];

1
es/data/index.d.ts vendored
View File

@ -29,5 +29,6 @@ declare const _default: {
station: import("../oak-app-domain/Station/Schema").CreateOperationData[];
subwayStation: import("../oak-app-domain/SubwayStation/Schema").CreateOperationData[];
actionAuth: import("../oak-app-domain/ActionAuth/Schema").CreateOperationData[];
path: import("../oak-app-domain/Path/Schema").CreateOperationData[];
};
export default _default;

View File

@ -4,6 +4,7 @@ import subway from "./subway";
import station from "./station";
import subwayStation from "./subwayStation";
import actionAuth from './actionAuth';
import path from './path';
export default {
user: users,
mobile: mobiles,
@ -13,4 +14,5 @@ export default {
station,
subwayStation,
actionAuth,
path,
};

3
es/data/path.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import { CreateOperationData as Path } from '../oak-app-domain/Path/Schema';
declare const paths: Path[];
export default paths;

45
es/data/path.js Normal file
View File

@ -0,0 +1,45 @@
const paths = [
{
id: 'msg-user',
sourceEntity: 'user',
destEntity: 'message',
value: 'user',
recursive: false,
},
{
id: 'mobile-user',
sourceEntity: 'user',
destEntity: 'mobile',
value: 'user',
recursive: false,
},
{
id: 'token-user',
sourceEntity: 'user',
destEntity: 'token',
value: 'user',
recursive: false,
},
{
id: 'wchL-user',
sourceEntity: 'user',
destEntity: 'wechatLogin',
value: 'user',
recursive: false,
},
{
id: 'wchU-user',
sourceEntity: 'user',
destEntity: 'wechatUser',
value: 'user',
recursive: false,
},
{
id: 'pwdCT-user',
sourceEntity: 'user',
destEntity: 'passwordChangeTemp',
value: 'user',
recursive: false,
},
];
export default paths;

View File

@ -3,24 +3,22 @@ import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey,
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import * as Relation from "../Relation/Schema";
import * as Path from "../Path/Schema";
type Actions = string[];
type Paths = string[];
export type OpSchema = EntityShape & {
relationId?: ForeignKey<"relation"> | null;
paths: Paths;
destEntity: String<32>;
pathId: ForeignKey<"path">;
deActions: Actions;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
relationId?: ForeignKey<"relation"> | null;
paths: Paths;
destEntity: String<32>;
pathId: ForeignKey<"path">;
deActions: Actions;
relation?: Relation.Schema | null;
path: Path.Schema;
} & {
[A in ExpressionKey]?: any;
};
@ -31,8 +29,8 @@ type AttrFilter = {
$$updateAt$$: Q_DateValue;
relationId: Q_StringValue;
relation: Relation.Filter;
paths: JsonFilter<Paths>;
destEntity: Q_StringValue;
pathId: Q_StringValue;
path: Path.Filter;
deActions: JsonFilter<Actions>;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
@ -45,8 +43,8 @@ export type Projection = {
$$seq$$?: number;
relationId?: number;
relation?: Relation.Projection;
paths?: number | JsonProjection<Paths>;
destEntity?: number;
pathId?: number;
path?: Path.Projection;
deActions?: number | JsonProjection<Actions>;
} & Partial<ExprOp<OpAttr | string>>;
type ActionAuthIdProjection = OneOf<{
@ -55,6 +53,9 @@ type ActionAuthIdProjection = OneOf<{
type RelationIdProjection = OneOf<{
relationId: number;
}>;
type PathIdProjection = OneOf<{
pathId: number;
}>;
export type SortAttr = {
id: number;
} | {
@ -68,9 +69,9 @@ export type SortAttr = {
} | {
relation: Relation.SortAttr;
} | {
paths: number;
pathId: number;
} | {
destEntity: number;
path: Path.SortAttr;
} | {
deActions: number;
} | {
@ -84,7 +85,7 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId">> & (({
export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId" | "pathId">> & (({
relationId?: never;
relation?: Relation.CreateSingleOperation;
} | {
@ -92,11 +93,19 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId">> &
relation?: Relation.UpdateOperation;
} | {
relationId?: ForeignKey<"relation">;
}) & ({
pathId?: never;
path: Path.CreateSingleOperation;
} | {
pathId: ForeignKey<"path">;
path?: Path.UpdateOperation;
} | {
pathId: ForeignKey<"path">;
}));
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId">> & (({
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId" | "pathId">> & (({
relation: Relation.CreateSingleOperation;
relationId?: never;
} | {
@ -108,16 +117,31 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId">> &
} | {
relation?: never;
relationId?: ForeignKey<"relation"> | null;
}) & ({
path: Path.CreateSingleOperation;
pathId?: never;
} | {
path: Path.UpdateOperation;
pathId?: never;
} | {
path: Path.RemoveOperation;
pathId?: never;
} | {
path?: never;
pathId?: ForeignKey<"path"> | null;
})) & {
[k: string]: any;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
relation?: Relation.UpdateOperation | Relation.RemoveOperation;
}) & ({
path?: Path.UpdateOperation | Path.RemoveOperation;
}));
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type RelationIdSubQuery = Selection<RelationIdProjection>;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type ActionAuthIdSubQuery = Selection<ActionAuthIdProjection>;
export type EntityDef = {
Schema: Schema;

View File

@ -5,16 +5,10 @@ export const desc = {
type: "ref",
ref: "relation"
},
paths: {
pathId: {
notNull: true,
type: "object"
},
destEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
type: "ref",
ref: "path"
},
deActions: {
notNull: true,
@ -25,15 +19,18 @@ export const desc = {
actions,
indexes: [
{
name: 'index_entity_relation',
name: 'index_relation_path',
attributes: [
{
name: 'destEntity',
},
{
name: "relationId",
},
{
name: "pathId",
}
],
config: {
unique: true,
},
}
]
};

View File

@ -1 +1 @@
{ "name": "用户授权", "attr": { "relation": "关系", "paths": "路径", "destEntity": "目标对象", "deActions": "目标对象动作" } }
{ "name": "用户授权", "attr": { "relation": "关系", "path": "路径", "deActions": "目标对象动作" } }

View File

@ -4,6 +4,7 @@ import { EntityDef as Modi } from "./Modi/Schema";
import { EntityDef as ModiEntity } from "./ModiEntity/Schema";
import { EntityDef as Oper } from "./Oper/Schema";
import { EntityDef as OperEntity } from "./OperEntity/Schema";
import { EntityDef as Path } from "./Path/Schema";
import { EntityDef as Relation } from "./Relation/Schema";
import { EntityDef as RelationAuth } from "./RelationAuth/Schema";
import { EntityDef as User } from "./User/Schema";
@ -55,6 +56,7 @@ export type EntityDict = {
modiEntity: ModiEntity;
oper: Oper;
operEntity: OperEntity;
path: Path;
relation: Relation;
relationAuth: RelationAuth;
user: User;

125
es/oak-app-domain/Path/Schema.d.ts vendored Normal file
View File

@ -0,0 +1,125 @@
import { Q_DateValue, Q_BooleanValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { String, Boolean } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import * as ActionAuth from "../ActionAuth/Schema";
import * as RelationAuth from "../RelationAuth/Schema";
export type OpSchema = EntityShape & {
destEntity: String<32>;
value: String<256>;
recursive: Boolean;
sourceEntity: String<32>;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
destEntity: String<32>;
value: String<256>;
recursive: Boolean;
sourceEntity: String<32>;
actionAuth$path?: Array<ActionAuth.Schema>;
actionAuth$path$$aggr?: AggregationResult<ActionAuth.Schema>;
relationAuth$path?: Array<RelationAuth.Schema>;
relationAuth$path$$aggr?: AggregationResult<RelationAuth.Schema>;
} & {
[A in ExpressionKey]?: any;
};
type AttrFilter = {
id: Q_StringValue;
$$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue;
destEntity: Q_StringValue;
value: Q_StringValue;
recursive: Q_BooleanValue;
sourceEntity: Q_StringValue;
actionAuth$path: ActionAuth.Filter & SubQueryPredicateMetadata;
relationAuth$path: RelationAuth.Filter & SubQueryPredicateMetadata;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export type Projection = {
"#id"?: NodeId;
[k: string]: any;
id?: number;
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
destEntity?: number;
value?: number;
recursive?: number;
sourceEntity?: number;
actionAuth$path?: ActionAuth.Selection & {
$entity: "actionAuth";
};
actionAuth$path$$aggr?: ActionAuth.Aggregation & {
$entity: "actionAuth";
};
relationAuth$path?: RelationAuth.Selection & {
$entity: "relationAuth";
};
relationAuth$path$$aggr?: RelationAuth.Aggregation & {
$entity: "relationAuth";
};
} & Partial<ExprOp<OpAttr | string>>;
type PathIdProjection = OneOf<{
id: number;
}>;
export type SortAttr = {
id: number;
} | {
$$createAt$$: number;
} | {
$$seq$$: number;
} | {
$$updateAt$$: number;
} | {
destEntity: number;
} | {
value: number;
} | {
recursive: number;
} | {
sourceEntity: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;
export type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<OpSchema> & {
actionAuth$path?: OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">> | OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">>>;
relationAuth$path?: OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">> | OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">>>;
};
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any;
actionAuth$path?: OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<ActionAuth.RemoveOperation["action"], Omit<ActionAuth.RemoveOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">> | OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<ActionAuth.RemoveOperation["action"], Omit<ActionAuth.RemoveOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">>>;
relationAuth$path?: OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<RelationAuth.RemoveOperation["action"], Omit<RelationAuth.RemoveOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">> | OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<RelationAuth.RemoveOperation["action"], Omit<RelationAuth.RemoveOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">>>;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {};
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<GenericAction> | string;
Selection: Selection;
Aggregation: Aggregation;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};
export {};

View File

@ -0,0 +1 @@
export {};

3
es/oak-app-domain/Path/Storage.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import { StorageDesc } from "oak-domain/lib/types/Storage";
import { OpSchema } from "./Schema";
export declare const desc: StorageDesc<OpSchema>;

View File

@ -0,0 +1,51 @@
import { genericActions as actions } from "oak-domain/lib/actions/action";
export const desc = {
attributes: {
destEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
},
value: {
notNull: true,
type: "varchar",
params: {
length: 256
}
},
recursive: {
notNull: true,
type: "boolean"
},
sourceEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
}
},
actionType: "crud",
actions,
indexes: [
{
name: 'index_source_dest_path',
attributes: [
{
name: 'sourceEntity',
},
{
name: 'value',
},
{
name: 'destEntity',
},
],
config: {
unique: true,
},
}
]
};

View File

@ -0,0 +1 @@
{ "name": "关系路径", "attr": { "sourceEntity": "源对象", "value": "路径从dest到source", "destEntity": "目标对象", "recursive": "是否递归(目标对象)" } }

View File

@ -3,20 +3,21 @@ import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey }
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import * as Relation from "../Relation/Schema";
import * as Path from "../Path/Schema";
export type OpSchema = EntityShape & {
sourceRelationId: ForeignKey<"relation">;
path: String<256>;
pathId: ForeignKey<"path">;
destRelationId: ForeignKey<"relation">;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
sourceRelationId: ForeignKey<"relation">;
path: String<256>;
pathId: ForeignKey<"path">;
destRelationId: ForeignKey<"relation">;
sourceRelation: Relation.Schema;
path: Path.Schema;
destRelation: Relation.Schema;
} & {
[A in ExpressionKey]?: any;
@ -28,7 +29,8 @@ type AttrFilter = {
$$updateAt$$: Q_DateValue;
sourceRelationId: Q_StringValue;
sourceRelation: Relation.Filter;
path: Q_StringValue;
pathId: Q_StringValue;
path: Path.Filter;
destRelationId: Q_StringValue;
destRelation: Relation.Filter;
};
@ -42,7 +44,8 @@ export type Projection = {
$$seq$$?: number;
sourceRelationId?: number;
sourceRelation?: Relation.Projection;
path?: number;
pathId?: number;
path?: Path.Projection;
destRelationId?: number;
destRelation?: Relation.Projection;
} & Partial<ExprOp<OpAttr | string>>;
@ -53,6 +56,9 @@ type RelationIdProjection = OneOf<{
sourceRelationId: number;
destRelationId: number;
}>;
type PathIdProjection = OneOf<{
pathId: number;
}>;
export type SortAttr = {
id: number;
} | {
@ -66,7 +72,9 @@ export type SortAttr = {
} | {
sourceRelation: Relation.SortAttr;
} | {
path: number;
pathId: number;
} | {
path: Path.SortAttr;
} | {
destRelationId: number;
} | {
@ -82,7 +90,7 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationId" | "destRelationId">> & (({
export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationId" | "pathId" | "destRelationId">> & (({
sourceRelationId?: never;
sourceRelation: Relation.CreateSingleOperation;
} | {
@ -90,6 +98,14 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationI
sourceRelation?: Relation.UpdateOperation;
} | {
sourceRelationId: ForeignKey<"sourceRelation">;
}) & ({
pathId?: never;
path: Path.CreateSingleOperation;
} | {
pathId: ForeignKey<"path">;
path?: Path.UpdateOperation;
} | {
pathId: ForeignKey<"path">;
}) & ({
destRelationId?: never;
destRelation: Relation.CreateSingleOperation;
@ -102,7 +118,7 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationI
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationId" | "destRelationId">> & (({
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationId" | "pathId" | "destRelationId">> & (({
sourceRelation: Relation.CreateSingleOperation;
sourceRelationId?: never;
} | {
@ -114,6 +130,18 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationI
} | {
sourceRelation?: never;
sourceRelationId?: ForeignKey<"sourceRelation"> | null;
}) & ({
path: Path.CreateSingleOperation;
pathId?: never;
} | {
path: Path.UpdateOperation;
pathId?: never;
} | {
path: Path.RemoveOperation;
pathId?: never;
} | {
path?: never;
pathId?: ForeignKey<"path"> | null;
}) & ({
destRelation: Relation.CreateSingleOperation;
destRelationId?: never;
@ -132,12 +160,15 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationI
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
sourceRelation?: Relation.UpdateOperation | Relation.RemoveOperation;
}) & ({
path?: Path.UpdateOperation | Path.RemoveOperation;
}) & ({
destRelation?: Relation.UpdateOperation | Relation.RemoveOperation;
}));
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type RelationIdSubQuery = Selection<RelationIdProjection>;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type RelationAuthIdSubQuery = Selection<RelationAuthIdProjection>;
export type EntityDef = {
Schema: Schema;

View File

@ -6,12 +6,10 @@ export const desc = {
type: "ref",
ref: "relation"
},
path: {
pathId: {
notNull: true,
type: "varchar",
params: {
length: 256
}
type: "ref",
ref: "path"
},
destRelationId: {
notNull: true,
@ -29,7 +27,7 @@ export const desc = {
name: "sourceRelationId",
},
{
name: 'path',
name: "pathId",
},
{
name: "destRelationId",

View File

@ -4,6 +4,7 @@ import { desc as modiDesc } from "./Modi/Storage";
import { desc as modiEntityDesc } from "./ModiEntity/Storage";
import { desc as operDesc } from "./Oper/Storage";
import { desc as operEntityDesc } from "./OperEntity/Storage";
import { desc as pathDesc } from "./Path/Storage";
import { desc as relationDesc } from "./Relation/Storage";
import { desc as relationAuthDesc } from "./RelationAuth/Storage";
import { desc as userDesc } from "./User/Storage";
@ -55,6 +56,7 @@ export const storageSchema = {
modiEntity: modiEntityDesc,
oper: operDesc,
operEntity: operEntityDesc,
path: pathDesc,
relation: relationDesc,
relationAuth: relationAuthDesc,
user: userDesc,

View File

@ -4,6 +4,7 @@ import * as Modi from "./Modi/Schema";
import * as ModiEntity from "./ModiEntity/Schema";
import * as Oper from "./Oper/Schema";
import * as OperEntity from "./OperEntity/Schema";
import * as Path from "./Path/Schema";
import * as Relation from "./Relation/Schema";
import * as RelationAuth from "./RelationAuth/Schema";
import * as User from "./User/Schema";
@ -82,6 +83,15 @@ export type OperEntityIdSubQuery = {
entity: "operEntity";
}) | any;
};
export type PathIdSubQuery = {
[K in "$in" | "$nin"]?: (ActionAuth.PathIdSubQuery & {
entity: "actionAuth";
}) | (RelationAuth.PathIdSubQuery & {
entity: "relationAuth";
}) | (Path.PathIdSubQuery & {
entity: "path";
}) | any;
};
export type RelationIdSubQuery = {
[K in "$in" | "$nin"]?: (ActionAuth.RelationIdSubQuery & {
entity: "actionAuth";

View File

@ -3,38 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
const actionAuths = [
{
id: 'message-user',
paths: ['user'],
destEntity: 'message',
pathId: 'msg-user',
deActions: ['select', 'remove', 'update'],
},
{
id: 'mobile-user',
paths: ['user'],
destEntity: 'mobile',
pathId: 'mobile-user',
deActions: ['create', 'update', 'remove', 'select'],
},
{
id: 'token-user',
paths: ['user'],
destEntity: 'token',
pathId: 'token-user',
deActions: ['create', 'update', 'remove', 'select'],
},
{
id: 'wechatLogin-user',
paths: ['user'],
destEntity: 'wechatLogin',
pathId: 'wchL-user',
deActions: ['create', 'update', 'select'],
},
{
id: 'wechatUser-user',
paths: ['user'],
destEntity: 'wechatUser',
pathId: 'wchU-user',
deActions: ['create', 'update', 'select'],
},
{
id: 'passwordChangeTemp-user',
paths: ['user'],
destEntity: 'passwordChangeTemp',
pathId: 'pwdCT-user',
deActions: ['create', 'select'],
},
];

1
lib/data/index.d.ts vendored
View File

@ -29,5 +29,6 @@ declare const _default: {
station: import("../oak-app-domain/Station/Schema").CreateOperationData[];
subwayStation: import("../oak-app-domain/SubwayStation/Schema").CreateOperationData[];
actionAuth: import("../oak-app-domain/ActionAuth/Schema").CreateOperationData[];
path: import("../oak-app-domain/Path/Schema").CreateOperationData[];
};
export default _default;

View File

@ -7,6 +7,7 @@ const subway_1 = tslib_1.__importDefault(require("./subway"));
const station_1 = tslib_1.__importDefault(require("./station"));
const subwayStation_1 = tslib_1.__importDefault(require("./subwayStation"));
const actionAuth_1 = tslib_1.__importDefault(require("./actionAuth"));
const path_1 = tslib_1.__importDefault(require("./path"));
exports.default = {
user: userRole_1.users,
mobile: userRole_1.mobiles,
@ -16,4 +17,5 @@ exports.default = {
station: station_1.default,
subwayStation: subwayStation_1.default,
actionAuth: actionAuth_1.default,
path: path_1.default,
};

3
lib/data/path.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import { CreateOperationData as Path } from '../oak-app-domain/Path/Schema';
declare const paths: Path[];
export default paths;

47
lib/data/path.js Normal file
View File

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const paths = [
{
id: 'msg-user',
sourceEntity: 'user',
destEntity: 'message',
value: 'user',
recursive: false,
},
{
id: 'mobile-user',
sourceEntity: 'user',
destEntity: 'mobile',
value: 'user',
recursive: false,
},
{
id: 'token-user',
sourceEntity: 'user',
destEntity: 'token',
value: 'user',
recursive: false,
},
{
id: 'wchL-user',
sourceEntity: 'user',
destEntity: 'wechatLogin',
value: 'user',
recursive: false,
},
{
id: 'wchU-user',
sourceEntity: 'user',
destEntity: 'wechatUser',
value: 'user',
recursive: false,
},
{
id: 'pwdCT-user',
sourceEntity: 'user',
destEntity: 'passwordChangeTemp',
value: 'user',
recursive: false,
},
];
exports.default = paths;

View File

@ -3,24 +3,22 @@ import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey,
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import * as Relation from "../Relation/Schema";
import * as Path from "../Path/Schema";
type Actions = string[];
type Paths = string[];
export type OpSchema = EntityShape & {
relationId?: ForeignKey<"relation"> | null;
paths: Paths;
destEntity: String<32>;
pathId: ForeignKey<"path">;
deActions: Actions;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
relationId?: ForeignKey<"relation"> | null;
paths: Paths;
destEntity: String<32>;
pathId: ForeignKey<"path">;
deActions: Actions;
relation?: Relation.Schema | null;
path: Path.Schema;
} & {
[A in ExpressionKey]?: any;
};
@ -31,8 +29,8 @@ type AttrFilter = {
$$updateAt$$: Q_DateValue;
relationId: Q_StringValue;
relation: Relation.Filter;
paths: JsonFilter<Paths>;
destEntity: Q_StringValue;
pathId: Q_StringValue;
path: Path.Filter;
deActions: JsonFilter<Actions>;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
@ -45,8 +43,8 @@ export type Projection = {
$$seq$$?: number;
relationId?: number;
relation?: Relation.Projection;
paths?: number | JsonProjection<Paths>;
destEntity?: number;
pathId?: number;
path?: Path.Projection;
deActions?: number | JsonProjection<Actions>;
} & Partial<ExprOp<OpAttr | string>>;
type ActionAuthIdProjection = OneOf<{
@ -55,6 +53,9 @@ type ActionAuthIdProjection = OneOf<{
type RelationIdProjection = OneOf<{
relationId: number;
}>;
type PathIdProjection = OneOf<{
pathId: number;
}>;
export type SortAttr = {
id: number;
} | {
@ -68,9 +69,9 @@ export type SortAttr = {
} | {
relation: Relation.SortAttr;
} | {
paths: number;
pathId: number;
} | {
destEntity: number;
path: Path.SortAttr;
} | {
deActions: number;
} | {
@ -84,7 +85,7 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId">> & (({
export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId" | "pathId">> & (({
relationId?: never;
relation?: Relation.CreateSingleOperation;
} | {
@ -92,11 +93,19 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId">> &
relation?: Relation.UpdateOperation;
} | {
relationId?: ForeignKey<"relation">;
}) & ({
pathId?: never;
path: Path.CreateSingleOperation;
} | {
pathId: ForeignKey<"path">;
path?: Path.UpdateOperation;
} | {
pathId: ForeignKey<"path">;
}));
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId">> & (({
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId" | "pathId">> & (({
relation: Relation.CreateSingleOperation;
relationId?: never;
} | {
@ -108,16 +117,31 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId">> &
} | {
relation?: never;
relationId?: ForeignKey<"relation"> | null;
}) & ({
path: Path.CreateSingleOperation;
pathId?: never;
} | {
path: Path.UpdateOperation;
pathId?: never;
} | {
path: Path.RemoveOperation;
pathId?: never;
} | {
path?: never;
pathId?: ForeignKey<"path"> | null;
})) & {
[k: string]: any;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
relation?: Relation.UpdateOperation | Relation.RemoveOperation;
}) & ({
path?: Path.UpdateOperation | Path.RemoveOperation;
}));
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type RelationIdSubQuery = Selection<RelationIdProjection>;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type ActionAuthIdSubQuery = Selection<ActionAuthIdProjection>;
export type EntityDef = {
Schema: Schema;

View File

@ -8,16 +8,10 @@ exports.desc = {
type: "ref",
ref: "relation"
},
paths: {
pathId: {
notNull: true,
type: "object"
},
destEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
type: "ref",
ref: "path"
},
deActions: {
notNull: true,
@ -28,15 +22,18 @@ exports.desc = {
actions: action_1.genericActions,
indexes: [
{
name: 'index_entity_relation',
name: 'index_relation_path',
attributes: [
{
name: 'destEntity',
},
{
name: "relationId",
},
{
name: "pathId",
}
],
config: {
unique: true,
},
}
]
};

View File

@ -1 +1 @@
{ "name": "用户授权", "attr": { "relation": "关系", "paths": "路径", "destEntity": "目标对象", "deActions": "目标对象动作" } }
{ "name": "用户授权", "attr": { "relation": "关系", "path": "路径", "deActions": "目标对象动作" } }

View File

@ -4,6 +4,7 @@ import { EntityDef as Modi } from "./Modi/Schema";
import { EntityDef as ModiEntity } from "./ModiEntity/Schema";
import { EntityDef as Oper } from "./Oper/Schema";
import { EntityDef as OperEntity } from "./OperEntity/Schema";
import { EntityDef as Path } from "./Path/Schema";
import { EntityDef as Relation } from "./Relation/Schema";
import { EntityDef as RelationAuth } from "./RelationAuth/Schema";
import { EntityDef as User } from "./User/Schema";
@ -55,6 +56,7 @@ export type EntityDict = {
modiEntity: ModiEntity;
oper: Oper;
operEntity: OperEntity;
path: Path;
relation: Relation;
relationAuth: RelationAuth;
user: User;

125
lib/oak-app-domain/Path/Schema.d.ts vendored Normal file
View File

@ -0,0 +1,125 @@
import { Q_DateValue, Q_BooleanValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { String, Boolean } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import * as ActionAuth from "../ActionAuth/Schema";
import * as RelationAuth from "../RelationAuth/Schema";
export type OpSchema = EntityShape & {
destEntity: String<32>;
value: String<256>;
recursive: Boolean;
sourceEntity: String<32>;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
destEntity: String<32>;
value: String<256>;
recursive: Boolean;
sourceEntity: String<32>;
actionAuth$path?: Array<ActionAuth.Schema>;
actionAuth$path$$aggr?: AggregationResult<ActionAuth.Schema>;
relationAuth$path?: Array<RelationAuth.Schema>;
relationAuth$path$$aggr?: AggregationResult<RelationAuth.Schema>;
} & {
[A in ExpressionKey]?: any;
};
type AttrFilter = {
id: Q_StringValue;
$$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue;
destEntity: Q_StringValue;
value: Q_StringValue;
recursive: Q_BooleanValue;
sourceEntity: Q_StringValue;
actionAuth$path: ActionAuth.Filter & SubQueryPredicateMetadata;
relationAuth$path: RelationAuth.Filter & SubQueryPredicateMetadata;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export type Projection = {
"#id"?: NodeId;
[k: string]: any;
id?: number;
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
destEntity?: number;
value?: number;
recursive?: number;
sourceEntity?: number;
actionAuth$path?: ActionAuth.Selection & {
$entity: "actionAuth";
};
actionAuth$path$$aggr?: ActionAuth.Aggregation & {
$entity: "actionAuth";
};
relationAuth$path?: RelationAuth.Selection & {
$entity: "relationAuth";
};
relationAuth$path$$aggr?: RelationAuth.Aggregation & {
$entity: "relationAuth";
};
} & Partial<ExprOp<OpAttr | string>>;
type PathIdProjection = OneOf<{
id: number;
}>;
export type SortAttr = {
id: number;
} | {
$$createAt$$: number;
} | {
$$seq$$: number;
} | {
$$updateAt$$: number;
} | {
destEntity: number;
} | {
value: number;
} | {
recursive: number;
} | {
sourceEntity: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;
export type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<OpSchema> & {
actionAuth$path?: OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">> | OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">>>;
relationAuth$path?: OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">> | OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">>>;
};
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any;
actionAuth$path?: OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<ActionAuth.RemoveOperation["action"], Omit<ActionAuth.RemoveOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">> | OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<ActionAuth.RemoveOperation["action"], Omit<ActionAuth.RemoveOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">>>;
relationAuth$path?: OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<RelationAuth.RemoveOperation["action"], Omit<RelationAuth.RemoveOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">> | OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<RelationAuth.RemoveOperation["action"], Omit<RelationAuth.RemoveOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">>>;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {};
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<GenericAction> | string;
Selection: Selection;
Aggregation: Aggregation;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};
export {};

View File

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

3
lib/oak-app-domain/Path/Storage.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import { StorageDesc } from "oak-domain/lib/types/Storage";
import { OpSchema } from "./Schema";
export declare const desc: StorageDesc<OpSchema>;

View File

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
const action_1 = require("oak-domain/lib/actions/action");
exports.desc = {
attributes: {
destEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
},
value: {
notNull: true,
type: "varchar",
params: {
length: 256
}
},
recursive: {
notNull: true,
type: "boolean"
},
sourceEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
}
},
actionType: "crud",
actions: action_1.genericActions,
indexes: [
{
name: 'index_source_dest_path',
attributes: [
{
name: 'sourceEntity',
},
{
name: 'value',
},
{
name: 'destEntity',
},
],
config: {
unique: true,
},
}
]
};

View File

@ -0,0 +1 @@
{ "name": "关系路径", "attr": { "sourceEntity": "源对象", "value": "路径从dest到source", "destEntity": "目标对象", "recursive": "是否递归(目标对象)" } }

View File

@ -3,20 +3,21 @@ import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey }
import { OneOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction } from "oak-domain/lib/types/Entity";
import { GenericAction } from "oak-domain/lib/actions/action";
import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import * as Relation from "../Relation/Schema";
import * as Path from "../Path/Schema";
export type OpSchema = EntityShape & {
sourceRelationId: ForeignKey<"relation">;
path: String<256>;
pathId: ForeignKey<"path">;
destRelationId: ForeignKey<"relation">;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
sourceRelationId: ForeignKey<"relation">;
path: String<256>;
pathId: ForeignKey<"path">;
destRelationId: ForeignKey<"relation">;
sourceRelation: Relation.Schema;
path: Path.Schema;
destRelation: Relation.Schema;
} & {
[A in ExpressionKey]?: any;
@ -28,7 +29,8 @@ type AttrFilter = {
$$updateAt$$: Q_DateValue;
sourceRelationId: Q_StringValue;
sourceRelation: Relation.Filter;
path: Q_StringValue;
pathId: Q_StringValue;
path: Path.Filter;
destRelationId: Q_StringValue;
destRelation: Relation.Filter;
};
@ -42,7 +44,8 @@ export type Projection = {
$$seq$$?: number;
sourceRelationId?: number;
sourceRelation?: Relation.Projection;
path?: number;
pathId?: number;
path?: Path.Projection;
destRelationId?: number;
destRelation?: Relation.Projection;
} & Partial<ExprOp<OpAttr | string>>;
@ -53,6 +56,9 @@ type RelationIdProjection = OneOf<{
sourceRelationId: number;
destRelationId: number;
}>;
type PathIdProjection = OneOf<{
pathId: number;
}>;
export type SortAttr = {
id: number;
} | {
@ -66,7 +72,9 @@ export type SortAttr = {
} | {
sourceRelation: Relation.SortAttr;
} | {
path: number;
pathId: number;
} | {
path: Path.SortAttr;
} | {
destRelationId: number;
} | {
@ -82,7 +90,7 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationId" | "destRelationId">> & (({
export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationId" | "pathId" | "destRelationId">> & (({
sourceRelationId?: never;
sourceRelation: Relation.CreateSingleOperation;
} | {
@ -90,6 +98,14 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationI
sourceRelation?: Relation.UpdateOperation;
} | {
sourceRelationId: ForeignKey<"sourceRelation">;
}) & ({
pathId?: never;
path: Path.CreateSingleOperation;
} | {
pathId: ForeignKey<"path">;
path?: Path.UpdateOperation;
} | {
pathId: ForeignKey<"path">;
}) & ({
destRelationId?: never;
destRelation: Relation.CreateSingleOperation;
@ -102,7 +118,7 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationI
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationId" | "destRelationId">> & (({
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationId" | "pathId" | "destRelationId">> & (({
sourceRelation: Relation.CreateSingleOperation;
sourceRelationId?: never;
} | {
@ -114,6 +130,18 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationI
} | {
sourceRelation?: never;
sourceRelationId?: ForeignKey<"sourceRelation"> | null;
}) & ({
path: Path.CreateSingleOperation;
pathId?: never;
} | {
path: Path.UpdateOperation;
pathId?: never;
} | {
path: Path.RemoveOperation;
pathId?: never;
} | {
path?: never;
pathId?: ForeignKey<"path"> | null;
}) & ({
destRelation: Relation.CreateSingleOperation;
destRelationId?: never;
@ -132,12 +160,15 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationI
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
sourceRelation?: Relation.UpdateOperation | Relation.RemoveOperation;
}) & ({
path?: Path.UpdateOperation | Path.RemoveOperation;
}) & ({
destRelation?: Relation.UpdateOperation | Relation.RemoveOperation;
}));
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type RelationIdSubQuery = Selection<RelationIdProjection>;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type RelationAuthIdSubQuery = Selection<RelationAuthIdProjection>;
export type EntityDef = {
Schema: Schema;

View File

@ -9,12 +9,10 @@ exports.desc = {
type: "ref",
ref: "relation"
},
path: {
pathId: {
notNull: true,
type: "varchar",
params: {
length: 256
}
type: "ref",
ref: "path"
},
destRelationId: {
notNull: true,
@ -32,7 +30,7 @@ exports.desc = {
name: "sourceRelationId",
},
{
name: 'path',
name: "pathId",
},
{
name: "destRelationId",

View File

@ -7,50 +7,51 @@ const Storage_3 = require("./Modi/Storage");
const Storage_4 = require("./ModiEntity/Storage");
const Storage_5 = require("./Oper/Storage");
const Storage_6 = require("./OperEntity/Storage");
const Storage_7 = require("./Relation/Storage");
const Storage_8 = require("./RelationAuth/Storage");
const Storage_9 = require("./User/Storage");
const Storage_10 = require("./UserEntityGrant/Storage");
const Storage_11 = require("./UserRelation/Storage");
const Storage_12 = require("./Account/Storage");
const Storage_13 = require("./Address/Storage");
const Storage_14 = require("./Application/Storage");
const Storage_15 = require("./Area/Storage");
const Storage_16 = require("./Article/Storage");
const Storage_17 = require("./ArticleMenu/Storage");
const Storage_18 = require("./Captcha/Storage");
const Storage_19 = require("./ChangePasswordTemp/Storage");
const Storage_20 = require("./Domain/Storage");
const Storage_21 = require("./Email/Storage");
const Storage_22 = require("./ExtraFile/Storage");
const Storage_23 = require("./Livestream/Storage");
const Storage_24 = require("./Message/Storage");
const Storage_25 = require("./MessageSystem/Storage");
const Storage_26 = require("./MessageType/Storage");
const Storage_27 = require("./MessageTypeTemplate/Storage");
const Storage_28 = require("./Mobile/Storage");
const Storage_29 = require("./Notification/Storage");
const Storage_30 = require("./Parasite/Storage");
const Storage_31 = require("./Platform/Storage");
const Storage_32 = require("./ReadRemark/Storage");
const Storage_33 = require("./Session/Storage");
const Storage_34 = require("./SessionMessage/Storage");
const Storage_35 = require("./Station/Storage");
const Storage_36 = require("./Subscription/Storage");
const Storage_37 = require("./Subway/Storage");
const Storage_38 = require("./SubwayStation/Storage");
const Storage_39 = require("./System/Storage");
const Storage_40 = require("./ToDo/Storage");
const Storage_41 = require("./Token/Storage");
const Storage_42 = require("./UserSystem/Storage");
const Storage_43 = require("./UserWechatPublicTag/Storage");
const Storage_44 = require("./WechatLogin/Storage");
const Storage_45 = require("./WechatMenu/Storage");
const Storage_46 = require("./WechatPublicTag/Storage");
const Storage_47 = require("./WechatPublicTemplate/Storage");
const Storage_48 = require("./WechatQrCode/Storage");
const Storage_49 = require("./WechatUser/Storage");
const Storage_50 = require("./wechatPublicAutoReply/Storage");
const Storage_7 = require("./Path/Storage");
const Storage_8 = require("./Relation/Storage");
const Storage_9 = require("./RelationAuth/Storage");
const Storage_10 = require("./User/Storage");
const Storage_11 = require("./UserEntityGrant/Storage");
const Storage_12 = require("./UserRelation/Storage");
const Storage_13 = require("./Account/Storage");
const Storage_14 = require("./Address/Storage");
const Storage_15 = require("./Application/Storage");
const Storage_16 = require("./Area/Storage");
const Storage_17 = require("./Article/Storage");
const Storage_18 = require("./ArticleMenu/Storage");
const Storage_19 = require("./Captcha/Storage");
const Storage_20 = require("./ChangePasswordTemp/Storage");
const Storage_21 = require("./Domain/Storage");
const Storage_22 = require("./Email/Storage");
const Storage_23 = require("./ExtraFile/Storage");
const Storage_24 = require("./Livestream/Storage");
const Storage_25 = require("./Message/Storage");
const Storage_26 = require("./MessageSystem/Storage");
const Storage_27 = require("./MessageType/Storage");
const Storage_28 = require("./MessageTypeTemplate/Storage");
const Storage_29 = require("./Mobile/Storage");
const Storage_30 = require("./Notification/Storage");
const Storage_31 = require("./Parasite/Storage");
const Storage_32 = require("./Platform/Storage");
const Storage_33 = require("./ReadRemark/Storage");
const Storage_34 = require("./Session/Storage");
const Storage_35 = require("./SessionMessage/Storage");
const Storage_36 = require("./Station/Storage");
const Storage_37 = require("./Subscription/Storage");
const Storage_38 = require("./Subway/Storage");
const Storage_39 = require("./SubwayStation/Storage");
const Storage_40 = require("./System/Storage");
const Storage_41 = require("./ToDo/Storage");
const Storage_42 = require("./Token/Storage");
const Storage_43 = require("./UserSystem/Storage");
const Storage_44 = require("./UserWechatPublicTag/Storage");
const Storage_45 = require("./WechatLogin/Storage");
const Storage_46 = require("./WechatMenu/Storage");
const Storage_47 = require("./WechatPublicTag/Storage");
const Storage_48 = require("./WechatPublicTemplate/Storage");
const Storage_49 = require("./WechatQrCode/Storage");
const Storage_50 = require("./WechatUser/Storage");
const Storage_51 = require("./wechatPublicAutoReply/Storage");
exports.storageSchema = {
actionAuth: Storage_1.desc,
i18n: Storage_2.desc,
@ -58,48 +59,49 @@ exports.storageSchema = {
modiEntity: Storage_4.desc,
oper: Storage_5.desc,
operEntity: Storage_6.desc,
relation: Storage_7.desc,
relationAuth: Storage_8.desc,
user: Storage_9.desc,
userEntityGrant: Storage_10.desc,
userRelation: Storage_11.desc,
account: Storage_12.desc,
address: Storage_13.desc,
application: Storage_14.desc,
area: Storage_15.desc,
article: Storage_16.desc,
articleMenu: Storage_17.desc,
captcha: Storage_18.desc,
changePasswordTemp: Storage_19.desc,
domain: Storage_20.desc,
email: Storage_21.desc,
extraFile: Storage_22.desc,
livestream: Storage_23.desc,
message: Storage_24.desc,
messageSystem: Storage_25.desc,
messageType: Storage_26.desc,
messageTypeTemplate: Storage_27.desc,
mobile: Storage_28.desc,
notification: Storage_29.desc,
parasite: Storage_30.desc,
platform: Storage_31.desc,
readRemark: Storage_32.desc,
session: Storage_33.desc,
sessionMessage: Storage_34.desc,
station: Storage_35.desc,
subscription: Storage_36.desc,
subway: Storage_37.desc,
subwayStation: Storage_38.desc,
system: Storage_39.desc,
toDo: Storage_40.desc,
token: Storage_41.desc,
userSystem: Storage_42.desc,
userWechatPublicTag: Storage_43.desc,
wechatLogin: Storage_44.desc,
wechatMenu: Storage_45.desc,
wechatPublicTag: Storage_46.desc,
wechatPublicTemplate: Storage_47.desc,
wechatQrCode: Storage_48.desc,
wechatUser: Storage_49.desc,
wechatPublicAutoReply: Storage_50.desc
path: Storage_7.desc,
relation: Storage_8.desc,
relationAuth: Storage_9.desc,
user: Storage_10.desc,
userEntityGrant: Storage_11.desc,
userRelation: Storage_12.desc,
account: Storage_13.desc,
address: Storage_14.desc,
application: Storage_15.desc,
area: Storage_16.desc,
article: Storage_17.desc,
articleMenu: Storage_18.desc,
captcha: Storage_19.desc,
changePasswordTemp: Storage_20.desc,
domain: Storage_21.desc,
email: Storage_22.desc,
extraFile: Storage_23.desc,
livestream: Storage_24.desc,
message: Storage_25.desc,
messageSystem: Storage_26.desc,
messageType: Storage_27.desc,
messageTypeTemplate: Storage_28.desc,
mobile: Storage_29.desc,
notification: Storage_30.desc,
parasite: Storage_31.desc,
platform: Storage_32.desc,
readRemark: Storage_33.desc,
session: Storage_34.desc,
sessionMessage: Storage_35.desc,
station: Storage_36.desc,
subscription: Storage_37.desc,
subway: Storage_38.desc,
subwayStation: Storage_39.desc,
system: Storage_40.desc,
toDo: Storage_41.desc,
token: Storage_42.desc,
userSystem: Storage_43.desc,
userWechatPublicTag: Storage_44.desc,
wechatLogin: Storage_45.desc,
wechatMenu: Storage_46.desc,
wechatPublicTag: Storage_47.desc,
wechatPublicTemplate: Storage_48.desc,
wechatQrCode: Storage_49.desc,
wechatUser: Storage_50.desc,
wechatPublicAutoReply: Storage_51.desc
};

View File

@ -4,6 +4,7 @@ import * as Modi from "./Modi/Schema";
import * as ModiEntity from "./ModiEntity/Schema";
import * as Oper from "./Oper/Schema";
import * as OperEntity from "./OperEntity/Schema";
import * as Path from "./Path/Schema";
import * as Relation from "./Relation/Schema";
import * as RelationAuth from "./RelationAuth/Schema";
import * as User from "./User/Schema";
@ -82,6 +83,15 @@ export type OperEntityIdSubQuery = {
entity: "operEntity";
}) | any;
};
export type PathIdSubQuery = {
[K in "$in" | "$nin"]?: (ActionAuth.PathIdSubQuery & {
entity: "actionAuth";
}) | (RelationAuth.PathIdSubQuery & {
entity: "relationAuth";
}) | (Path.PathIdSubQuery & {
entity: "path";
}) | any;
};
export type RelationIdSubQuery = {
[K in "$in" | "$nin"]?: (ActionAuth.RelationIdSubQuery & {
entity: "actionAuth";

View File

@ -3,38 +3,32 @@ import { CreateOperationData as ActionAuth } from '../oak-app-domain/ActionAuth/
const actionAuths: ActionAuth[] = [
{
id: 'message-user',
paths: ['user'],
destEntity: 'message',
pathId: 'msg-user',
deActions: ['select', 'remove', 'update'],
},
{
id: 'mobile-user',
paths: ['user'],
destEntity: 'mobile',
pathId: 'mobile-user',
deActions: ['create', 'update', 'remove', 'select'],
},
{
id: 'token-user',
paths: ['user'],
destEntity: 'token',
pathId: 'token-user',
deActions: ['create', 'update', 'remove', 'select'],
},
{
id: 'wechatLogin-user',
paths: ['user'],
destEntity: 'wechatLogin',
pathId: 'wchL-user',
deActions: ['create', 'update', 'select'],
},
{
id: 'wechatUser-user',
paths: ['user'],
destEntity: 'wechatUser',
pathId: 'wchU-user',
deActions: ['create', 'update', 'select'],
},
{
id: 'passwordChangeTemp-user',
paths: ['user'],
destEntity: 'passwordChangeTemp',
pathId: 'pwdCT-user',
deActions: ['create', 'select'],
},
];

View File

@ -4,6 +4,7 @@ import subway from "./subway";
import station from "./station";
import subwayStation from "./subwayStation";
import actionAuth from './actionAuth';
import path from './path';
export default {
user: users,
@ -14,4 +15,5 @@ export default {
station,
subwayStation,
actionAuth,
path,
};

48
src/data/path.ts Normal file
View File

@ -0,0 +1,48 @@
import { CreateOperationData as Path } from '../oak-app-domain/Path/Schema';
const paths: Path[] = [
{
id: 'msg-user',
sourceEntity: 'user',
destEntity: 'message',
value: 'user',
recursive: false,
},
{
id: 'mobile-user',
sourceEntity: 'user',
destEntity: 'mobile',
value: 'user',
recursive: false,
},
{
id: 'token-user',
sourceEntity: 'user',
destEntity: 'token',
value: 'user',
recursive: false,
},
{
id: 'wchL-user',
sourceEntity: 'user',
destEntity: 'wechatLogin',
value: 'user',
recursive: false,
},
{
id: 'wchU-user',
sourceEntity: 'user',
destEntity: 'wechatUser',
value: 'user',
recursive: false,
},
{
id: 'pwdCT-user',
sourceEntity: 'user',
destEntity: 'passwordChangeTemp',
value: 'user',
recursive: false,
},
];
export default paths;

View File

@ -3,25 +3,23 @@ import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue,
import { OneOf, ValueOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult } from "oak-domain/lib/types/Entity";
import { GenericAction, AppendOnlyAction, ReadOnlyAction, ExcludeUpdateAction, ExcludeRemoveAction, RelationAction } from "oak-domain/lib/actions/action";
import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import { EntityDesc } from "oak-domain/lib/types/EntityDesc";
import * as Relation from "../Relation/Schema";
import * as Path from "../Path/Schema";
type Actions = string[];
type Paths = string[];
export type OpSchema = EntityShape & {
relationId?: ForeignKey<"relation"> | null;
paths: Paths;
destEntity: String<32>;
pathId: ForeignKey<"path">;
deActions: Actions;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
relationId?: ForeignKey<"relation"> | null;
paths: Paths;
destEntity: String<32>;
pathId: ForeignKey<"path">;
deActions: Actions;
relation?: Relation.Schema | null;
path: Path.Schema;
} & {
[A in ExpressionKey]?: any;
};
@ -32,8 +30,8 @@ type AttrFilter = {
$$updateAt$$: Q_DateValue;
relationId: Q_StringValue;
relation: Relation.Filter;
paths: JsonFilter<Paths>;
destEntity: Q_StringValue;
pathId: Q_StringValue;
path: Path.Filter;
deActions: JsonFilter<Actions>;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
@ -46,8 +44,8 @@ export type Projection = {
$$seq$$?: number;
relationId?: number;
relation?: Relation.Projection;
paths?: number | JsonProjection<Paths>;
destEntity?: number;
pathId?: number;
path?: Path.Projection;
deActions?: number | JsonProjection<Actions>;
} & Partial<ExprOp<OpAttr | string>>;
type ActionAuthIdProjection = OneOf<{
@ -56,6 +54,9 @@ type ActionAuthIdProjection = OneOf<{
type RelationIdProjection = OneOf<{
relationId: number;
}>;
type PathIdProjection = OneOf<{
pathId: number;
}>;
export type SortAttr = {
id: number;
} | {
@ -69,9 +70,9 @@ export type SortAttr = {
} | {
relation: Relation.SortAttr;
} | {
paths: number;
pathId: number;
} | {
destEntity: number;
path: Path.SortAttr;
} | {
deActions: number;
} | {
@ -85,7 +86,7 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId">> & (({
export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId" | "pathId">> & (({
relationId?: never;
relation?: Relation.CreateSingleOperation;
} | {
@ -93,11 +94,19 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "relationId">> &
relation?: Relation.UpdateOperation;
} | {
relationId?: ForeignKey<"relation">;
}) & ({
pathId?: never;
path: Path.CreateSingleOperation;
} | {
pathId: ForeignKey<"path">;
path?: Path.UpdateOperation;
} | {
pathId: ForeignKey<"path">;
}));
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId">> & (({
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId" | "pathId">> & (({
relation: Relation.CreateSingleOperation;
relationId?: never;
} | {
@ -109,16 +118,31 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "relationId">> &
} | {
relation?: never;
relationId?: ForeignKey<"relation"> | null;
}) & ({
path: Path.CreateSingleOperation;
pathId?: never;
} | {
path: Path.UpdateOperation;
pathId?: never;
} | {
path: Path.RemoveOperation;
pathId?: never;
} | {
path?: never;
pathId?: ForeignKey<"path"> | null;
})) & {
[k: string]: any;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
relation?: Relation.UpdateOperation | Relation.RemoveOperation;
}) & ({
path?: Path.UpdateOperation | Path.RemoveOperation;
}));
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type RelationIdSubQuery = Selection<RelationIdProjection>;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type ActionAuthIdSubQuery = Selection<ActionAuthIdProjection>;
export type EntityDef = {
Schema: Schema;

View File

@ -7,16 +7,10 @@ export const desc: StorageDesc<OpSchema> = {
type: "ref",
ref: "relation"
},
paths: {
pathId: {
notNull: true,
type: "object"
},
destEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
type: "ref",
ref: "path"
},
deActions: {
notNull: true,
@ -27,15 +21,18 @@ export const desc: StorageDesc<OpSchema> = {
actions,
indexes: [
{
name: 'index_entity_relation',
name: 'index_relation_path',
attributes: [
{
name: 'destEntity',
},
{
name: "relationId",
},
{
name: "pathId",
}
],
config: {
unique: true,
},
}
]
};

View File

@ -1 +1 @@
{"name":"用户授权","attr":{"relation":"关系","paths":"路径","destEntity":"目标对象","deActions":"目标对象动作"}}
{"name":"用户授权","attr":{"relation":"关系","path":"路径","deActions":"目标对象动作"}}

View File

@ -4,6 +4,7 @@ import { EntityDef as Modi } from "./Modi/Schema";
import { EntityDef as ModiEntity } from "./ModiEntity/Schema";
import { EntityDef as Oper } from "./Oper/Schema";
import { EntityDef as OperEntity } from "./OperEntity/Schema";
import { EntityDef as Path } from "./Path/Schema";
import { EntityDef as Relation } from "./Relation/Schema";
import { EntityDef as RelationAuth } from "./RelationAuth/Schema";
import { EntityDef as User } from "./User/Schema";
@ -55,6 +56,7 @@ export type EntityDict = {
modiEntity: ModiEntity;
oper: Oper;
operEntity: OperEntity;
path: Path;
relation: Relation;
relationAuth: RelationAuth;
user: User;

View File

@ -0,0 +1,126 @@
import { PrimaryKey, ForeignKey, JsonProjection } from "oak-domain/lib/types/DataType";
import { Q_DateValue, Q_BooleanValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, FulltextFilter, ExprOp, ExpressionKey, JsonFilter, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
import { OneOf, ValueOf } from "oak-domain/lib/types/Polyfill";
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult } from "oak-domain/lib/types/Entity";
import { GenericAction, AppendOnlyAction, ReadOnlyAction, ExcludeUpdateAction, ExcludeRemoveAction, RelationAction } from "oak-domain/lib/actions/action";
import { String, Boolean, Text } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import { EntityDesc } from "oak-domain/lib/types/EntityDesc";
import * as ActionAuth from "../ActionAuth/Schema";
import * as RelationAuth from "../RelationAuth/Schema";
export type OpSchema = EntityShape & {
destEntity: String<32>;
value: String<256>;
recursive: Boolean;
sourceEntity: String<32>;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
destEntity: String<32>;
value: String<256>;
recursive: Boolean;
sourceEntity: String<32>;
actionAuth$path?: Array<ActionAuth.Schema>;
actionAuth$path$$aggr?: AggregationResult<ActionAuth.Schema>;
relationAuth$path?: Array<RelationAuth.Schema>;
relationAuth$path$$aggr?: AggregationResult<RelationAuth.Schema>;
} & {
[A in ExpressionKey]?: any;
};
type AttrFilter = {
id: Q_StringValue;
$$createAt$$: Q_DateValue;
$$seq$$: Q_StringValue;
$$updateAt$$: Q_DateValue;
destEntity: Q_StringValue;
value: Q_StringValue;
recursive: Q_BooleanValue;
sourceEntity: Q_StringValue;
actionAuth$path: ActionAuth.Filter & SubQueryPredicateMetadata;
relationAuth$path: RelationAuth.Filter & SubQueryPredicateMetadata;
};
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export type Projection = {
"#id"?: NodeId;
[k: string]: any;
id?: number;
$$createAt$$?: number;
$$updateAt$$?: number;
$$seq$$?: number;
destEntity?: number;
value?: number;
recursive?: number;
sourceEntity?: number;
actionAuth$path?: ActionAuth.Selection & {
$entity: "actionAuth";
};
actionAuth$path$$aggr?: ActionAuth.Aggregation & {
$entity: "actionAuth";
};
relationAuth$path?: RelationAuth.Selection & {
$entity: "relationAuth";
};
relationAuth$path$$aggr?: RelationAuth.Aggregation & {
$entity: "relationAuth";
};
} & Partial<ExprOp<OpAttr | string>>;
type PathIdProjection = OneOf<{
id: number;
}>;
export type SortAttr = {
id: number;
} | {
$$createAt$$: number;
} | {
$$seq$$: number;
} | {
$$updateAt$$: number;
} | {
destEntity: number;
} | {
value: number;
} | {
recursive: number;
} | {
sourceEntity: number;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;
export type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<OpSchema> & {
actionAuth$path?: OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">> | OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">>>;
relationAuth$path?: OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">> | OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">>>;
};
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any;
actionAuth$path?: OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<ActionAuth.RemoveOperation["action"], Omit<ActionAuth.RemoveOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<ActionAuth.CreateOperationData, "path" | "pathId">> | OakOperation<ActionAuth.UpdateOperation["action"], Omit<ActionAuth.UpdateOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">> | OakOperation<ActionAuth.RemoveOperation["action"], Omit<ActionAuth.RemoveOperationData, "path" | "pathId">, Omit<ActionAuth.Filter, "path" | "pathId">>>;
relationAuth$path?: OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<RelationAuth.RemoveOperation["action"], Omit<RelationAuth.RemoveOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">[]> | Array<OakOperation<"create", Omit<RelationAuth.CreateOperationData, "path" | "pathId">> | OakOperation<RelationAuth.UpdateOperation["action"], Omit<RelationAuth.UpdateOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">> | OakOperation<RelationAuth.RemoveOperation["action"], Omit<RelationAuth.RemoveOperationData, "path" | "pathId">, Omit<RelationAuth.Filter, "path" | "pathId">>>;
};
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {};
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<GenericAction> | string;
Selection: Selection;
Aggregation: Aggregation;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};

View File

@ -0,0 +1,53 @@
import { StorageDesc } from "oak-domain/lib/types/Storage";
import { OpSchema } from "./Schema";
import { genericActions as actions } from "oak-domain/lib/actions/action";
export const desc: StorageDesc<OpSchema> = {
attributes: {
destEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
},
value: {
notNull: true,
type: "varchar",
params: {
length: 256
}
},
recursive: {
notNull: true,
type: "boolean"
},
sourceEntity: {
notNull: true,
type: "varchar",
params: {
length: 32
}
}
},
actionType: "crud",
actions,
indexes: [
{
name: 'index_source_dest_path',
attributes: [
{
name: 'sourceEntity',
},
{
name: 'value',
},
{
name: 'destEntity',
},
],
config: {
unique: true,
},
}
]
};

View File

@ -0,0 +1 @@
{"name":"关系路径","attr":{"sourceEntity":"源对象","value":"路径从dest到source","destEntity":"目标对象","recursive":"是否递归(目标对象)"}}

View File

@ -7,17 +7,19 @@ import { String } from "oak-domain/lib/types/DataType";
import { EntityShape } from "oak-domain/lib/types/Entity";
import { EntityDesc } from "oak-domain/lib/types/EntityDesc";
import * as Relation from "../Relation/Schema";
import * as Path from "../Path/Schema";
export type OpSchema = EntityShape & {
sourceRelationId: ForeignKey<"relation">;
path: String<256>;
pathId: ForeignKey<"path">;
destRelationId: ForeignKey<"relation">;
};
export type OpAttr = keyof OpSchema;
export type Schema = EntityShape & {
sourceRelationId: ForeignKey<"relation">;
path: String<256>;
pathId: ForeignKey<"path">;
destRelationId: ForeignKey<"relation">;
sourceRelation: Relation.Schema;
path: Path.Schema;
destRelation: Relation.Schema;
} & {
[A in ExpressionKey]?: any;
@ -29,7 +31,8 @@ type AttrFilter = {
$$updateAt$$: Q_DateValue;
sourceRelationId: Q_StringValue;
sourceRelation: Relation.Filter;
path: Q_StringValue;
pathId: Q_StringValue;
path: Path.Filter;
destRelationId: Q_StringValue;
destRelation: Relation.Filter;
};
@ -43,7 +46,8 @@ export type Projection = {
$$seq$$?: number;
sourceRelationId?: number;
sourceRelation?: Relation.Projection;
path?: number;
pathId?: number;
path?: Path.Projection;
destRelationId?: number;
destRelation?: Relation.Projection;
} & Partial<ExprOp<OpAttr | string>>;
@ -54,6 +58,9 @@ type RelationIdProjection = OneOf<{
sourceRelationId: number;
destRelationId: number;
}>;
type PathIdProjection = OneOf<{
pathId: number;
}>;
export type SortAttr = {
id: number;
} | {
@ -67,7 +74,9 @@ export type SortAttr = {
} | {
sourceRelation: Relation.SortAttr;
} | {
path: number;
pathId: number;
} | {
path: Path.SortAttr;
} | {
destRelationId: number;
} | {
@ -83,7 +92,7 @@ export type Sorter = SortNode[];
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
export type Selection<P extends Object = Projection> = SelectOperation<P>;
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationId" | "destRelationId">> & (({
export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationId" | "pathId" | "destRelationId">> & (({
sourceRelationId?: never;
sourceRelation: Relation.CreateSingleOperation;
} | {
@ -91,6 +100,14 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationI
sourceRelation?: Relation.UpdateOperation;
} | {
sourceRelationId: ForeignKey<"sourceRelation">;
}) & ({
pathId?: never;
path: Path.CreateSingleOperation;
} | {
pathId: ForeignKey<"path">;
path?: Path.UpdateOperation;
} | {
pathId: ForeignKey<"path">;
}) & ({
destRelationId?: never;
destRelation: Relation.CreateSingleOperation;
@ -103,7 +120,7 @@ export type CreateOperationData = FormCreateData<Omit<OpSchema, "sourceRelationI
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationId" | "destRelationId">> & (({
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationId" | "pathId" | "destRelationId">> & (({
sourceRelation: Relation.CreateSingleOperation;
sourceRelationId?: never;
} | {
@ -115,6 +132,18 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationI
} | {
sourceRelation?: never;
sourceRelationId?: ForeignKey<"sourceRelation"> | null;
}) & ({
path: Path.CreateSingleOperation;
pathId?: never;
} | {
path: Path.UpdateOperation;
pathId?: never;
} | {
path: Path.RemoveOperation;
pathId?: never;
} | {
path?: never;
pathId?: ForeignKey<"path"> | null;
}) & ({
destRelation: Relation.CreateSingleOperation;
destRelationId?: never;
@ -133,12 +162,15 @@ export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "sourceRelationI
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export type RemoveOperationData = {} & (({
sourceRelation?: Relation.UpdateOperation | Relation.RemoveOperation;
}) & ({
path?: Path.UpdateOperation | Path.RemoveOperation;
}) & ({
destRelation?: Relation.UpdateOperation | Relation.RemoveOperation;
}));
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
export type RelationIdSubQuery = Selection<RelationIdProjection>;
export type PathIdSubQuery = Selection<PathIdProjection>;
export type RelationAuthIdSubQuery = Selection<RelationAuthIdProjection>;
export type EntityDef = {
Schema: Schema;

View File

@ -8,12 +8,10 @@ export const desc: StorageDesc<OpSchema> = {
type: "ref",
ref: "relation"
},
path: {
pathId: {
notNull: true,
type: "varchar",
params: {
length: 256
}
type: "ref",
ref: "path"
},
destRelationId: {
notNull: true,
@ -31,7 +29,7 @@ export const desc: StorageDesc<OpSchema> = {
name: "sourceRelationId",
},
{
name: 'path',
name: "pathId",
},
{
name: "destRelationId",

View File

@ -6,6 +6,7 @@ import { desc as modiDesc } from "./Modi/Storage";
import { desc as modiEntityDesc } from "./ModiEntity/Storage";
import { desc as operDesc } from "./Oper/Storage";
import { desc as operEntityDesc } from "./OperEntity/Storage";
import { desc as pathDesc } from "./Path/Storage";
import { desc as relationDesc } from "./Relation/Storage";
import { desc as relationAuthDesc } from "./RelationAuth/Storage";
import { desc as userDesc } from "./User/Storage";
@ -57,6 +58,7 @@ export const storageSchema: StorageSchema<EntityDict> = {
modiEntity: modiEntityDesc,
oper: operDesc,
operEntity: operEntityDesc,
path: pathDesc,
relation: relationDesc,
relationAuth: relationAuthDesc,
user: userDesc,

View File

@ -4,6 +4,7 @@ import * as Modi from "./Modi/Schema";
import * as ModiEntity from "./ModiEntity/Schema";
import * as Oper from "./Oper/Schema";
import * as OperEntity from "./OperEntity/Schema";
import * as Path from "./Path/Schema";
import * as Relation from "./Relation/Schema";
import * as RelationAuth from "./RelationAuth/Schema";
import * as User from "./User/Schema";
@ -82,6 +83,15 @@ export type OperEntityIdSubQuery = {
entity: "operEntity";
}) | any;
};
export type PathIdSubQuery = {
[K in "$in" | "$nin"]?: (ActionAuth.PathIdSubQuery & {
entity: "actionAuth";
}) | (RelationAuth.PathIdSubQuery & {
entity: "relationAuth";
}) | (Path.PathIdSubQuery & {
entity: "path";
}) | any;
};
export type RelationIdSubQuery = {
[K in "$in" | "$nin"]?: (ActionAuth.RelationIdSubQuery & {
entity: "actionAuth";