/// <summary> /// Configures the plugin for a real time read /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <ConfigureRealTimeResponse> ConfigureRealTime(ConfigureRealTimeRequest request, ServerCallContext context) { Logger.Info("Configuring real time..."); var schemaJson = Read.GetSchemaJson(); var uiJson = Read.GetUIJson(); // if subquery exists then throw unsupported feature error if (Regex.IsMatch(request.Schema.Query, @"\( *[Ss][Ee][Ll][Ee][Cc][Tt]")) { return(Task.FromResult(new ConfigureRealTimeResponse { Form = new ConfigurationFormResponse { DataJson = request.Form.DataJson, DataErrorsJson = "", Errors = { "Schemas with relationship queries are not supported for real time reads at this time." }, SchemaJson = schemaJson, UiJson = uiJson, StateJson = request.Form.StateJson, } })); } // if first call if (string.IsNullOrWhiteSpace(request.Form.DataJson) || request.Form.DataJson == "{}") { return(Task.FromResult(new ConfigureRealTimeResponse { Form = new ConfigurationFormResponse { DataJson = request.Form.DataJson, DataErrorsJson = "", Errors = { }, SchemaJson = schemaJson, UiJson = uiJson, StateJson = request.Form.StateJson, } })); } // TODO: Enhancement - Validate if the passed in channel name is valid and covers all the properties of the schema return(Task.FromResult(new ConfigureRealTimeResponse { Form = new ConfigurationFormResponse { DataJson = request.Form.DataJson, DataErrorsJson = "", Errors = { }, SchemaJson = schemaJson, UiJson = uiJson, StateJson = request.Form.StateJson, } })); }
/// <summary> /// Configures the plugin for a real time read /// </summary> /// <param name="request"></param> /// <param name="context"></param> /// <returns></returns> public override Task <ConfigureRealTimeResponse> ConfigureRealTime(ConfigureRealTimeRequest request, ServerCallContext context) { Logger.Info("Configuring real time..."); var schemaJson = Read.GetSchemaJson(); var uiJson = Read.GetUIJson(); // if first call if (string.IsNullOrWhiteSpace(request.Form.DataJson) || request.Form.DataJson == "{}") { return(Task.FromResult(new ConfigureRealTimeResponse { Form = new ConfigurationFormResponse { DataJson = request.Form.DataJson, DataErrorsJson = "", Errors = { }, SchemaJson = schemaJson, UiJson = uiJson, StateJson = request.Form.StateJson, } })); } return(Task.FromResult(new ConfigureRealTimeResponse { Form = new ConfigurationFormResponse { DataJson = request.Form.DataJson, DataErrorsJson = "", Errors = { }, SchemaJson = schemaJson, UiJson = uiJson, StateJson = request.Form.StateJson, } })); }