syntax = "proto3";
    option go_package = "./artifacts/academy-server/release-tsjs/modules/licenses";

import "artifacts/academy-server/release-tsjs/core/common.proto";
import "artifacts/academy-server/release-tsjs/modules/workspaces/index.proto";
import "artifacts/academy-server/release-tsjs/modules/currency/index.proto";




  

  

  
      
service ActivationKeys {
  rpc ActivationKeyActionCreate (ActivationKeyEntity) returns (ActivationKeyCreateReply) {}
  rpc ActivationKeyActionUpdate (ActivationKeyEntity) returns (ActivationKeyCreateReply) {}

  rpc ActivationKeyActionQuery (QueryFilterRequest) returns (ActivationKeyQueryReply) {}
  rpc ActivationKeyActionGetOne (QueryFilterRequest) returns (ActivationKeyReply) {}
  rpc ActivationKeyActionRemove (QueryFilterRequest) returns (RemoveReply) {}
}

message ActivationKeyCreateReply {
	ActivationKeyEntity data  = 1;
	IError error = 2;
}

message ActivationKeyReply {
	ActivationKeyEntity data = 1;
	IError error = 2;
}

message ActivationKeyQueryReply {
	repeated ActivationKeyEntity items = 1;
	int64 totalItems = 2;
	int64 itemsPerPage = 3;
	int64 startIndex = 4;
	IError error = 5;
}



;





 
message ActivationKeyEntity {
  optional string visibility = 1; // @tag(yaml:"visibility")
  optional string workspaceId = 2; // @tag(yaml:"workspaceId")
  optional string linkerId = 3; // @tag(yaml:"linkerId")
  optional string parentId = 4; // @tag(yaml:"parentId")
  string uniqueId = 5; // @tag(gorm:"primarykey;uniqueId;unique;not null;size:100;" yaml:"uniqueId")
  optional string userId = 6; // @tag(yaml:"userId")
  optional string series = 8; // @tag(  yaml:"series"  )

  int64 used = 9; // @tag(  yaml:"used"  )

  /* One 2 one to external entity */
  optional string planId  = 11; // @tag(yaml:"planId" )
  ProductPlanEntity plan = 12; // @tag(gorm:"foreignKey:PlanId;references:UniqueId" json:"plan" yaml:"plan")

  int64 rank = 13; // @tag(gorm:"type:int;name:rank")
  int64 updated = 14; // @tag(gorm:"autoUpdateTime:nano")
  int64 created = 15; // @tag(gorm:"autoUpdateTime:nano")
  string createdFormatted = 16; // @tag(sql:"-")
  string updatedFormatted = 17; // @tag(sql:"-")

}









/**
* Add your custom services, and messages here.
* It can be your dto for example. 
* - Use Module.yml for entities, otherwise it won't be managed
* - Don't use this file for entities might be queried by web
**/
      




  

  

  
      
service LicensableProducts {
  rpc LicensableProductActionCreate (LicensableProductEntity) returns (LicensableProductCreateReply) {}
  rpc LicensableProductActionUpdate (LicensableProductEntity) returns (LicensableProductCreateReply) {}

  rpc LicensableProductActionQuery (QueryFilterRequest) returns (LicensableProductQueryReply) {}
  rpc LicensableProductActionGetOne (QueryFilterRequest) returns (LicensableProductReply) {}
  rpc LicensableProductActionRemove (QueryFilterRequest) returns (RemoveReply) {}
}

message LicensableProductCreateReply {
	LicensableProductEntity data  = 1;
	IError error = 2;
}

message LicensableProductReply {
	LicensableProductEntity data = 1;
	IError error = 2;
}

message LicensableProductQueryReply {
	repeated LicensableProductEntity items = 1;
	int64 totalItems = 2;
	int64 itemsPerPage = 3;
	int64 startIndex = 4;
	IError error = 5;
}







 
message LicensableProductEntity {
  optional string visibility = 1; // @tag(yaml:"visibility")
  optional string workspaceId = 2; // @tag(yaml:"workspaceId")
  optional string linkerId = 3; // @tag(yaml:"linkerId")
  optional string parentId = 4; // @tag(yaml:"parentId")
  string uniqueId = 5; // @tag(gorm:"primarykey;uniqueId;unique;not null;size:100;" yaml:"uniqueId")
  optional string userId = 6; // @tag(yaml:"userId")
  repeated LicensableProductEntityPolyglot translations = 7; // @tag(gorm:"foreignKey:LinkerId;references:UniqueId" json:"translations")
  optional string name = 9; // @tag(translate:"true" validate:"required,omitempty,min=1,max=100" yaml:"name"  )

  optional string privateKey = 10; // @tag(  yaml:"privateKey"  )

  optional string publicKey = 11; // @tag(  yaml:"publicKey"  )

  int64 rank = 12; // @tag(gorm:"type:int;name:rank")
  int64 updated = 13; // @tag(gorm:"autoUpdateTime:nano")
  int64 created = 14; // @tag(gorm:"autoUpdateTime:nano")
  string createdFormatted = 15; // @tag(sql:"-")
  string updatedFormatted = 16; // @tag(sql:"-")

}

