syntax = "proto3";

package devvit.dev_portal.app_version.info;

import "devvit/dev_portal/nutrition/nutrition.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

option go_package = "github.snooguts.net/reddit/reddit-devplatform-monorepo/go-common/generated/protos/types/devvit/devportal/appversion/info";

// This exists in its own file to prevent circular dependency imports between
// app_version and installation.

// region Enums

enum VersionVisibility {
  PUBLIC = 0;
  PRIVATE = 1;
  UNLISTED = 2;
}

enum BuildStatus {
  BUILDING = 0;
  READY = 1;
  FAILED = 2;
}

enum InstallationType {
  USER = 0;
  SUBREDDIT = 1;
  SUBREDDIT_GLOBAL = 2;
}

enum ComputePool {
  LOW = 0;
  MEDIUM = 1 [deprecated = true];
  HIGH = 2;
  RESTRICTED = 3;
  INTERNAL = 4;
  BETA = 5;
}

// endregion

message OptionalVersionVisibility {
  VersionVisibility value = 1;
}

// Contains the details of an app version. For field documentation, refer to the Prisma schema.
message AppVersionInfo {
  string id = 1;
  VersionVisibility visibility = 2;
  reserved 3;
  repeated InstallationType valid_install_types = 4;

  int32 major_version = 5;
  int32 minor_version = 6;
  int32 patch_version = 7;
  google.protobuf.Int32Value prerelease_version = 8;

  google.protobuf.Timestamp uploaded_at = 9;
  BuildStatus build_status = 10;
  google.protobuf.Timestamp built_at = 11;

  string about = 12;
  bool has_custom_settings = 13;
  ComputePool pool = 14;
  reserved 15; // removed

  // Abstract plugin capabilities used by the target app version
  repeated devvit.dev_portal.nutrition.NutritionCategory app_capabilities = 16;

  // Devvit API version of this app version (e.g. "1.0.0")
  optional string public_api_version = 17;

  AppVersionMarketingInfo marketing_info = 18;

  // Indicates whether the app version has a devvit.json file.
  bool has_devvit_json = 19;

  // Contains any information.
  SourceUploadInfo source_upload_info = 20;
}

message SourceUploadInfo {
  // The URL to upload the source code archive to. Only populated in response to
  // app version creation requests; will be omitted in all other contexts.
  optional string upload_url = 1;
  // Any headers that need to be included in the upload request. Will be blank unless
  // upload_url is truthy.
  map<string, string> required_headers = 2;
  // The S3 object key where the source code archive will be stored. Useful for
  // determining if a version should have a source code archive associated with it,
  // as well as for downloading it later.
  optional string s3_object_key = 3;
}

// Contains marketing information about an app version, such as its icon.
message AppVersionMarketingInfo {
  // Reddit-hosted URL for the app version's icon, OR in the case of uploading a new app version,
  // the UUID of the media asset to use as the icon.
  optional string icon = 1;
  // pssst, there's more coming later
}
