@cubicweb/client
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -66,2 +66,3 @@ import { Cardinality } from ".."; | ||
subject: ERawSchema["type"]; | ||
final: false; | ||
}>>[]; | ||
@@ -73,2 +74,3 @@ /** | ||
object: ERawSchema["type"]; | ||
final: false; | ||
}>>[]; | ||
@@ -87,3 +89,6 @@ /** | ||
*/ | ||
get attributes(): RelationDefinitionSchema<E, R, R[number]>[]; | ||
get attributes(): RelationDefinitionSchema<E, R, MatchedRelationDefinition<E, R, { | ||
subject: ERawSchema["type"]; | ||
final: true; | ||
}>>[]; | ||
} | ||
@@ -113,2 +118,6 @@ /** | ||
/** | ||
* The list of options set for this relation | ||
*/ | ||
get options(): RDef["options"]; | ||
/** | ||
* The list of constraints if any. Only attributes (relations with final = true) have constraints. | ||
@@ -115,0 +124,0 @@ * In other cases this returns null. |
@@ -163,2 +163,8 @@ "use strict"; | ||
/** | ||
* The list of options set for this relation | ||
*/ | ||
get options() { | ||
return this.relDef.options; | ||
} | ||
/** | ||
* The list of constraints if any. Only attributes (relations with final = true) have constraints. | ||
@@ -165,0 +171,0 @@ * In other cases this returns null. |
@@ -93,2 +93,13 @@ declare type ConstraintBase<T extends string, V extends Record<string, unknown> | null> = { | ||
export declare type EntityRawSchemaArray = ReadonlyArray<EntityRawSchema>; | ||
export declare type AttributeOptions = { | ||
indexed?: boolean; | ||
fulltextindexed?: boolean; | ||
internationalizable?: boolean; | ||
}; | ||
export declare type RelationOptions = { | ||
symmetric?: boolean; | ||
inlined?: boolean; | ||
fulltext_container?: "subject" | "object"; | ||
composite?: "subject" | "object"; | ||
}; | ||
export declare type RelationDefinitionRawSchema<ESchemas extends EntityRawSchemaArray, Final extends boolean = boolean> = Readonly<{ | ||
@@ -100,3 +111,5 @@ type: string; | ||
} & (Final extends true ? BuildObj & { | ||
final: true; | ||
constraints: Constraint[]; | ||
options: AttributeOptions; | ||
} : { | ||
@@ -106,2 +119,3 @@ object: EntityRawSchema["type"]; | ||
constraints: null; | ||
options: RelationOptions; | ||
})>; | ||
@@ -108,0 +122,0 @@ export declare type RelationDefinitionRawSchemaArray<ESchemas extends EntityRawSchemaArray> = ReadonlyArray<RelationDefinitionRawSchema<ESchemas, boolean>>; |
@@ -5,3 +5,3 @@ { | ||
"author": "Logilab", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"license": "LGPL-3.0-or-later", | ||
@@ -8,0 +8,0 @@ "main": "lib/index.js", |
@@ -28,6 +28,3 @@ import { Cardinality } from ".."; | ||
) => { | ||
return schema as unknown as Schema< | ||
EntityRawSchemaArray, | ||
RelationDefinitionRawSchemaArray<EntityRawSchemaArray> | ||
>; | ||
return schema as unknown as Schema; | ||
}; | ||
@@ -167,3 +164,7 @@ | ||
R, | ||
MatchedRelationDefinition<E, R, { subject: ERawSchema["type"] }> | ||
MatchedRelationDefinition< | ||
E, | ||
R, | ||
{ subject: ERawSchema["type"]; final: false } | ||
> | ||
>[] { | ||
@@ -182,3 +183,7 @@ return this.schema.matchRelationDefinitions({ | ||
R, | ||
MatchedRelationDefinition<E, R, { object: ERawSchema["type"] }> | ||
MatchedRelationDefinition< | ||
E, | ||
R, | ||
{ object: ERawSchema["type"]; final: false } | ||
> | ||
>[] { | ||
@@ -210,3 +215,11 @@ return this.schema.matchRelationDefinitions({ | ||
*/ | ||
get attributes(): RelationDefinitionSchema<E, R, R[number]>[] { | ||
get attributes(): RelationDefinitionSchema< | ||
E, | ||
R, | ||
MatchedRelationDefinition< | ||
E, | ||
R, | ||
{ subject: ERawSchema["type"]; final: true } | ||
> | ||
>[] { | ||
return this.schema.matchRelationDefinitions({ | ||
@@ -250,2 +263,8 @@ final: true, | ||
} | ||
/** | ||
* The list of options set for this relation | ||
*/ | ||
get options(): RDef["options"] { | ||
return this.relDef.options; | ||
} | ||
@@ -252,0 +271,0 @@ /** |
@@ -147,2 +147,15 @@ type ConstraintBase< | ||
export type AttributeOptions = { | ||
indexed?: boolean; | ||
fulltextindexed?: boolean; | ||
internationalizable?: boolean; | ||
}; | ||
export type RelationOptions = { | ||
symmetric?: boolean; | ||
inlined?: boolean; | ||
fulltext_container?: "subject" | "object"; | ||
composite?: "subject" | "object"; | ||
}; | ||
export type RelationDefinitionRawSchema< | ||
@@ -159,5 +172,12 @@ ESchemas extends EntityRawSchemaArray, | ||
? BuildObj & { | ||
final: true; | ||
constraints: Constraint[]; | ||
options: AttributeOptions; | ||
} | ||
: { object: EntityRawSchema["type"]; final: false; constraints: null }) | ||
: { | ||
object: EntityRawSchema["type"]; | ||
final: false; | ||
constraints: null; | ||
options: RelationOptions; | ||
}) | ||
>; | ||
@@ -164,0 +184,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81619
1671