syntax = "proto3";

package devvit.ui.effects.v1alpha;

import "devvit/ui/effect_types/v1alpha/app_permission.proto";
import "devvit/ui/effect_types/v1alpha/create_order.proto";
import "devvit/ui/effect_types/v1alpha/navigate_to_url.proto";
import "devvit/ui/effect_types/v1alpha/show_form.proto";
import "devvit/ui/effect_types/v1alpha/show_toast.proto";
import "devvit/ui/effects/v1alpha/interval.proto";
import "devvit/ui/effects/v1alpha/realtime_subscriptions.proto";
import "devvit/ui/effects/v1alpha/rerender_ui.proto";
import "devvit/ui/effects/web_view/v1alpha/web_view.proto";

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/ui/effects/v1alpha";
option java_package = "com.reddit.devvit.ui.effects.v1alpha";

enum EffectType {
  // Notify client to synchronize its realtime subscriptions
  EFFECT_REALTIME_SUB = 0;

  // Trigger a re-render for apps that have visible UI
  EFFECT_RERENDER_UI = 1;

  // Notify the client that parts of a subreddit, post, or comment should be reloaded
  EFFECT_RELOAD_PART = 2 [deprecated = true];

  // Display a user input form
  EFFECT_SHOW_FORM = 3;

  // Display a transient toast message
  EFFECT_SHOW_TOAST = 4;

  // Notify the client to navigate to a URL
  EFFECT_NAVIGATE_TO_URL = 5;

  // This updates the list of active timers.
  EFFECT_SET_INTERVALS = 7;

  // This starts a purchase flow
  EFFECT_CREATE_ORDER = 8;

  // Control and communicate with WebViews
  EFFECT_WEB_VIEW = 9;

  // Check if the app can execute some actions as the user
  EFFECT_CAN_RUN_AS_USER = 11;

  // Statistical data event for analytics.
  EFFECT_TELEMETRY = 12;

  // Request an updated signed request context
  EFFECT_UPDATE_REQUEST_CONTEXT = 13;

  // Send the screenshot response from web view to the client
  EFFECT_SCREENSHOT_RESPONSE = 14;

  // Request a login/signup prompt
  EFFECT_LOGIN_PROMPT = 15;
}

// Blocks only.
message Effect {
  option deprecated = true;
  oneof effect_type {
    RealtimeSubscriptionsEffect realtime_subscriptions = 1;
    RerenderEffect rerender_ui = 2;
    devvit.ui.effect_types.v1alpha.ShowFormEffect show_form = 4;
    devvit.ui.effect_types.v1alpha.ShowToastEffect show_toast = 5;
    devvit.ui.effect_types.v1alpha.NavigateToUrlEffect navigate_to_url = 6;
    SetIntervalsEffect interval = 9;
    devvit.ui.effect_types.v1alpha.CreateOrderEffect create_order = 10;
    devvit.ui.effects.web_view.v1alpha.WebViewEffect web_view = 11;
    devvit.ui.effect_types.v1alpha.CanRunAsUserEffect can_run_as_user = 13;
  }

  //TODO: remove this field once all clients are updated.  Redundant with effect_type
  EffectType type = 7;

  reserved "reload_part";
  reserved 3, 8;
}
