syntax = "proto3";

package golem.component;

import "golem/common/uuid.proto";
import "golem/common/account_id.proto";
import "golem/common/empty.proto";
import "golem/component/component_id.proto";
import "golem/common/project_id.proto";

message PluginId {
  golem.common.UUID value = 1;
}

message PluginDefinitionCreation {
  string name = 1;
  string version = 2;
  string description = 3;
  bytes icon = 4;
  string homepage = 5;
  golem.component.PluginTypeSpecificDefinition specs = 6;
  golem.component.PluginScope scope = 7;
}

message PluginDefinition {
  golem.component.PluginId id = 1;
  string name = 2;
  string version = 3;
  string description = 4;
  bytes icon = 5;
  string homepage = 6;
  golem.component.PluginTypeSpecificDefinition specs = 7;
  golem.component.PluginScope scope = 8;
  golem.common.AccountId account_id = 9;
  bool deleted = 10;
}

message PluginScope {
  oneof scope {
    golem.common.Empty global = 1;
    golem.component.ComponentPluginScope component = 2;
    ProjectPluginScope project = 3;
  }
}

message ComponentPluginScope {
  golem.component.ComponentId component_id = 1;
}

message ProjectPluginScope {
  golem.common.ProjectId project_id = 1;
}

message PluginTypeSpecificDefinition {
  oneof definition {
    ComponentTransformerDefinition component_transformer = 1;
    OplogProcessorDefinition oplog_processor = 2;
    LibraryPluginDefinition library = 3;
    AppPluginDefinition app = 4;
  }
}

message ComponentTransformerDefinition {
  optional string provided_wit_package = 1;
  optional string json_schema = 2;
  string validate_url = 3;
  string transform_url = 4;
}

message OplogProcessorDefinition {
  golem.component.ComponentId component_id = 1;
  uint64 component_version = 2;
}

message LibraryPluginDefinition {
  string blob_storage_key = 1;
}

message AppPluginDefinition {
  string blob_storage_key = 1;
}
