import { JsonPathExpression } from './jsonpath-expression-type.model';
import { NavOptionConfig } from './navigation-config.model';
import { ExpressionCondition, ConditionAdvanced } from '../pfe-conditions/public-api';
// This data model is basically only there for the configuration schema
// It leaves out attributes that do not have an effect and adds validation
// to the conditions.
/**
* The NavOptionErrorPageConfig is very similar to the NavOptionConfig.
* The only difference is, that it doesn't support updateStateValues and
* it uses slightly different types for the conditions, which support json-schema validation
* of the error specific condition paths.
*/
export interface NavOptionErrorPageConfig extends Pick<NavOptionConfig, Exclude<keyof NavOptionConfig, 'updateStateValues'>> {
// The documentation about the conditions is the same as in the ErrorCase
// It is partially duplicated here, so that it shows up everywhere in the json schema
/**
* The conditions to determine if a navigation to an error page should happen.
*
* They are similar to the NavOptionConfig conditions.
* But in difference to those, the state is only available under $.state in these conditions.
* The error response is available under $.response
* The response body for error responses is available under $.response.error
* The response headers under $.responseHeaders
*
* See also the data model for the data/state the JSONPath expressions run against:
* {@link ErrorCaseConditionsState}
* See also, the standard NavOptionConfig conditions:
* {@link NavOptionConfig#conditions}
*
* The errorPageNavigation:
* {@link PfeNavigationConfiguration.errorPageNavigation}
*/
conditions?: ConditionE[] | ConditionAdvancedE;
/**
* See: {@link NavOptionConfig#external}
*/
external?: boolean;
}
export interface ConditionAdvancedE extends ConditionAdvanced {
conditions: ConditionE[];
}
export interface ConditionE extends ExpressionCondition {
/**
* See: {@link ExpressionCondition#expression}
*
* @TJS-pattern ^(\$\.state\.|\$\.response\.|\$\.responseHeaders\.|(?!\$\.).)*$
*/
expression: JsonPathExpression | boolean | number;
}