// {{ model_name }} gRPC service definition.
//
// ⚠️ AUTO-GENERATED BY PRISM - DO NOT EDIT

syntax = "proto3";

package {{ proto_package }};

option python_package = "{{ python_package }}";

import "google/protobuf/timestamp.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";

// ---------- Messages ----------

message {{ model_name }} {
    int64 id = 1;
{% for field in proto_fields %}
    {{ field.proto_type }} {{ field.name }} = {{ field.number }};
{% endfor %}
{% if has_timestamps %}
    google.protobuf.Timestamp created_at = {{ ts_created_number }};
    google.protobuf.Timestamp updated_at = {{ ts_updated_number }};
{% endif %}
}

message {{ model_name }}CreateRequest {
{% for field in create_fields %}
    {{ field.proto_type }} {{ field.name }} = {{ field.number }};
{% endfor %}
}

message {{ model_name }}UpdateRequest {
    int64 id = 1;
{% for field in update_fields %}
    {{ field.proto_type }} {{ field.name }} = {{ field.number }};
{% endfor %}
}

message {{ model_name }}GetRequest {
    int64 id = 1;
}

message {{ model_name }}DeleteRequest {
    int64 id = 1;
}

message {{ model_name }}DeleteResponse {
    bool success = 1;
}

message {{ model_name }}ListRequest {
    int32 skip = 1;
    int32 limit = 2;
}

message {{ model_name }}ListResponse {
    repeated {{ model_name }} items = 1;
    int64 total = 2;
}

message {{ model_name }}WatchRequest {
    // Optional: filter to specific event types
    repeated string event_types = 1;
}

message {{ model_name }}Event {
    string event_type = 1;
    int64 entity_id = 2;
    {{ model_name }} entity = 3;
}

// ---------- Service ----------

service {{ service_name }} {
{% if ops_read %}
    rpc Get{{ model_name }} ({{ model_name }}GetRequest) returns ({{ model_name }});
{% endif %}
{% if ops_list %}
    rpc List{{ model_name }}s ({{ model_name }}ListRequest) returns ({{ model_name }}ListResponse);
{% endif %}
{% if ops_create %}
    rpc Create{{ model_name }} ({{ model_name }}CreateRequest) returns ({{ model_name }});
{% endif %}
{% if ops_update %}
    rpc Update{{ model_name }} ({{ model_name }}UpdateRequest) returns ({{ model_name }});
{% endif %}
{% if ops_delete %}
    rpc Delete{{ model_name }} ({{ model_name }}DeleteRequest) returns ({{ model_name }}DeleteResponse);
{% endif %}
{% if streaming_methods %}
    // Server-streaming: watch for real-time events
    rpc Watch{{ model_name }} ({{ model_name }}WatchRequest) returns (stream {{ model_name }}Event);
{% endif %}
{% if ops_list and streaming_methods %}
    // Server-streaming: stream all records
    rpc Stream{{ model_name }}s ({{ model_name }}ListRequest) returns (stream {{ model_name }});
{% endif %}
{% if bidirectional_streaming %}
    // Bidirectional streaming: real-time sync
    rpc Sync{{ model_name }} (stream {{ model_name }}Event) returns (stream {{ model_name }}Event);
{% endif %}
}
