// flynt-disable missing-extensible, missing-string-validations

syntax = "proto3";

package wix.devcenter.apps.versions.v1;
option java_package = "com.wixpress.devcenter.apps.versions.v1";

import "google/protobuf/wrappers.proto";
import "wix/api/validations.proto";
import "wix/api/entity.proto";
import "wix/api/annotations.proto";
import "google/protobuf/timestamp.proto";

/**
  AppVersion is the main entity of AppVersionsService that can be used for lorem ipsum dolor
 */
message AppVersion {
  option (.wix.api.entity) = {
    fqdn: "wix.devcenter.apps.v1.app_version"
    segment: PUBLIC
    app_def_id: "8fbc00c7-a53f-485c-8972-2ea50e2bfda0"
    appendix_files: {
      type: DOCS_CONF
      path: "appendices/docs"
    };
    domain_events: {
      updated_include_modified_fields: true
    };
  };
  string id = 1 [(.wix.api.format) = GUID]; // Application ID
  int32 version = 2 [(wix.api.readOnly) = true]; // app version
  State state = 3 [(wix.api.readOnly) = true]; // indicates if this is the draft instance of the version.
  google.protobuf.Int64Value revision = 4; // Represents the current state of an item. Each time the item is modified, its `revision` changes. for an update operation to succeed, you MUST pass the latest revision
  Components components = 5; // id+version of components
  AppPermissions app_permissions = 6; // The permissions of the app
  AppDependencies app_dependencies = 7 [deprecated = true, (.wix.api.field_deprecated) = {
    replaced_by: "app_dependency_version"
    target_removal_date: "2026-03-31"
  }]; // The old deprecated dependencies of the app.
  Status status = 8; // Status of the app
  Metadata metadata = 9; // Metadata of the app
  google.protobuf.Timestamp created_date = 10 [(wix.api.readOnly) = true]; // Represents the time this version was created
  google.protobuf.Timestamp updated_date = 11 [(wix.api.readOnly) = true]; // Represents the time version App was last updated
  google.protobuf.StringValue full_version = 12 [(wix.api.readOnly) = true]; // Represents the full version (major.minor.build) of the version. Only applicable for State = LOCKED_DRAFT / PRODUCTION
  google.protobuf.Int64Value app_dependency_version = 13; // The new dependencies of the app.

}

// metadata contains unversioned data.
message Metadata {
  string account_id = 1 [(wix.api.readOnly) = true, (.wix.api.format) = GUID, (.wix.api.referenced_entity) = "wix.identity.account.v1.account"]; // The account that own this app
}

enum Status {
  UNKNOWN = 0;
  DEPRECATED = 1;
  ARCHIVED = 2;
}

enum State {
  UNKNOWN_STATE = 0;
  UNLOCKED_DRAFT = 1;
  LOCKED_DRAFT = 2;
  PRODUCTION = 3;
}

message Components {
  option (.wix.api.unwrap_array_value) = true;
  repeated VersionedComponent versioned_component = 1 [(.wix.api.maxSize) = 330]; // List of component (id version) this app version contains
}

message VersionedComponent {
  string id = 1 [(.wix.api.format) = GUID];
  int32 version = 2; // The version of the component
}

message AppDependencies {
  option (.wix.api.unwrap_array_value) = true;
  repeated DependencyData dependencies = 1 [(.wix.api.maxSize) = 100]; // List of app dependencies of the app version
}

message DependencyData {
  string app_id = 1 [(wix.api.format) = GUID]; // app id
  int32 version = 2; // the version of the dependent app
  bool direct = 3; // is the dependency direct
}

message AppPermissions {
  option (.wix.api.unwrap_array_value) = true;
  repeated string permissions = 1 [(.wix.api.maxSize) = 700, (wix.api.maxLength) = 164]; // List of the permissions of the app version
}

message AppDraftChangedEvent {
  string app_id = 1 [(wix.api.format) = GUID]; // app id
  google.protobuf.Timestamp updated_date = 2; // Represents the time the draft was last updated
  google.protobuf.Int32Value version = 3; // Represents the version that changed. empty when latest draft
}