/* Because it has translation field, we need a translation table for this */
message LicensableProductEntityPolyglot {
  string linkerId = 1; // @tag(gorm:"uniqueId;not null;size:100;" json:"linkerId" yaml:"linkerId")
  string languageId = 2; // @tag(gorm:"uniqueId;not null;size:100;" json:"languageId" yaml:"languageId")

  string name = 3; // @tag(yaml:"name" json:"name");

}









/**
* Add your custom services, and messages here.
* It can be your dto for example. 
* - Use Module.yml for entities, otherwise it won't be managed
* - Don't use this file for entities might be queried by web
**/
      




  

  

  
      
service Licenses {
  rpc LicenseActionCreate (LicenseEntity) returns (LicenseCreateReply) {}
  rpc LicenseActionUpdate (LicenseEntity) returns (LicenseCreateReply) {}

  rpc LicenseActionQuery (QueryFilterRequest) returns (LicenseQueryReply) {}
  rpc LicenseActionGetOne (QueryFilterRequest) returns (LicenseReply) {}
  rpc LicenseActionRemove (QueryFilterRequest) returns (RemoveReply) {}
}

message LicenseCreateReply {
	LicenseEntity data  = 1;
	IError error = 2;
}

message LicenseReply {
	LicenseEntity data = 1;
	IError error = 2;
}

message LicenseQueryReply {
	repeated LicenseEntity items = 1;
	int64 totalItems = 2;
	int64 itemsPerPage = 3;
	int64 startIndex = 4;
	IError error = 5;
}




;





 
message LicenseEntity {
  optional string visibility = 1; // @tag(yaml:"visibility")
  optional string workspaceId = 2; // @tag(yaml:"workspaceId")
  optional string linkerId = 3; // @tag(yaml:"linkerId")
  optional string parentId = 4; // @tag(yaml:"parentId")
  string uniqueId = 5; // @tag(gorm:"primarykey;uniqueId;unique;not null;size:100;" yaml:"uniqueId")
  optional string userId = 6; // @tag(yaml:"userId")
  optional string name = 8; // @tag(  yaml:"name"  )

  optional string signedLicense = 9; // @tag(  yaml:"signedLicense"  )

  Timestamp validityStartDate = 10; // @tag( yaml:"validityStartDate")

  Timestamp validityEndDate = 11; // @tag( yaml:"validityEndDate")

  /* This is an object, another entity needs to be created for */
  /*repeated LicensePermissionEntity permissions = 12; // @tag(gorm:"foreignKey:LinkerId;references:UniqueId" yaml:"permissions")*/
  repeated LicensePermissionEntity permissions = 12; // @tag(gorm:"foreignKey:LinkerId;references:UniqueId" yaml:"permissions")

  int64 rank = 13; // @tag(gorm:"type:int;name:rank")
  int64 updated = 14; // @tag(gorm:"autoUpdateTime:nano")
  int64 created = 15; // @tag(gorm:"autoUpdateTime:nano")
  string createdFormatted = 16; // @tag(sql:"-")
  string updatedFormatted = 17; // @tag(sql:"-")

}









 
message LicensePermissionEntity {
  optional string visibility = 1; // @tag(yaml:"visibility")
  optional string workspaceId = 2; // @tag(yaml:"workspaceId")
  optional string linkerId = 3; // @tag(yaml:"linkerId")
  optional string parentId = 4; // @tag(yaml:"parentId")
  string uniqueId = 5; // @tag(gorm:"primarykey;uniqueId;unique;not null;size:100;" yaml:"uniqueId")
  optional string userId = 6; // @tag(yaml:"userId")
  /* One 2 one to external entity */
  optional string capabilityId  = 9; // @tag(yaml:"capabilityId" )
  CapabilityEntity capability = 10; // @tag(gorm:"foreignKey:CapabilityId;references:UniqueId" json:"capability" yaml:"capability")

  int64 rank = 11; // @tag(gorm:"type:int;name:rank")
  int64 updated = 12; // @tag(gorm:"autoUpdateTime:nano")
  int64 created = 13; // @tag(gorm:"autoUpdateTime:nano")
  string createdFormatted = 14; // @tag(sql:"-")
  string updatedFormatted = 15; // @tag(sql:"-")

}









/**
* Add your custom services, and messages here.
* It can be your dto for example. 
* - Use Module.yml for entities, otherwise it won't be managed
* - Don't use this file for entities might be queried by web
**/
      
message LicenseFromActivationKeyDto {
    string activationKeyId = 1;
    string machineId = 2;
}

message LicenseFromPlanIdDto {
    string machineId = 1;
    string email = 2;
    string owner = 3;
}



  

  

  
      
