/*! * Copyright 2020 Ron Buckton * * 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 * * http://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 type { DataTypeNameLike } from "./dataTypeNameLike"; import type { GraphCategory } from "./graphCategory"; import type { GraphCategoryIdLike } from "./graphCategoryIdLike"; import type { GraphProperty } from "./graphProperty"; import type { GraphPropertyIdLike } from "./graphPropertyIdLike"; import type { GraphSchemaNameLike } from "./graphSchemaNameLike"; import type { Graph } from "./graph"; import { DataTypeCollection } from "./dataTypeCollection"; import { DataType } from "./dataType"; import { EventSubscription } from "./events"; import { GraphCategoryCollection } from "./graphCategoryCollection"; import { GraphSchemaCollection } from "./graphSchemaCollection"; import { GraphPropertyCollection } from "./graphPropertyCollection"; /** * A GraphSchema defines a related set of graph categories and properties. */ export declare class GraphSchema { private _graph; private _name; private _schemas; private _dataTypes; private _categories; private _properties; private _events?; constructor(name: GraphSchemaNameLike); /** * Gets the graph that owns the schema. */ get graph(): Graph | undefined; /** * Gets the name of the schema. */ get name(): GraphSchemaNameLike; /** * Gets the child schemas of this schema. */ get schemas(): GraphSchemaCollection; /** * Gets the categories defined by this schema. */ get categories(): GraphCategoryCollection; /** * Gets the properties defined by this schema. */ get properties(): GraphPropertyCollection; /** * Gets the data types defined by this schema. */ get dataTypes(): DataTypeCollection; /** * Creates a subscription for a set of named events. */ subscribe(events: GraphSchemaEvents): EventSubscription; /** * Determines whether this schema contains the provided schema as a child or grandchild. */ hasSchema(schema: GraphSchema | GraphSchemaNameLike): boolean; /** * Adds a child schema to this schema. */ addSchema(schema: GraphSchema): this; /** * Creates an iterator for all schemas within this schema (including this schema). */ allSchemas(): IterableIterator; /** * Finds a category in this schema or its descendants. */ findCategory(id: GraphCategoryIdLike): GraphCategory | undefined; /** * Creates an iterator for the categories in this schema or its descendants with the provided ids. */ findCategories(...categoryIds: GraphCategoryIdLike[]): IterableIterator; /** * Finds a property in this schema or its descendants. */ findProperty(id: GraphPropertyIdLike): GraphProperty | undefined; /** * Creates an iterator for the properties in this schema or its descendants with the provided ids. */ findProperties(...propertyIds: GraphPropertyIdLike[]): IterableIterator; /** * Finds a data type in this schema or its descendants. */ findDataType(name: DataTypeNameLike, packageQualifier?: string): DataType | undefined; } export interface GraphSchemaEvents { /** * An event raised when the schema or one of its child schemas has changed. */ onChanged?: () => void; } export declare const DATATYPE_GraphSchema: DataType;