/*! * 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"; export declare class DataType { /** * The default DataType representing the `string` type. */ static readonly string: DataType; /** * The default DataType representing the `symbol` type. */ static readonly symbol: DataType; /** * The default DataType representing the `number` type. */ static readonly number: DataType; /** * The default DataType representing the `bigint` type. */ static readonly bigint: DataType; /** * The default DataType representing the `boolean` type. */ static readonly boolean: DataType; /** * The default DataType representing the `object` type. */ static readonly object: DataType; /** * The default DataType representing the `function` type. */ static readonly function: DataType; /** * The default DataType representing the `null` type. */ static readonly null: DataType; /** * The default DataType representing the `undefined` type. */ static readonly undefined: DataType; /** * The default DataType representing the TypeScript `unknown` type. */ static readonly unknown: DataType; /** * The default DataType representing the TypeScript `never` type. */ static readonly never: DataType; /** * The default DataType representing the TypeScript `any` type. */ static readonly any: DataType; static readonly DataType: DataType>; private readonly _validator?; private _canValidateCache?; private readonly _canConvert?; private readonly _convert?; /** * For internal use only. Instances should be created via `GraphSchema.dataTypes.getOrCreate()`. */ private constructor(); /** * Gets the name for the data type */ get name(): DataTypeNameLike; /** * Gets the package name and submodule path for this data type (if available). */ get packageQualifier(): string; /** * Gets the fully-qualified name for the data type. */ get fullName(): DataTypeNameLike; /** * Gets a value indicating whether this data type supports validation. */ get canValidate(): boolean; /** * Gets a data type that represents a union of multiple data types. */ static union(...constituentTypes: A): DataType ? T : never>; /** * Validates whether a value is valid for this data type. */ validate(value: any): value is T; /** * Tests whether the provided value can be converted into the underlying data-type value. */ canConvert(value: any): "convertible" | "not-convertible" | "ambiguous"; /** * Converts the provided value to a value consistent with the datatype. */ convert(value: any): T; toString(): string; } export interface DataTypeOptions { validate?: ((value: any) => value is T) | ((value: any) => boolean); canConvert?: (value: any) => boolean; convert?: (value: any) => T; }