syntax = "proto3";

package com.wixpress.roles.management.api;

import "google/protobuf/wrappers.proto";
import "users.proto";
import "google/protobuf/timestamp.proto";
import "wix/api/annotations.proto";
import "wix/api/entity.proto";
import "wix/api/validations.proto";

message PeopleResource {
    oneof resource_type {
        string site = 1;
        FolderResource folder = 2;
    }
}

message FolderResource {
    string folder_id = 1;
    string folder_full_path = 2;
}

message People {
    repeated Person people = 1;
    int32 total_people = 2;
}

message Person {
    oneof person {
        Contributor contributor = 1;
        TeamMember team_member = 2;
    }
}

message Contributor {
    option (.wix.api.entity) = {
        fqdn: "wix.identity.v1.contributor"
        appendix_files: {
            type: AUTO_VELO
            path: "appendices/velo/contributor"
        }
        appendix_files: {
            type: DOCS_CONF
            path: "appendices/docs"
        }
        segment: USERS
    };
    // Contributor's metadata.
    PersonMetaData meta_data = 1;
    // Whether the contributor account is a team account.
    google.protobuf.BoolValue is_team = 2;
    // Date that the contributor joined the site.
    google.protobuf.Timestamp joined_at = 3;
    // Email address that received the invite.
    google.protobuf.StringValue invited_email = 4 [(wix.api.pii) = true];
    // Whether the contributor account is a client account. 
    google.protobuf.BoolValue is_client = 5;
    // Contributor's user ID.
    string id = 6 [(wix.api.format) = GUID, (wix.api.readOnly) = true];
    // A set of capability keys representing the actions that the caller is allowed
    // to perform on this specific contributor. This field is calculated based on the
    // identity of the request sender and may differ between callers.
    repeated string caller_capabilities = 7 [(wix.api.maxSize) = 20, (wix.api.maxLength ) = 20];
}

message ContributorV2 {
    // Contributor's account ID.
    google.protobuf.StringValue account_id = 1;
    // User ID of the owner of the account that the contributor has joined.
    google.protobuf.StringValue account_owner_id = 2;
}

message TeamMember {
    PersonMetaData meta_data = 1;
}

message PersonMetaData {
    // Contributor's account ID.
    string id = 1;
    // Contributor's full name.
    google.protobuf.StringValue full_name = 2 [(wix.api.pii) = true];
    // URL for contributor's profile image.
    google.protobuf.StringValue image_url = 3;
    // Contributor's email address.
    google.protobuf.StringValue email = 4 [(wix.api.pii) = true];
    // Contributor's access to assets and their assigned role (`policy`) for that asset.
    repeated Assignment assignments = 5;
}

enum PeopleType {
    UNDEF_PEOPLE_TYPE = 0;
    CONTRIBUTOR = 1;
    TEAM_MEMBER = 2;
}
;