service ProductPlans {
  rpc ProductPlanActionCreate (ProductPlanEntity) returns (ProductPlanCreateReply) {}
  rpc ProductPlanActionUpdate (ProductPlanEntity) returns (ProductPlanCreateReply) {}

  rpc ProductPlanActionQuery (QueryFilterRequest) returns (ProductPlanQueryReply) {}
  rpc ProductPlanActionGetOne (QueryFilterRequest) returns (ProductPlanReply) {}
  rpc ProductPlanActionRemove (QueryFilterRequest) returns (RemoveReply) {}
}

message ProductPlanCreateReply {
	ProductPlanEntity data  = 1;
	IError error = 2;
}

message ProductPlanReply {
	ProductPlanEntity data = 1;
	IError error = 2;
}

message ProductPlanQueryReply {
	repeated ProductPlanEntity items = 1;
	int64 totalItems = 2;
	int64 itemsPerPage = 3;
	int64 startIndex = 4;
	IError error = 5;
}



;


;


;





 
message ProductPlanEntity {
  optional string visibility = 1; // @tag(yaml:"visibility")
  optional string workspaceId = 2; // @tag(yaml:"workspaceId")
  optional string linkerId = 3; // @tag(yaml:"linkerId")
  optional string parentId = 4; // @tag(yaml:"parentId")
  string uniqueId = 5; // @tag(gorm:"primarykey;uniqueId;unique;not null;size:100;" yaml:"uniqueId")
  optional string userId = 6; // @tag(yaml:"userId")
  repeated ProductPlanEntityPolyglot translations = 7; // @tag(gorm:"foreignKey:LinkerId;references:UniqueId" json:"translations")
  optional string name = 9; // @tag(translate:"true" validate:"required,omitempty,min=1,max=100" yaml:"name"  )

  int64 duration = 10; // @tag( validate:"required" yaml:"duration"  )

  /* One 2 one to external entity */
  optional string productId  = 12; // @tag(yaml:"productId" validate:"required")
  LicensableProductEntity product = 13; // @tag(gorm:"foreignKey:ProductId;references:UniqueId" json:"product" yaml:"product")

  /* One 2 one to external entity */
  optional string priceTagId  = 15; // @tag(yaml:"priceTagId" )
  PriceTagEntity priceTag = 16; // @tag(gorm:"foreignKey:PriceTagId;references:UniqueId" json:"priceTag" yaml:"priceTag")

  /* This is an object, another entity needs to be created for */
  /*repeated ProductPlanPermissionEntity permissions = 17; // @tag(gorm:"foreignKey:LinkerId;references:UniqueId" yaml:"permissions")*/
  repeated ProductPlanPermissionEntity permissions = 17; // @tag(gorm:"foreignKey:LinkerId;references:UniqueId" yaml:"permissions")

  int64 rank = 18; // @tag(gorm:"type:int;name:rank")
  int64 updated = 19; // @tag(gorm:"autoUpdateTime:nano")
  int64 created = 20; // @tag(gorm:"autoUpdateTime:nano")
  string createdFormatted = 21; // @tag(sql:"-")
  string updatedFormatted = 22; // @tag(sql:"-")

}

/* Because it has translation field, we need a translation table for this */
message ProductPlanEntityPolyglot {
  string linkerId = 1; // @tag(gorm:"uniqueId;not null;size:100;" json:"linkerId" yaml:"linkerId")
  string languageId = 2; // @tag(gorm:"uniqueId;not null;size:100;" json:"languageId" yaml:"languageId")

  string name = 3; // @tag(yaml:"name" json:"name");

}









 
message ProductPlanPermissionEntity {
  optional string visibility = 1; // @tag(yaml:"visibility")
  optional string workspaceId = 2; // @tag(yaml:"workspaceId")
  optional string linkerId = 3; // @tag(yaml:"linkerId")
  optional string parentId = 4; // @tag(yaml:"parentId")
  string uniqueId = 5; // @tag(gorm:"primarykey;uniqueId;unique;not null;size:100;" yaml:"uniqueId")
  optional string userId = 6; // @tag(yaml:"userId")
  /* One 2 one to external entity */
  optional string capabilityId  = 9; // @tag(yaml:"capabilityId" )
  CapabilityEntity capability = 10; // @tag(gorm:"foreignKey:CapabilityId;references:UniqueId" json:"capability" yaml:"capability")

  int64 rank = 11; // @tag(gorm:"type:int;name:rank")
  int64 updated = 12; // @tag(gorm:"autoUpdateTime:nano")
  int64 created = 13; // @tag(gorm:"autoUpdateTime:nano")
  string createdFormatted = 14; // @tag(sql:"-")
  string updatedFormatted = 15; // @tag(sql:"-")

}









/**
* Add your custom services, and messages here.
* It can be your dto for example. 
* - Use Module.yml for entities, otherwise it won't be managed
* - Don't use this file for entities might be queried by web
**/
      


