// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";
package designcompose.live_update;

import "definition/design_compose_definition.proto";
import "live_update/figma/figma_doc.proto";

option java_multiple_files = true;
option java_package = "com.android.designcompose.live_update";
option optimize_for = LITE_RUNTIME;

// From Kotlin to Rust
message ConvertRequest {
  string figma_api_key = 1;
  // Node names
  repeated string queries = 2;
  // Ignored images
  repeated live_update.figma.IgnoredImage ignored_images = 3;
  // Last modified comes from the previously fetched document and is
  // used to avoid fetching the same doc version over and over.
  optional string last_modified = 4;
  // The version also comes from the previously fetched document. When certain
  // properties of a Figma doc like a new branch changes, the version gets
  // updated but the last_modified field does not.
  optional string version = 5;
  // Image session also comes from the previously fetched document. We allow
  // this
  // to fail decoding, in case we're receiving a request from a client that has
  // an image session generated by an old version.
  optional bytes image_session_json = 6;
}

// From Rust to Kotlin
message ConvertResponse {
  // Document contains the converted DesignCompose definition, the server Figma
  // document and the session id required to fetch images.
  message Document {
    // The DesignCompose definition header.
    definition.DesignComposeDefinitionHeader header = 1;
    // The server Figma document contains minimal information required by the
    // client to fetch images.
    live_update.figma.ServerFigmaDoc server_doc = 2;
    // Session id required by the client to fetch images.
    bytes image_session_json = 3;
  }

  oneof convert_response_type {
    Document document = 1;
    string unmodified = 2;
  }
}
