import { Expression } from '../../core/expression'; import { PipeOperator } from '../../core/pipe-operator'; import { ExpressionResultType } from '../../types/expression-result-type'; import { TsFlexQueryTypeMarker } from '../../types/ts-flex-query-type'; import { IfPrimitive } from '../../types/utils'; import type { Error } from '../../types/utils'; export type PrimitiveSchemaSpec = true; type PrimitiveQuerySchemaType = TFieldType; declare enum SpecialObjectSchemaSpec { /** Expand the object with all its primitive fields. */ expand = "expand", /** Like expand, but when using OData, don't include the field in the $expand clause. */ select = "select" } type ExplicitObjectSchemaSpec = { [TKey in keyof NonNullable & string]?: SpecificSchemaSpec[TKey], NonNullable>; }; type ObjectSchemaSpec = keyof typeof SpecialObjectSchemaSpec | ExplicitObjectSchemaSpec; type NonNullableObjectSchemaType> = TSchema extends ExplicitObjectSchemaSpec ? (TsFlexQueryTypeMarker<'record'> & { [key in keyof TSchema]: key extends keyof NonNullable ? SchemaType[key], NonNullable> : never; }) : NonNullable; type ObjectSchemaType> = undefined extends TIn ? NonNullableObjectSchemaType | undefined : NonNullableObjectSchemaType; type ValidObjectSchemaSpec = keyof typeof SpecialObjectSchemaSpec | { [TKey in keyof TSchema]: TKey extends keyof NonNullable ? ValidSchemaSpec[TKey], TSchema[TKey]> : never; }; export type ArraySchemaSpec = readonly [ObjectSchemaSpec]; type ArraySchemaType> = (ObjectSchemaType)[]; export type ExpressionSchemaSpec = TContainer extends null ? (valueExpr: Expression) => Expression : (valueExpr: Expression, container: Expression) => Expression; type ExpressionSchemaType> = ExpressionResultType>; export type SchemaSpec = PrimitiveSchemaSpec | ObjectSchemaSpec | ArraySchemaSpec | ExpressionSchemaSpec; export type SpecificSchemaSpec = (NonNullable extends (infer TElement)[] ? ArraySchemaSpec : IfPrimitive>) | ExpressionSchemaSpec; export type ValidSchemaSpec = TSchema extends readonly [infer TObjectSchema] ? TValue extends (infer TElement)[] | undefined ? readonly [ValidObjectSchemaSpec] : never : TSchema extends Partial> | keyof typeof SpecialObjectSchemaSpec ? ValidObjectSchemaSpec : TSchema extends true ? IfPrimitive : TSchema extends (...args: any[]) => any ? TSchema : never; export type SchemaType = TSchema extends PrimitiveSchemaSpec ? PrimitiveQuerySchemaType : TSchema extends ObjectSchemaSpec ? ObjectSchemaType : TSchema extends ArraySchemaSpec ? TValue extends (infer TElement)[] | undefined ? ArraySchemaType : never : TSchema extends ExpressionSchemaSpec ? ExpressionSchemaType : never; export declare function createOperatorForSchema(schema: SchemaSpec, container: Expression | null): PipeOperator; export declare function querySchema>(schema: TSchema): TSchema extends ValidSchemaSpec ? PipeOperator> : Error<'Invalid schema. Use the SchemaFactory for a detailed error.'>; export {};