UNPKG

@opra/common

Version:
78 lines (77 loc) 2.6 kB
import 'reflect-metadata'; import { type Combine, type Type } from 'ts-gems'; import type { Field } from '../../schema/data-type/field.interface.js'; import { OpraSchema } from '../../schema/index.js'; import type { ApiDocument } from '../api-document.js'; import { DocumentElement } from '../common/document-element.js'; import type { ComplexType } from './complex-type.js'; import { ComplexTypeBase } from './complex-type-base.js'; import { DataType } from './data-type.js'; import type { MixinType } from './mixin-type.js'; /** * @namespace MappedType */ export declare namespace MappedType { interface Metadata extends Combine<{ kind: OpraSchema.MappedType.Kind; base: Type | string; }, DataType.Metadata, Pick<ComplexType.Metadata, 'additionalFields'>, OpraSchema.MappedType> { } interface Options<T, K = keyof T> { pick?: readonly K[]; omit?: readonly K[]; partial?: readonly K[] | boolean; } interface InitArguments extends Combine<{ kind: OpraSchema.MappedType.Kind; base: ComplexType | MappedType | MixinType; ctor?: Type; }, DataType.InitArguments, MappedType.Metadata> { } } /** * Type definition of class constructor for MappedType */ export interface MappedTypeStatic { /** * Class constructor of MappedType * * @param owner * @param args * @constructor */ new (owner: DocumentElement, args: MappedType.InitArguments): MappedType; _applyMixin(targetType: Type, sourceType: Type, options: MappedType.Options<any> & { isInheritedPredicate: (fieldName: string) => boolean; }): void; prototype: MappedType; } /** * Type definition of MappedType prototype * @interface MappedType */ export interface MappedType extends MappedTypeClass { } /** * MappedType constructor */ export declare const MappedType: MappedTypeStatic; /** * * @class MappedType */ declare class MappedTypeClass extends ComplexTypeBase { readonly kind: OpraSchema.MappedType.Kind; readonly base: ComplexType | MappedType | MixinType; readonly ctor?: Type; readonly omit?: Field.Name[]; readonly pick?: Field.Name[]; readonly partial?: Field.Name[] | boolean; readonly required?: Field.Name[] | boolean; discriminatorField?: string; discriminatorValue?: string; extendsFrom(baseType: DataType | string | Type | object): boolean; toJSON(options?: ApiDocument.ExportOptions): OpraSchema.MappedType; protected _locateBase(callback: (base: ComplexTypeBase) => boolean): ComplexTypeBase | undefined; } export {};