schema-dts-gen
Version:
Generate TypeScript Definitions for Schema.org Schema
102 lines • 3.86 kB
TypeScript
/**
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { NamedNode } from 'n3';
import type { Quad, Term, Quad_Object, Quad_Predicate, Quad_Subject } from 'n3';
export interface Topic {
subject: Quad_Subject;
quads: Quad[];
}
export interface TypedTopic extends Topic {
types: readonly NamedNode[];
}
/**
* If an ObjectPredicate represents a comment, returns the comment. Otherwise
* returns null.
*/
export declare function GetComment(q: Quad): {
comment: string;
} | null;
/**
* If an ObjectPredicate represents a subClass relation, returns the parent
* class. Otherwise returns null.
*/
export declare function GetSubClassOf(q: Quad): {
subClassOf: NamedNode;
} | null;
/** Return true iff this object is a subclass of some other entity. */
export declare function IsSubclass(topic: TypedTopic): boolean;
/** Returns true iff a node corresponds to http://schema.org/DataType */
export declare function IsDataType(t: Quad_Subject): boolean;
/** Returns true iff a Topic represents a DataType. */
export declare function ClassIsDataType(topic: TypedTopic): boolean;
/**
* Returns true iff a Topic represents a named class.
*
* Note that some schemas define subclasses without explicitly redefining them
* as classes. So just because a topic isn't directly named as a class doesn't
* mean that it isn't a named class.
*
* A named class is such if it *OR ANY OF ITS PARENTS* are directly named
* classes.
*/
export declare function IsDirectlyNamedClass(topic: TypedTopic): boolean;
/**
* Returns true iff a Predicate corresponds to http://schema.org/domainIncludes
*/
export declare function IsDomainIncludes(value: Quad_Predicate): boolean;
/**
* Returns true iff a Predicate corresponds to http://schema.org/rangeIncludes
*/
export declare function IsRangeIncludes(value: Quad_Predicate): boolean;
/**
* Returns true iff a Predicate corresponds to http://schema.org/supersededBy.
*/
export declare function IsSupersededBy(value: Quad_Predicate): boolean;
/**
* Returns true iff a Predicate corresponds to
* http://www.w3.org/1999/02/22-rdf-syntax-ns#type.
*/
export declare function IsType(predicate: Quad_Predicate): boolean;
/** Returns iff an Object can be described as a Type Name. */
export declare function IsTypeName(value: Quad_Object): value is NamedNode;
/**
* If an ObjectPredicate corresponds to a
* http://www.w3.org/1999/02/22-rdf-syntax-ns#type, returns a Type it describes.
*/
export declare function GetType(value: Quad): NamedNode | null;
/**
* Returns all Nodes described by a Topic's
* http://www.w3.org/1999/02/22-rdf-syntax-ns#type predicates.
*/
export declare function GetTypes(values: readonly Quad[]): readonly NamedNode[];
/**
* Returns true iff a Type corresponds to
* http://www.w3.org/2000/01/rdf-schema#Class
*/
export declare function IsClassType(type: Term): boolean;
/**
* Returns true iff a Type corresponds to
* http://www.w3.org/1999/02/22-rdf-syntax-ns#Property
*/
export declare function IsPropertyType(type: Term): boolean;
/**
* Returns true iff a Subject has a Type indicating it is an Enum value.
*
* Enum Values have, in addition to other Data or Class types, another object as
* its "Type".
*/
export declare function HasEnumType(types: readonly NamedNode[]): boolean;
//# sourceMappingURL=wellKnown.d.ts.map