修正了importation和exportation的定义
This commit is contained in:
parent
83bb033359
commit
98bd993d02
|
|
@ -2,7 +2,7 @@ import { String } from "../../types/DataType";
|
|||
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||
import { OneOf } from "../../types/Polyfill";
|
||||
import * as SubQuery from "../_SubQuery";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
|
||||
import { Action, ParticularAction, IState } from "./Action";
|
||||
import * as ModiEntity from "../ModiEntity/Schema";
|
||||
import * as OperEntity from "../OperEntity/Schema";
|
||||
|
|
@ -27,7 +27,9 @@ export declare type Schema = EntityShape & {
|
|||
extra?: Object | null;
|
||||
iState?: IState | null;
|
||||
modiEntity$modi?: Array<ModiEntity.Schema>;
|
||||
modiEntity$modi$$aggr?: AggregationResult<ModiEntity.Schema>;
|
||||
operEntity$entity?: Array<OperEntity.Schema>;
|
||||
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -64,29 +66,13 @@ export declare type Projection = {
|
|||
modiEntity$modi?: ModiEntity.Selection & {
|
||||
$entity: "modiEntity";
|
||||
};
|
||||
modiEntity$modi$$aggr?: ModiEntity.Aggregation & {
|
||||
$entity: "modiEntity";
|
||||
};
|
||||
operEntity$entity?: OperEntity.Selection & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
export declare type ExportProjection = {
|
||||
"#id"?: NodeId;
|
||||
[k: string]: any;
|
||||
id?: string;
|
||||
$$createAt$$?: string;
|
||||
$$updateAt$$?: string;
|
||||
$$seq$$?: string;
|
||||
targetEntity?: string;
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
action?: string;
|
||||
data?: string;
|
||||
filter?: string;
|
||||
extra?: string;
|
||||
iState?: string;
|
||||
modiEntity$modi?: ModiEntity.Exportation & {
|
||||
$entity: "modiEntity";
|
||||
};
|
||||
operEntity$entity?: OperEntity.Exportation & {
|
||||
operEntity$entity$$aggr?: OperEntity.Aggregation & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
|
|
@ -122,7 +108,6 @@ export declare type Sorter = SortNode[];
|
|||
export declare type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
||||
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
||||
export declare type Aggregation = Omit<DeduceAggregation<Schema, Projection, Filter, Sorter>, "id">;
|
||||
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
|
||||
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId">> & ({
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
|
|
|
|||
|
|
@ -46,19 +46,6 @@ export declare type Projection = {
|
|||
entityId?: number;
|
||||
user?: User.Projection;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
export declare type ExportProjection = {
|
||||
"#id"?: NodeId;
|
||||
[k: string]: any;
|
||||
id?: string;
|
||||
$$createAt$$?: string;
|
||||
$$updateAt$$?: string;
|
||||
$$seq$$?: string;
|
||||
modiId?: string;
|
||||
modi?: Modi.ExportProjection;
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
user?: User.ExportProjection;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
declare type ModiEntityIdProjection = OneOf<{
|
||||
id: number;
|
||||
}>;
|
||||
|
|
@ -97,7 +84,6 @@ export declare type Sorter = SortNode[];
|
|||
export declare type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
||||
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
||||
export declare type Aggregation = Omit<DeduceAggregation<Schema, Projection, Filter, Sorter>, "id">;
|
||||
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
|
||||
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "modiId">> & (({
|
||||
modiId?: never;
|
||||
modi: Modi.CreateSingleOperation;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { String, ForeignKey } from "../../types/DataType";
|
|||
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||
import { OneOf } from "../../types/Polyfill";
|
||||
import * as SubQuery from "../_SubQuery";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
|
||||
import { AppendOnlyAction } from "../../actions/action";
|
||||
import * as User from "../User/Schema";
|
||||
import * as OperEntity from "../OperEntity/Schema";
|
||||
|
|
@ -22,6 +22,7 @@ export declare type Schema = EntityShape & {
|
|||
operatorId?: ForeignKey<"user"> | null;
|
||||
operator?: User.Schema | null;
|
||||
operEntity$oper?: Array<OperEntity.Schema>;
|
||||
operEntity$oper$$aggr?: AggregationResult<OperEntity.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -54,21 +55,7 @@ export declare type Projection = {
|
|||
operEntity$oper?: OperEntity.Selection & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
export declare type ExportProjection = {
|
||||
"#id"?: NodeId;
|
||||
[k: string]: any;
|
||||
id?: string;
|
||||
$$createAt$$?: string;
|
||||
$$updateAt$$?: string;
|
||||
$$seq$$?: string;
|
||||
action?: string;
|
||||
data?: string;
|
||||
filter?: string;
|
||||
extra?: string;
|
||||
operatorId?: string;
|
||||
operator?: User.ExportProjection;
|
||||
operEntity$oper?: OperEntity.Exportation & {
|
||||
operEntity$oper$$aggr?: OperEntity.Aggregation & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
|
|
@ -103,7 +90,6 @@ export declare type Sorter = SortNode[];
|
|||
export declare type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
||||
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
||||
export declare type Aggregation = Omit<DeduceAggregation<Schema, Projection, Filter, Sorter>, "id">;
|
||||
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
|
||||
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "operatorId">> & (({
|
||||
operatorId?: never;
|
||||
operator?: User.CreateSingleOperation;
|
||||
|
|
|
|||
|
|
@ -50,20 +50,6 @@ export declare type Projection = {
|
|||
modi?: Modi.Projection;
|
||||
user?: User.Projection;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
export declare type ExportProjection = {
|
||||
"#id"?: NodeId;
|
||||
[k: string]: any;
|
||||
id?: string;
|
||||
$$createAt$$?: string;
|
||||
$$updateAt$$?: string;
|
||||
$$seq$$?: string;
|
||||
operId?: string;
|
||||
oper?: Oper.ExportProjection;
|
||||
entity?: string;
|
||||
entityId?: string;
|
||||
modi?: Modi.ExportProjection;
|
||||
user?: User.ExportProjection;
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
declare type OperEntityIdProjection = OneOf<{
|
||||
id: number;
|
||||
}>;
|
||||
|
|
@ -107,7 +93,6 @@ export declare type Sorter = SortNode[];
|
|||
export declare type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
||||
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
||||
export declare type Aggregation = Omit<DeduceAggregation<Schema, Projection, Filter, Sorter>, "id">;
|
||||
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
|
||||
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entity" | "entityId" | "operId">> & (({
|
||||
operId?: never;
|
||||
oper: Oper.CreateSingleOperation;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { String, Text } from "../../types/DataType";
|
|||
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||
import { OneOf } from "../../types/Polyfill";
|
||||
import * as SubQuery from "../_SubQuery";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape, AggregationResult } from "../../types/Entity";
|
||||
import { GenericAction, RelationAction } from "../../actions/action";
|
||||
import * as Oper from "../Oper/Schema";
|
||||
import * as OperEntity from "../OperEntity/Schema";
|
||||
|
|
@ -18,8 +18,11 @@ export declare type Schema = EntityShape & {
|
|||
nickname?: String<64> | null;
|
||||
password?: Text | null;
|
||||
oper$operator?: Array<Oper.Schema>;
|
||||
oper$operator$$aggr?: AggregationResult<Oper.Schema>;
|
||||
operEntity$entity?: Array<OperEntity.Schema>;
|
||||
operEntity$entity$$aggr?: AggregationResult<OperEntity.Schema>;
|
||||
modiEntity$entity?: Array<ModiEntity.Schema>;
|
||||
modiEntity$entity$$aggr?: AggregationResult<ModiEntity.Schema>;
|
||||
} & {
|
||||
[A in ExpressionKey]?: any;
|
||||
};
|
||||
|
|
@ -46,30 +49,19 @@ export declare type Projection = {
|
|||
oper$operator?: Oper.Selection & {
|
||||
$entity: "oper";
|
||||
};
|
||||
oper$operator$$aggr?: Oper.Aggregation & {
|
||||
$entity: "oper";
|
||||
};
|
||||
operEntity$entity?: OperEntity.Selection & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
operEntity$entity$$aggr?: OperEntity.Aggregation & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
modiEntity$entity?: ModiEntity.Selection & {
|
||||
$entity: "modiEntity";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
export declare type ExportProjection = {
|
||||
"#id"?: NodeId;
|
||||
[k: string]: any;
|
||||
id?: string;
|
||||
$$createAt$$?: string;
|
||||
$$updateAt$$?: string;
|
||||
$$seq$$?: string;
|
||||
name?: string;
|
||||
nickname?: string;
|
||||
password?: string;
|
||||
oper$operator?: Oper.Exportation & {
|
||||
$entity: "oper";
|
||||
};
|
||||
operEntity$entity?: OperEntity.Exportation & {
|
||||
$entity: "operEntity";
|
||||
};
|
||||
modiEntity$entity?: ModiEntity.Exportation & {
|
||||
modiEntity$entity$$aggr?: ModiEntity.Aggregation & {
|
||||
$entity: "modiEntity";
|
||||
};
|
||||
} & Partial<ExprOp<OpAttr | string>>;
|
||||
|
|
@ -101,7 +93,6 @@ export declare type Sorter = SortNode[];
|
|||
export declare type SelectOperation<P extends Object = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
|
||||
export declare type Selection<P extends Object = Projection> = Omit<SelectOperation<P>, "action">;
|
||||
export declare type Aggregation = Omit<DeduceAggregation<Schema, Projection, Filter, Sorter>, "id">;
|
||||
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
|
||||
export declare type CreateOperationData = FormCreateData<OpSchema> & {
|
||||
oper$operator?: OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId">>>;
|
||||
operEntity$entity?: OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId">>>;
|
||||
|
|
|
|||
|
|
@ -966,6 +966,8 @@ function constructSchema(statements, entity) {
|
|||
foreignKeySet[entityName].forEach(function (foreignKey) {
|
||||
var identifier = "".concat(entityNameLc, "$").concat(foreignKey);
|
||||
members2.push(factory.createPropertySignature(undefined, identifier, factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(factory.createIdentifier("Array"), [factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'Schema'), undefined)])));
|
||||
var aggrIdentifier = "".concat(entityNameLc, "$").concat(foreignKey, "$$aggr");
|
||||
members2.push(factory.createPropertySignature(undefined, aggrIdentifier, factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(factory.createIdentifier("AggregationResult"), [factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'Schema'), undefined)])));
|
||||
});
|
||||
};
|
||||
for (var entityName in foreignKeySet) {
|
||||
|
|
@ -1206,7 +1208,10 @@ function constructProjection(statements, entity) {
|
|||
});
|
||||
if (manyToOneItem) {
|
||||
// 外键投影
|
||||
properties.push(["".concat(attrName, "Id"), false, undefined], [name_4, false, factory.createTypeReferenceNode(createForeignRef(entity, text2_4, 'Projection')), factory.createTypeReferenceNode(createForeignRef(entity, text2_4, 'ExportProjection'))]);
|
||||
properties.push(["".concat(attrName, "Id"), false, undefined], [name_4, false, factory.createTypeReferenceNode(createForeignRef(entity, text2_4, 'Projection')) /* , factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, text2, 'ExportProjection')
|
||||
) */
|
||||
]);
|
||||
if (foreignKeyProperties.hasOwnProperty(text2_4)) {
|
||||
foreignKeyProperties[text2_4].push(attrName);
|
||||
}
|
||||
|
|
@ -1256,7 +1261,10 @@ function constructProjection(statements, entity) {
|
|||
ReversePointerRelations[entity].forEach(function (one) {
|
||||
var _a;
|
||||
var text2 = one === 'Schema' ? entity : one;
|
||||
properties.push([(0, string_1.firstLetterLowerCase)(one), false, factory.createTypeReferenceNode(createForeignRef(entity, one, 'Projection')), factory.createTypeReferenceNode(createForeignRef(entity, one, 'ExportProjection'))]);
|
||||
properties.push([(0, string_1.firstLetterLowerCase)(one), false, factory.createTypeReferenceNode(createForeignRef(entity, one, 'Projection')) /* , factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, one, 'ExportProjection')
|
||||
) */
|
||||
]);
|
||||
if (foreignKeyProperties.hasOwnProperty(one)) {
|
||||
foreignKeyProperties[text2].push('entity');
|
||||
}
|
||||
|
|
@ -1294,15 +1302,31 @@ function constructProjection(statements, entity) {
|
|||
var entityNameLc = (0, string_1.firstLetterLowerCase)(entityName);
|
||||
foreignKeySet[entityName].forEach(function (foreignKey) {
|
||||
var identifier = "".concat(entityNameLc, "$").concat(foreignKey);
|
||||
var aggrIdentifier = "".concat(entityNameLc, "$").concat(foreignKey, "$$aggr");
|
||||
properties.push([identifier, false,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'Selection'), undefined),
|
||||
factory.createTypeLiteralNode([
|
||||
factory.createPropertySignature(undefined, factory.createIdentifier("$entity"), undefined, factory.createLiteralTypeNode(factory.createStringLiteral((0, string_1.firstLetterLowerCase)(entityName))))
|
||||
])
|
||||
]),
|
||||
]) /* ,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'Exportation'), undefined),
|
||||
factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, entityName, 'Exportation'),
|
||||
undefined
|
||||
),
|
||||
factory.createTypeLiteralNode([
|
||||
factory.createPropertySignature(
|
||||
undefined,
|
||||
factory.createIdentifier("$entity"),
|
||||
undefined,
|
||||
factory.createLiteralTypeNode(factory.createStringLiteral(firstLetterLowerCase(entityName)))
|
||||
)
|
||||
])
|
||||
]) */
|
||||
], [aggrIdentifier, false,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'Aggregation'), undefined),
|
||||
factory.createTypeLiteralNode([
|
||||
factory.createPropertySignature(undefined, factory.createIdentifier("$entity"), undefined, factory.createLiteralTypeNode(factory.createStringLiteral((0, string_1.firstLetterLowerCase)(entityName))))
|
||||
])
|
||||
|
|
@ -1324,28 +1348,47 @@ function constructProjection(statements, entity) {
|
|||
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr'))
|
||||
])
|
||||
]);
|
||||
var MetaPropertySignaturs = [
|
||||
var MetaPropertySignatures = [
|
||||
factory.createPropertySignature(undefined, factory.createStringLiteral("#id"), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode('NodeId'))
|
||||
];
|
||||
if (process.env.COMPLING_AS_LIB) {
|
||||
MetaPropertySignaturs.push(factory.createIndexSignature(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier("k"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), undefined)], factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)));
|
||||
MetaPropertySignatures.push(factory.createIndexSignature(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier("k"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), undefined)], factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)));
|
||||
}
|
||||
// Projection,正常查询的投影
|
||||
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Projection"), undefined, factory.createIntersectionTypeNode([
|
||||
factory.createTypeLiteralNode(MetaPropertySignaturs.concat(properties.map(function (_a) {
|
||||
factory.createTypeLiteralNode(MetaPropertySignatures.concat(properties.map(function (_a) {
|
||||
var _b = tslib_1.__read(_a, 3), n = _b[0], q = _b[1], v = _b[2];
|
||||
return factory.createPropertySignature(undefined, n, q ? undefined : factory.createToken(ts.SyntaxKind.QuestionToken), v || factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword));
|
||||
}))),
|
||||
exprNode,
|
||||
])));
|
||||
// ExportProjection,下载查询的投影
|
||||
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("ExportProjection"), undefined, factory.createIntersectionTypeNode([
|
||||
factory.createTypeLiteralNode(MetaPropertySignaturs.concat(properties.map(function (_a) {
|
||||
var _b = tslib_1.__read(_a, 4), n = _b[0], q = _b[1], v = _b[2], v2 = _b[3];
|
||||
return factory.createPropertySignature(undefined, n, factory.createToken(ts.SyntaxKind.QuestionToken), v2 || factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
|
||||
}))),
|
||||
// 已经废弃。By Xc 2023.01.08
|
||||
/* statements.push(
|
||||
factory.createTypeAliasDeclaration(
|
||||
undefined,
|
||||
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
||||
factory.createIdentifier("ExportProjection"),
|
||||
undefined,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeLiteralNode(
|
||||
MetaPropertySignaturs.concat(
|
||||
properties.map(
|
||||
([n, q, v, v2]) => {
|
||||
return factory.createPropertySignature(
|
||||
undefined,
|
||||
n,
|
||||
factory.createToken(ts.SyntaxKind.QuestionToken),
|
||||
v2 || factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
|
||||
)
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
exprNode,
|
||||
])));
|
||||
])
|
||||
)
|
||||
); */
|
||||
// ${Entity}Projection,外键查询的专用投影
|
||||
for (var foreignKey in foreignKeyProperties) {
|
||||
var identifier = "".concat(foreignKey, "IdProjection");
|
||||
|
|
@ -1731,12 +1774,33 @@ function constructActions(statements, entity) {
|
|||
factory.createLiteralTypeNode(factory.createStringLiteral("id"))
|
||||
])));
|
||||
// Exportation
|
||||
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("Exportation"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("OakOperation"), [
|
||||
// 已经废弃,by Xc 2023.01.08
|
||||
/* statements.push(
|
||||
factory.createTypeAliasDeclaration(
|
||||
undefined,
|
||||
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
||||
factory.createIdentifier("Exportation"),
|
||||
undefined,
|
||||
factory.createTypeReferenceNode(
|
||||
factory.createIdentifier("OakOperation"),
|
||||
[
|
||||
factory.createLiteralTypeNode(factory.createStringLiteral("export")),
|
||||
factory.createTypeReferenceNode(factory.createIdentifier("ExportProjection"), undefined),
|
||||
factory.createTypeReferenceNode(factory.createIdentifier("Filter"), undefined),
|
||||
factory.createTypeReferenceNode(factory.createIdentifier("Sorter"), undefined)
|
||||
])));
|
||||
factory.createTypeReferenceNode(
|
||||
factory.createIdentifier("ExportProjection"),
|
||||
undefined
|
||||
),
|
||||
factory.createTypeReferenceNode(
|
||||
factory.createIdentifier("Filter"),
|
||||
undefined
|
||||
),
|
||||
factory.createTypeReferenceNode(
|
||||
factory.createIdentifier("Sorter"),
|
||||
undefined
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
); */
|
||||
var _k = ManyToOne, _l = entity, manyToOneSet = _k[_l];
|
||||
var _m = OneToMany, _o = entity, oneToManySet = _m[_o];
|
||||
var foreignKeySet = {};
|
||||
|
|
@ -2555,6 +2619,7 @@ var initialStatements = function () { return [
|
|||
factory.createImportSpecifier(false, factory.createIdentifier("Operation"), factory.createIdentifier("OakOperation")),
|
||||
factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction")),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityShape")),
|
||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier("AggregationResult")),
|
||||
])), factory.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Entity")), undefined)
|
||||
]; };
|
||||
function outputSubQuery(outputDir, printer) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { EntityDict, OperateOption, SelectOption, OperationResult, DeduceFilter } from "../types/Entity";
|
||||
import { EntityDict, OperateOption, SelectOption, OperationResult, DeduceFilter, AggregationResult } from "../types/Entity";
|
||||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { RowStore } from '../types/RowStore';
|
||||
import { StorageSchema } from '../types/Storage';
|
||||
|
|
@ -13,7 +13,9 @@ export declare abstract class CascadeStore<ED extends EntityDict & BaseEntityDic
|
|||
protected abstract updateAbjointRow<T extends keyof ED, OP extends OperateOption, Cxt extends SyncContext<ED>>(entity: T, operation: ED[T]['Operation'], context: Cxt, option: OP): number;
|
||||
protected abstract selectAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, selection: ED[T]['Selection'], context: Cxt, option: OP): Promise<Partial<ED[T]['Schema']>[]>;
|
||||
protected abstract updateAbjointRowAsync<T extends keyof ED, OP extends OperateOption, Cxt extends AsyncContext<ED>>(entity: T, operation: ED[T]['Create'] | ED[T]['Update'] | ED[T]['Remove'], context: Cxt, option: OP): Promise<number>;
|
||||
protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>, R>(entity: T, projection2: ED[T]['Selection']['data'], context: Cxt, cascadeSelect: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => R, option: OP): {
|
||||
protected abstract aggregateSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): AggregationResult<ED[T]['Schema']>;
|
||||
protected abstract aggregateAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
||||
protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>>(entity: T, projection2: ED[T]['Selection']['data'], context: Cxt, cascadeSelectFn: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial<ED[T2]['Schema']>[] | Promise<Partial<ED[T2]['Schema']>[]>, option: OP): {
|
||||
projection: ED[T]["Selection"]["data"];
|
||||
cascadeSelectionFns: ((result: Partial<ED[T]['Schema']>[]) => Promise<void> | void)[];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
function CascadeStore(storageSchema) {
|
||||
return _super.call(this, storageSchema) || this;
|
||||
}
|
||||
CascadeStore.prototype.destructCascadeSelect = function (entity, projection2, context, cascadeSelect, option) {
|
||||
CascadeStore.prototype.destructCascadeSelect = function (entity, projection2, context, cascadeSelectFn, option) {
|
||||
var _this = this;
|
||||
var projection = {};
|
||||
var cascadeSelectionFns = [];
|
||||
|
|
@ -58,7 +58,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
});
|
||||
}
|
||||
});
|
||||
var _e = this_1.destructCascadeSelect(attr, projection2[attr], context, cascadeSelect, option), subProjection = _e.projection, subCascadeSelectionFns = _e.cascadeSelectionFns;
|
||||
var _e = this_1.destructCascadeSelect(attr, projection2[attr], context, cascadeSelectFn, option), subProjection = _e.projection, subCascadeSelectionFns = _e.cascadeSelectionFns;
|
||||
Object.assign(projection, (_b = {},
|
||||
_b[attr] = subProjection,
|
||||
_b));
|
||||
|
|
@ -101,7 +101,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
});
|
||||
};
|
||||
var entityIds = (0, lodash_1.uniq)(result.filter(function (ele) { return ele.entity === attr; }).map(function (ele) { return ele.entityId; }));
|
||||
var subRows = cascadeSelect.call(_this, attr, {
|
||||
var subRows = cascadeSelectFn.call(_this, attr, {
|
||||
data: projection2[attr],
|
||||
filter: {
|
||||
id: {
|
||||
|
|
@ -143,7 +143,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
}
|
||||
});
|
||||
}
|
||||
var _f = this_1.destructCascadeSelect(relation, projection2[attr], context, cascadeSelect, option), subProjection = _f.projection, subCascadeSelectionFns = _f.cascadeSelectionFns;
|
||||
var _f = this_1.destructCascadeSelect(relation, projection2[attr], context, cascadeSelectFn, option), subProjection = _f.projection, subCascadeSelectionFns = _f.cascadeSelectionFns;
|
||||
Object.assign(projection, (_d = {},
|
||||
_d[attr] = subProjection,
|
||||
_d));
|
||||
|
|
@ -191,7 +191,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
});
|
||||
};
|
||||
var ids = (0, lodash_1.uniq)(result.filter(function (ele) { return !!(ele["".concat(attr, "Id")]); }).map(function (ele) { return ele["".concat(attr, "Id")]; }));
|
||||
var subRows = cascadeSelect.call(_this, relation, {
|
||||
var subRows = cascadeSelectFn.call(_this, relation, {
|
||||
data: projection2[attr],
|
||||
filter: {
|
||||
id: {
|
||||
|
|
@ -225,7 +225,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
_a));
|
||||
});
|
||||
};
|
||||
var subRows = cascadeSelect.call(_this, entity2_1, {
|
||||
var subRows = cascadeSelectFn.call(_this, entity2_1, {
|
||||
data: subProjection_1,
|
||||
filter: (0, filter_1.combineFilters)([(_a = {},
|
||||
_a[foreignKey_1] = {
|
||||
|
|
@ -256,7 +256,7 @@ var CascadeStore = /** @class */ (function (_super) {
|
|||
_a));
|
||||
});
|
||||
};
|
||||
var subRows = cascadeSelect.call(_this, entity2_1, {
|
||||
var subRows = cascadeSelectFn.call(_this, entity2_1, {
|
||||
data: subProjection_1,
|
||||
filter: (0, filter_1.combineFilters)([{
|
||||
entity: entity,
|
||||
|
|
|
|||
|
|
@ -24,9 +24,10 @@ function judgeRelation(schema, entity, attr) {
|
|||
return 1;
|
||||
}
|
||||
if (attr.includes('$')) {
|
||||
var entity2 = attr.slice(0, attr.indexOf('$'));
|
||||
var firstDelimiter = attr.indexOf('$');
|
||||
var entity2 = attr.slice(0, firstDelimiter);
|
||||
(0, assert_1.default)(schema.hasOwnProperty(entity2));
|
||||
var foreignKey = attr.slice(attr.indexOf('$') + 1);
|
||||
var foreignKey = attr.slice(firstDelimiter + 1, attr.indexOf('$', firstDelimiter + 1));
|
||||
var _c = schema, _d = entity2, attributes2 = _c[_d].attributes;
|
||||
if (foreignKey === 'entity') {
|
||||
// 基于反指对象的反向关联
|
||||
|
|
|
|||
|
|
@ -174,14 +174,14 @@ export declare type Exportation<ED extends EntityDict, T extends keyof ED, K ext
|
|||
id: string;
|
||||
entity: T;
|
||||
projection: ED[T]['Selection']['data'];
|
||||
header: K[];
|
||||
fn: (data: ED[T]['Schema']) => Record<K, string | number | boolean | null>;
|
||||
headers: K[];
|
||||
fn: (data: ED[T]['Schema']) => Partial<Record<K, string | number | boolean | null>>;
|
||||
};
|
||||
export declare type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
|
||||
name: string;
|
||||
id: string;
|
||||
entity: T;
|
||||
header: K[];
|
||||
fn: (data: Record<K, string | number | boolean>) => ED[T]['CreateSingle']['data'];
|
||||
headers: K[];
|
||||
fn: (data: Partial<Record<K, string | number | boolean>>) => ED[T]['CreateSingle']['data'];
|
||||
};
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1361,6 +1361,21 @@ function constructSchema(statements: Array<ts.Statement>, entity: string) {
|
|||
),
|
||||
)
|
||||
);
|
||||
const aggrIdentifier = `${entityNameLc}$${foreignKey}$$aggr`;
|
||||
members2.push(
|
||||
factory.createPropertySignature(
|
||||
undefined,
|
||||
aggrIdentifier,
|
||||
factory.createToken(ts.SyntaxKind.QuestionToken),
|
||||
factory.createTypeReferenceNode(
|
||||
factory.createIdentifier("AggregationResult"),
|
||||
[factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, entityName, 'Schema'),
|
||||
undefined
|
||||
)]
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -1758,7 +1773,7 @@ function constructFilter(statements: Array<ts.Statement>, entity: string) {
|
|||
*/
|
||||
function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
||||
const { schemaAttrs } = Schema[entity];
|
||||
const properties: Array<[string | ts.PropertyName, boolean, ts.TypeNode?, ts.TypeNode?]> = [
|
||||
const properties: Array<[string | ts.PropertyName, boolean, ts.TypeNode?/* , ts.TypeNode? */]> = [
|
||||
['id', false],
|
||||
['$$createAt$$', false],
|
||||
['$$updateAt$$', false],
|
||||
|
|
@ -1808,9 +1823,9 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
[`${attrName}Id`, false, undefined],
|
||||
[name, false, factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, text2, 'Projection')
|
||||
), factory.createTypeReferenceNode(
|
||||
)/* , factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, text2, 'ExportProjection')
|
||||
)]
|
||||
) */]
|
||||
);
|
||||
if (foreignKeyProperties.hasOwnProperty(text2)) {
|
||||
foreignKeyProperties[text2].push(attrName);
|
||||
|
|
@ -1858,9 +1873,9 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
properties.push(
|
||||
[firstLetterLowerCase(one), false, factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, one, 'Projection')
|
||||
), factory.createTypeReferenceNode(
|
||||
)/* , factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, one, 'ExportProjection')
|
||||
)]
|
||||
) */]
|
||||
);
|
||||
if (foreignKeyProperties.hasOwnProperty(one)) {
|
||||
foreignKeyProperties[text2].push('entity');
|
||||
|
|
@ -1894,6 +1909,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
foreignKeySet[entityName].forEach(
|
||||
(foreignKey) => {
|
||||
const identifier = `${entityNameLc}$${foreignKey}`;
|
||||
const aggrIdentifier = `${entityNameLc}$${foreignKey}$$aggr`;
|
||||
properties.push(
|
||||
[identifier, false,
|
||||
factory.createIntersectionTypeNode([
|
||||
|
|
@ -1909,7 +1925,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
factory.createLiteralTypeNode(factory.createStringLiteral(firstLetterLowerCase(entityName)))
|
||||
)
|
||||
])
|
||||
]),
|
||||
])/* ,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, entityName, 'Exportation'),
|
||||
|
|
@ -1923,6 +1939,22 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
factory.createLiteralTypeNode(factory.createStringLiteral(firstLetterLowerCase(entityName)))
|
||||
)
|
||||
])
|
||||
]) */
|
||||
],
|
||||
[aggrIdentifier, false,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeReferenceNode(
|
||||
createForeignRef(entity, entityName, 'Aggregation'),
|
||||
undefined
|
||||
),
|
||||
factory.createTypeLiteralNode([
|
||||
factory.createPropertySignature(
|
||||
undefined,
|
||||
factory.createIdentifier("$entity"),
|
||||
undefined,
|
||||
factory.createLiteralTypeNode(factory.createStringLiteral(firstLetterLowerCase(entityName)))
|
||||
)
|
||||
])
|
||||
])
|
||||
]
|
||||
);
|
||||
|
|
@ -1952,7 +1984,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
]
|
||||
);
|
||||
|
||||
const MetaPropertySignaturs: ts.TypeElement[] = [
|
||||
const MetaPropertySignatures: ts.TypeElement[] = [
|
||||
factory.createPropertySignature(
|
||||
undefined,
|
||||
factory.createStringLiteral("#id"),
|
||||
|
|
@ -1963,7 +1995,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
)
|
||||
];
|
||||
if (process.env.COMPLING_AS_LIB) {
|
||||
MetaPropertySignaturs.push(
|
||||
MetaPropertySignatures.push(
|
||||
factory.createIndexSignature(
|
||||
undefined,
|
||||
undefined,
|
||||
|
|
@ -1989,7 +2021,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
undefined,
|
||||
factory.createIntersectionTypeNode([
|
||||
factory.createTypeLiteralNode(
|
||||
MetaPropertySignaturs.concat(
|
||||
MetaPropertySignatures.concat(
|
||||
properties.map(
|
||||
([n, q, v]) => {
|
||||
return factory.createPropertySignature(
|
||||
|
|
@ -2008,7 +2040,8 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
);
|
||||
|
||||
// ExportProjection,下载查询的投影
|
||||
statements.push(
|
||||
// 已经废弃。By Xc 2023.01.08
|
||||
/* statements.push(
|
||||
factory.createTypeAliasDeclaration(
|
||||
undefined,
|
||||
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
||||
|
|
@ -2032,7 +2065,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
|||
exprNode,
|
||||
])
|
||||
)
|
||||
);
|
||||
); */
|
||||
|
||||
// ${Entity}Projection,外键查询的专用投影
|
||||
for (const foreignKey in foreignKeyProperties) {
|
||||
|
|
@ -2838,7 +2871,8 @@ function constructActions(statements: Array<ts.Statement>, entity: string) {
|
|||
);
|
||||
|
||||
// Exportation
|
||||
statements.push(
|
||||
// 已经废弃,by Xc 2023.01.08
|
||||
/* statements.push(
|
||||
factory.createTypeAliasDeclaration(
|
||||
undefined,
|
||||
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
||||
|
|
@ -2863,7 +2897,7 @@ function constructActions(statements: Array<ts.Statement>, entity: string) {
|
|||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
); */
|
||||
|
||||
const { [entity]: manyToOneSet } = ManyToOne;
|
||||
const { [entity]: oneToManySet } = OneToMany;
|
||||
|
|
@ -4469,6 +4503,11 @@ const initialStatements = () => [
|
|||
undefined,
|
||||
factory.createIdentifier("EntityShape")
|
||||
),
|
||||
factory.createImportSpecifier(
|
||||
false,
|
||||
undefined,
|
||||
factory.createIdentifier("AggregationResult")
|
||||
),
|
||||
])
|
||||
),
|
||||
factory.createStringLiteral(`${TYPE_PATH_IN_OAK_DOMAIN()}Entity`),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import assert from "assert";
|
||||
import {
|
||||
EntityDict,
|
||||
OperateOption, SelectOption, OperationResult, DeduceFilter, CreateAtAttribute, UpdateAtAttribute
|
||||
OperateOption, SelectOption, OperationResult, DeduceFilter, CreateAtAttribute, UpdateAtAttribute, AggregationResult
|
||||
} from "../types/Entity";
|
||||
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
||||
import { RowStore } from '../types/RowStore';
|
||||
|
|
@ -49,11 +49,23 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
context: Cxt,
|
||||
option: OP): Promise<number>;
|
||||
|
||||
protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>, R>(
|
||||
protected abstract aggregateSync<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED>>(
|
||||
entity: T,
|
||||
aggregation: ED[T]['Aggregation'],
|
||||
context: Cxt,
|
||||
option: OP): AggregationResult<ED[T]['Schema']>;
|
||||
|
||||
protected abstract aggregateAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(
|
||||
entity: T,
|
||||
aggregation: ED[T]['Aggregation'],
|
||||
context: Cxt,
|
||||
option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
|
||||
|
||||
protected destructCascadeSelect<T extends keyof ED, OP extends SelectOption, Cxt extends SyncContext<ED> | AsyncContext<ED>>(
|
||||
entity: T,
|
||||
projection2: ED[T]['Selection']['data'],
|
||||
context: Cxt,
|
||||
cascadeSelect: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => R,
|
||||
cascadeSelectFn: <T2 extends keyof ED>(entity2: T2, selection: ED[T2]['Selection'], context: Cxt, op: OP) => Partial<ED[T2]['Schema']>[] | Promise<Partial<ED[T2]['Schema']>[]>,
|
||||
option: OP) {
|
||||
const projection: ED[T]['Selection']['data'] = {};
|
||||
const cascadeSelectionFns: Array<(result: Partial<ED[T]['Schema']>[]) => Promise<void> | void> = [];
|
||||
|
|
@ -102,7 +114,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
const {
|
||||
projection: subProjection,
|
||||
cascadeSelectionFns: subCascadeSelectionFns,
|
||||
} = this.destructCascadeSelect(attr, projection2[attr], context, cascadeSelect, option);
|
||||
} = this.destructCascadeSelect(attr, projection2[attr], context, cascadeSelectFn, option);
|
||||
Object.assign(projection, {
|
||||
[attr]: subProjection,
|
||||
});
|
||||
|
|
@ -159,7 +171,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
ele => ele.entityId
|
||||
) as string[]);
|
||||
|
||||
const subRows = cascadeSelect.call(this, attr as any, {
|
||||
const subRows = cascadeSelectFn.call(this, attr as any, {
|
||||
data: projection2[attr],
|
||||
filter: {
|
||||
id: {
|
||||
|
|
@ -211,7 +223,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
const {
|
||||
projection: subProjection,
|
||||
cascadeSelectionFns: subCascadeSelectionFns,
|
||||
} = this.destructCascadeSelect(relation, projection2[attr], context, cascadeSelect, option);
|
||||
} = this.destructCascadeSelect(relation, projection2[attr], context, cascadeSelectFn, option);
|
||||
Object.assign(projection, {
|
||||
[attr]: subProjection,
|
||||
});
|
||||
|
|
@ -273,7 +285,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
ele => ele[`${attr}Id`]
|
||||
) as string[]);
|
||||
|
||||
const subRows = cascadeSelect.call(this, relation, {
|
||||
const subRows = cascadeSelectFn.call(this, relation, {
|
||||
data: projection2[attr],
|
||||
filter: {
|
||||
id: {
|
||||
|
|
@ -317,7 +329,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
);
|
||||
};
|
||||
|
||||
const subRows = cascadeSelect.call(this, entity2, {
|
||||
const subRows = cascadeSelectFn.call(this, entity2, {
|
||||
data: subProjection,
|
||||
filter: combineFilters([{
|
||||
[foreignKey]: {
|
||||
|
|
@ -358,7 +370,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
);
|
||||
};
|
||||
|
||||
const subRows = cascadeSelect.call(this, entity2, {
|
||||
const subRows = cascadeSelectFn.call(this, entity2, {
|
||||
data: subProjection,
|
||||
filter: combineFilters([{
|
||||
entity,
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@ export function judgeRelation<ED extends {
|
|||
}
|
||||
|
||||
if (attr.includes('$')) {
|
||||
const entity2 = attr.slice(0, attr.indexOf('$'));
|
||||
const firstDelimiter = attr.indexOf('$');
|
||||
const entity2 = attr.slice(0, firstDelimiter);
|
||||
assert (schema.hasOwnProperty(entity2));
|
||||
const foreignKey = attr.slice(attr.indexOf('$') + 1);
|
||||
const foreignKey = attr.slice(firstDelimiter + 1, attr.indexOf('$', firstDelimiter + 1));
|
||||
const { [entity2]: { attributes: attributes2 } } = schema;
|
||||
|
||||
if (foreignKey === 'entity') {
|
||||
|
|
|
|||
|
|
@ -252,14 +252,14 @@ export type Exportation<ED extends EntityDict, T extends keyof ED, K extends str
|
|||
id: string;
|
||||
entity: T;
|
||||
projection: ED[T]['Selection']['data'];
|
||||
header: K[];
|
||||
fn: (data: ED[T]['Schema']) => Record<K, string | number | boolean | null>;
|
||||
headers: K[];
|
||||
fn: (data: ED[T]['Schema']) => Partial<Record<K, string | number | boolean | null>>;
|
||||
};
|
||||
|
||||
export type Importation<ED extends EntityDict, T extends keyof ED, K extends string> = {
|
||||
name: string;
|
||||
id: string;
|
||||
entity: T;
|
||||
header: K[];
|
||||
fn: (data: Record<K, string | number | boolean>) => ED[T]['CreateSingle']['data'];
|
||||
headers: K[];
|
||||
fn: (data: Partial<Record<K, string | number | boolean>>) => ED[T]['CreateSingle']['data'];
|
||||
};
|
||||
Loading…
Reference in New Issue