@cubicweb/client
Advanced tools
Comparing version 1.8.0 to 1.9.0
import { EntityRawSchemaArray } from "../raw/Entities"; | ||
import { Cardinality, RelationDefinitionRawSchema, RelationDefinitionRawSchemaArray } from "../raw/RelationDefinitions"; | ||
import { Schema } from "./Schema"; | ||
import { EntitySchema } from "./EntitySchema"; | ||
/** | ||
@@ -30,2 +31,4 @@ * Returns the given schema using loose typing. | ||
export type MatchedRelationDefinition<E extends EntityRawSchemaArray, R extends RelationDefinitionRawSchemaArray<EntityRawSchemaArray>, M extends RelationDefinitionMatcher<E>> = R[number] extends infer RDef ? (RDef extends M ? RDef : never) : never; | ||
export declare function hasAttributeWithName(entitySchema: EntitySchema, attributeNameSearched: string): boolean; | ||
export declare function isAttributeRichString(entitySchema: EntitySchema, attributeNameSearched: string): boolean; | ||
//# sourceMappingURL=Utils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cardinalityRequired = exports.getLooseSchema = void 0; | ||
exports.isAttributeRichString = exports.hasAttributeWithName = exports.cardinalityRequired = exports.getLooseSchema = void 0; | ||
/** | ||
@@ -25,2 +25,15 @@ * Returns the given schema using loose typing. | ||
exports.cardinalityRequired = cardinalityRequired; | ||
function hasAttributeWithName(entitySchema, attributeNameSearched) { | ||
for (const entityAttribute of entitySchema.attributes) { | ||
if (entityAttribute.type == attributeNameSearched) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
exports.hasAttributeWithName = hasAttributeWithName; | ||
function isAttributeRichString(entitySchema, attributeNameSearched) { | ||
return hasAttributeWithName(entitySchema, attributeNameSearched + "_format"); | ||
} | ||
exports.isAttributeRichString = isAttributeRichString; | ||
//# sourceMappingURL=Utils.js.map |
@@ -5,3 +5,3 @@ { | ||
"author": "Logilab", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"license": "LGPL-3.0-or-later", | ||
@@ -8,0 +8,0 @@ "main": "lib/index.js", |
@@ -206,3 +206,1 @@ # @cubicweb/client | ||
``` | ||
@@ -8,2 +8,3 @@ import { EntityRawSchemaArray } from "../raw/Entities"; | ||
import { Schema } from "./Schema"; | ||
import { EntitySchema } from "./EntitySchema"; | ||
@@ -54,1 +55,20 @@ /** | ||
> = R[number] extends infer RDef ? (RDef extends M ? RDef : never) : never; | ||
export function hasAttributeWithName( | ||
entitySchema: EntitySchema, | ||
attributeNameSearched: string | ||
): boolean { | ||
for (const entityAttribute of entitySchema.attributes) { | ||
if (entityAttribute.type == attributeNameSearched) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
export function isAttributeRichString( | ||
entitySchema: EntitySchema, | ||
attributeNameSearched: string | ||
): boolean { | ||
return hasAttributeWithName(entitySchema, attributeNameSearched + "_format"); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
138317
2825
206