syntax = "proto3";

package wix.devcenter.apps.components.enricher;

import "wix/spi/definitions.proto";
import "wix/api/validations.proto";
import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "google/protobuf/wrappers.proto";
import "wix/devcenter/apps/components/v1/component.proto";
import "wix/devcenter/apps/components/enricher/component_enricher_config.proto";
import "wix/common/spi.proto";
import "wix/devcenter/apps/components/enricher/upstream/wix/common/bulk.proto";

service ComponentEnricher {
  option (.wix.spi.service) = {
    spi_identifier: "com.wixpress.appservice.api.ComponentType.COMPONENT_ENRICHER_PROVIDER"
    config_message: "wix.devcenter.apps.components.enricher.ComponentEnricherConfig",
    host_service: "wix.devcenter.apps.components.v1.ComponentsService",
    fqdn: "wix.interfaces.component_enricher.v1.enricher_provider",
    app_id: "9de1f02b-cfe9-4ff1-a016-c5e270977576"
  };

  // Enrich components before create/edit
  rpc EnrichComponents (EnrichComponentsRequest) returns (EnrichComponentsResponse) {
    option (.google.api.http).post = "/v1/enrich-components";
  };
}

message EnrichComponentsRequest {
  // components that have been created or have been modified
  repeated wix.devcenter.apps.components.v1.Component components = 1 [(.wix.api.maxSize) = 100];
  // ID of the relevant ComponentsOverride
  google.protobuf.StringValue components_override_id = 2 [(wix.api.maxLength) = 50];
}

message EnrichComponentsResponse {
  // The results
  repeated ComponentEnrichResult results = 1;
  // Bulk request metadata
  wix.devcenter.apps.components.enricher.upstream.wix.common.BulkActionMetadata bulk_action_metadata = 2;
}

message ComponentEnrichResult {
  // the enriched component
  wix.devcenter.apps.components.v1.Component enriched_component = 1;
  // result metadata
  wix.devcenter.apps.components.enricher.upstream.wix.common.ItemMetadata item_metadata = 2;
}