import { RelationSide, RootEntityType } from '../model'; import { QueryNode } from './base'; export interface QueryResultValidatorFunctionProvider { /** * Gets a unique name for this validator function * @returns {string} */ getValidatorName(): string; /** * Gets the validation function * * The may be serialized and transported to a different JavaScript engine, so it should work stand-alone and not * rely on any libraries. * * The actual arguments for the function are the result of getValidatorData() and the value of the result variable. */ getValidatorFunction(): (validationData: any, result: any) => void; } /** * Specifies how a value should be validated * * This can be used in a PreExecQueryNode. It will be evaluated on its result variable. If the validator reports an * error, the whole transaction is cancelled. */ export interface QueryResultValidator extends QueryNode { /** * The name of the validator function (QueryResultValidatorFunctionProvider), which should be present in * ALL_QUERY_RESULT_VALIDATOR_FUNCTION_PROVIDERS */ getValidatorName(): string; /** * Optional data to be passed to the validator function */ getValidatorData(): any; } export interface ValidatorParams { readonly errorMessage: string; readonly errorCode?: string; } /** * A validator that verifies that a value is truthy */ export declare class ErrorIfNotTruthyResultValidator extends QueryNode implements QueryResultValidator { readonly errorMessage: string; readonly errorCode?: string; constructor(params: ValidatorParams); static getValidatorFunction(): (validationData: any, result: any) => void; static getValidatorName(): string; getValidatorName(): string; getValidatorData(): { errorMessage: string; errorCode: string | undefined; }; describe(): string; } /** * Validates that a TransformListQueryNode does not resolve to fewer elements * than expected. This can happen when an implicit query/mutation limit is applied * to the TransformListQueryNode but more elements are available in the collection. * * In this case a helpful error message should be returned to the consumer so that * a manual query limit can be applied. */ export declare class NoImplicitlyTruncatedListValidator extends QueryNode implements QueryResultValidator { private readonly maximumExpectedNumberOfItems; private readonly operation; constructor(maximumExpectedNumberOfItems: number, operation: string); static getValidatorFunction(): (validationData: any, result: any) => void; static getValidatorName(): string; getValidatorName(): string; getValidatorData(): { maximumExpectedNumberOfItems: number; operation: string; tooManyObjectsError: string; }; describe(): string; } /** * A validator that verifies that a value is neither falsy nor empty (works for both strings and lists) */ export declare class ErrorIfEmptyResultValidator extends QueryNode implements QueryResultValidator { readonly errorMessage: string; readonly errorCode?: string; constructor(params: ValidatorParams); static getValidatorFunction(): (validationData: any, result: any) => void; static getValidatorName(): string; getValidatorName(): string; getValidatorData(): { errorMessage: string; errorCode: string | undefined; }; describe(): string; } export interface NoRestrictingObjectsOnDeleteValidatorParams { readonly restrictedRootEntityType: RootEntityType; readonly restrictingRootEntityType: RootEntityType; readonly path: ReadonlyArray; } interface NoRestrictingObjectsOnDeleteValidatorData { readonly restrictedTypeName: string; readonly restrictingTypeName: string; readonly path: string; } /** * A validator that verifies that a list is empty, and if it's not, it reports them as restring a delete operation */ export declare class NoRestrictingObjectsOnDeleteValidator extends QueryNode implements QueryResultValidator { readonly data: NoRestrictingObjectsOnDeleteValidatorData; constructor(params: NoRestrictingObjectsOnDeleteValidatorParams); static getValidatorFunction(): (validationData: NoRestrictingObjectsOnDeleteValidatorData, result: ReadonlyArray) => void; static getValidatorName(): string; getValidatorName(): string; getValidatorData(): NoRestrictingObjectsOnDeleteValidatorData; describe(): string; } export declare const ALL_QUERY_RESULT_VALIDATOR_FUNCTION_PROVIDERS: ReadonlyArray; export {};