// Customer is fraser's top-level tenant -- the IA-parity public surface
// for the existing `customers` table that fraser's admin.v1 / Drizzle
// layer already owns. Resource shape mirrors ia.tenancy.v1.Customer.
syntax = "proto3";

package tars.tenancy.v1;

import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/tetrateio/fraser/api/tars/tenancy/v1;tenancyv1";

// CustomerState is the lifecycle of a customer record. ARCHIVED is the
// soft-deleted state -- the row stays in customers with deleted_at set.
enum CustomerState {
  CUSTOMER_STATE_UNSPECIFIED = 0;
  CUSTOMER_STATE_ACTIVE = 1;
  CUSTOMER_STATE_ARCHIVED = 2;
}

// Customer mirrors ia.tenancy.v1.Customer with fraser-shaped fields.
// `customer_id` is the operator-scoped slug (e.g. "acme") -- the
// natural key callers use everywhere. `id` is the server-assigned uuid
// row key.
message Customer {
  // Server-assigned uuid row id. Output-only.
  string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Operator-scoped slug used in CLI and URLs (e.g. "acme"). Required
  // on create; immutable thereafter.
  string customer_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Human-friendly display name.
  string display_name = 3;

  // Freeform description.
  string description = 4;

  // Lifecycle state.
  CustomerState state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Freeform labels for filtering / grouping.
  map<string, string> labels = 6;

  // When the customer row was created. Output-only.
  google.protobuf.Timestamp created_at = 50 [(google.api.field_behavior) = OUTPUT_ONLY];
  // When the customer row was last modified. Output-only.
  google.protobuf.Timestamp updated_at = 51 [(google.api.field_behavior) = OUTPUT_ONLY];
  // When the customer was archived (soft-deleted, state ARCHIVED); unset
  // while active. Maps to the row's deleted_at. Output-only.
  google.protobuf.Timestamp archived_at = 52 [(google.api.field_behavior) = OUTPUT_ONLY];
}
