import type { Schema, EntityInterface, IDenormalizeDelegate, PolymorphicInterface, SchemaClass, IQueryDelegate, INormalizeDelegate, } from './interface.js'; import type { AbstractInstanceType, Normalize, NormalizeNullable, Denormalize, DenormalizeNullable, DenormalizeObject, DenormalizeNullableObject, NormalizeObject, NormalizedNullableObject, EntityMap, ObjectArgs, } from './normal.js'; import { EntityFields } from './schemas/EntityFields.js'; import { default as EntityMixin, default as Entity, } from './schemas/EntityMixin.js'; import { default as Invalidate } from './schemas/Invalidate.js'; import { default as Lazy } from './schemas/Lazy.js'; import { default as Query } from './schemas/Query.js'; import { default as Scalar } from './schemas/Scalar.js'; import type { CollectionConstructor, DefaultArgs, SchemaAttributeFunction, SchemaFunction, UnionResult, } from './schemaTypes.js'; export { EntityMap, Invalidate, Query, Lazy, Scalar, EntityMixin, Entity }; export type { SchemaClass }; export { EntityInterface } from './interface.js'; export * from './schemaTypes.js'; /** * Represents arrays * @see https://dataclient.io/rest/api/Array */ export class Array implements SchemaClass { /** * Represents arrays * @see https://dataclient.io/rest/api/Array */ constructor( definition: S, schemaAttribute?: S extends EntityMap ? keyof T | SchemaFunction : undefined, ); define(definition: Schema): void; readonly isSingleSchema: S extends EntityMap ? false : true; schemaKey(): string; readonly schema: S; normalize( input: any, parent: any, key: any, delegate: INormalizeDelegate, ): (S extends EntityMap ? UnionResult : Normalize)[]; _normalizeNullable(): | (S extends EntityMap ? UnionResult : Normalize)[] | undefined; _denormalizeNullable(): | (S extends EntityMap ? T : Denormalize)[] | undefined; denormalize( input: {}, delegate: IDenormalizeDelegate, ): (S extends EntityMap ? T : Denormalize)[]; queryKey( args: readonly any[], unvisit: (...args: any) => any, delegate: any, ): undefined; } /** * Retrieves all entities in cache * * @see https://dataclient.io/rest/api/All */ export class All< S extends EntityMap | EntityInterface = EntityMap | EntityInterface, > implements SchemaClass { /** * Retrieves all entities in cache * * @see https://dataclient.io/rest/api/All */ constructor( definition: S, schemaAttribute?: S extends EntityMap ? keyof T | SchemaFunction : undefined, ); define(definition: Schema): void; readonly isSingleSchema: S extends EntityMap ? false : true; schemaKey(): string; readonly schema: S; schemaKey(): string; normalize( input: any, parent: any, key: any, delegate: INormalizeDelegate, ): (S extends EntityMap ? UnionResult : Normalize)[]; _normalizeNullable(): | (S extends EntityMap ? UnionResult : Normalize)[] | undefined; _denormalizeNullable(): | (S extends EntityMap ? T : Denormalize)[] | undefined; denormalize( input: {}, delegate: IDenormalizeDelegate, ): (S extends EntityMap ? T : Denormalize)[]; queryKey( // TODO: hack for now to allow for variable arg combinations with Query args: [] | [unknown], unvisit: (...args: any) => any, delegate: IQueryDelegate, ): any; } /** * Represents objects with statically known members * @see https://dataclient.io/rest/api/Object */ export class Object< O extends Record = Record, > implements SchemaClass { /** * Represents objects with statically known members * @see https://dataclient.io/rest/api/Object */ constructor(definition: O); define(definition: Schema): void; readonly schema: O; normalize( input: any, parent: any, key: any, delegate: INormalizeDelegate, ): NormalizeObject; _normalizeNullable(): NormalizedNullableObject; _denormalizeNullable(): DenormalizeNullableObject; denormalize(input: {}, delegate: IDenormalizeDelegate): DenormalizeObject; queryKey( args: ObjectArgs, unvisit: (...args: any) => any, delegate: IQueryDelegate, ): any; } type RequiredMember< O extends Record, Required extends keyof O, > = { [K in Required]: O[K]; }; type UnionSchemaToArgs< Choices extends EntityMap, SchemaAttribute extends | keyof AbstractInstanceType | SchemaFunction, > = SchemaAttribute extends keyof AbstractInstanceType ? RequiredMember< AbstractInstanceType, SchemaAttribute > : SchemaAttribute extends (value: infer Args, ...rest: any) => unknown ? Args : never; /** * Represents polymorphic values. * @see https://dataclient.io/rest/api/Union */ export interface UnionConstructor { /** * Represents polymorphic values. * @see https://dataclient.io/rest/api/Union */ new < Choices extends EntityMap, SchemaAttribute extends | keyof AbstractInstanceType | SchemaFunction, >( definition: Choices, schemaAttribute: SchemaAttribute, ): UnionInstance< Choices, Partial> & Partial> >; readonly prototype: UnionInstance; } /** * Represents polymorphic values. * @see https://dataclient.io/rest/api/Union */ export interface UnionInstance< Choices extends EntityMap = any, Args extends EntityFields> = EntityFields>, > { readonly _hoistable: true; define(definition: Schema): void; inferSchema: SchemaAttributeFunction; getSchemaAttribute: SchemaFunction; schemaKey(): string; readonly schema: Choices; normalize( input: any, parent: any, key: any, delegate: INormalizeDelegate, ): UnionResult; _normalizeNullable(): UnionResult | undefined; _denormalizeNullable(): | AbstractInstanceType | undefined; denormalize( input: {}, delegate: IDenormalizeDelegate, ): AbstractInstanceType; queryKey( args: [Args], unvisit: (...args: any) => any, delegate: IQueryDelegate, ): { id: any; schema: string }; } /** * Represents polymorphic values. * @see https://dataclient.io/rest/api/Union */ export declare let UnionRoot: UnionConstructor; /** * Represents polymorphic values. * @see https://dataclient.io/rest/api/Union */ export declare class Union< Choices extends EntityMap, SchemaAttribute extends | keyof AbstractInstanceType | SchemaFunction, > extends UnionRoot {} /** * Represents variably sized objects * @see https://dataclient.io/rest/api/Values */ export class Values implements SchemaClass { /** * Represents variably sized objects * @see https://dataclient.io/rest/api/Values */ constructor( definition: Choices, schemaAttribute?: Choices extends EntityMap ? keyof T | SchemaFunction : undefined, ); define(definition: Schema): void; readonly isSingleSchema: Choices extends EntityMap ? false : true; schemaKey(): string; inferSchema: SchemaAttributeFunction< Choices extends EntityMap ? Choices[keyof Choices] : Choices >; getSchemaAttribute: Choices extends EntityMap ? SchemaFunction : false; readonly schema: Choices; normalize( input: any, parent: any, key: any, delegate: INormalizeDelegate, ): Record< string, Choices extends EntityMap ? UnionResult : Normalize >; _normalizeNullable(): | Record< string, Choices extends EntityMap ? UnionResult : NormalizeNullable > | undefined; _denormalizeNullable(): Record< string, Choices extends EntityMap ? T | undefined : DenormalizeNullable >; denormalize( input: {}, delegate: IDenormalizeDelegate, ): Record< string, Choices extends EntityMap ? T : Denormalize >; queryKey( args: readonly any[], unvisit: (...args: any) => any, delegate: IQueryDelegate, ): undefined; } /** Collection merge that places incoming items at the start. * * @see https://dataclient.io/rest/api/Collection#moveWith */ export declare const unshift: (existing: any, incoming: any) => any; export declare let CollectionRoot: CollectionConstructor; /** * Entities but for Arrays instead of classes * @see https://dataclient.io/rest/api/Collection */ export declare class Collection< S extends any[] | PolymorphicInterface = any, Args extends any[] = DefaultArgs, Parent = any, > extends CollectionRoot {}