import type { IDenormalizeDelegate, Queryable, SchemaSimple, } from '../interface.js'; import type { Denormalize, NormalizeNullable, SchemaArgs } from '../normal.js'; /** * Programmatic cache reading * * @see https://dataclient.io/rest/api/Query */ export default class Query< S extends Queryable | { [k: string]: Queryable }, P extends (entries: Denormalize, ...args: any) => any, > implements SchemaSimple | undefined, ProcessParameters> { declare schema: S; declare process: P; /** * Programmatic cache reading * * @see https://dataclient.io/rest/api/Query */ constructor(schema: S, process: P) { this.schema = schema; this.process = process; } normalize(...args: any) { return (this.schema as any).normalize(...args); } denormalize(input: {}, delegate: IDenormalizeDelegate): ReturnType

{ const value = delegate.unvisit(this.schema, input); return ( typeof value === 'symbol' ? value : ( this.process(value, ...delegate.args) )) as any; } queryKey( args: ProcessParameters, unvisit: (schema: any, args: any) => any, ) { return unvisit(this.schema, args); } declare _denormalizeNullable: ( input: {}, delegate: IDenormalizeDelegate, ) => ReturnType

| undefined; declare _normalizeNullable: () => NormalizeNullable; } type ProcessParameters = P extends (entries: any, ...args: infer Par) => any ? Par extends [] ? SchemaArgs : Par & SchemaArgs : SchemaArgs;