export interface CreateOrganizationRequest {
  client_email: string;
  organization_name: string;
}

export interface CreateAppRequest {
  organization_apikey: string;
  app_name: string;
  tenancy_model: 'single' | 'multi';
}

export interface CreateAPIKeyRequest {
  organization_apikey: string;
  app_apikey?: string;      // Required for app and tenant keys
  tenant_apikey?: string;   // Required for tenant keys
  name: string;             // Name for the new API key
  type: 'organization' | 'app' | 'tenant';
}

export interface APIKeyResponse {
  key: string;              // Format: wt_{TYPE}_{16bsalt}{uuid} where TYPE is ORG, APP, or TEN
  type: 'organization' | 'app' | 'tenant';
  organization_id: string;  // Organization ID
  app_id?: string;         // App ID (for app and tenant keys)
  tenant_id?: string;      // Tenant ID (for tenant keys)
  name: string;            // Name of the API key
  status: 'active';
  created_at: string;      // ISO 8601 timestamp
  updated_at: string;      // ISO 8601 timestamp
}

export interface ErrorResponse {
  error: string;  // Error message
}

export interface CreateOrgKeyRequest {
  organization_id: string;  // Required - ID of existing organization
}

export interface CreateAppKeyRequest {
  app_name: string;        // Required - Name of the app
  tenancy_model: 'single' | 'multi';  // Required - App's tenancy model
}

export interface AppAPIKey {
  key: string; // Format: wt_APP_{16bsalt}{uuid}
  type: 'app';
  organization_id: string;
  app_id: string;
  name: string;
  status: 'active';
  created_at: string; // ISO 8601 timestamp
  updated_at: string; // ISO 8601 timestamp
}

export interface TenantAPIKey {
  key: string; // Format: wt_TNT_{16bsalt}{uuid}
  type: 'tenant';
  organization_id: string;
  app_id: string;
  tenant_id: string;
  name: string;
  status: 'active';
  created_at: string; // ISO 8601 timestamp
  updated_at: string; // ISO 8601 timestamp
}

export interface CreateTenantRequest {
  organization_apikey: string;
  app_apikey: string;
  client_email: string;
}

export interface RollAPIKeyRequest {
  current_apikey: string;
  type: 'organization' | 'app' | 'tenant';
}

export interface RolledAPIKey {
  key: string; // Format depends on type: wt_ORG_, wt_APP_, or wt_TNT_
  type: 'organization' | 'app' | 'tenant';
  organization_id: string;
  app_id?: string; // Optional, only for app and tenant keys
  tenant_id?: string; // Optional, only for tenant keys
  name: string;
  status: 'active';
  created_at: string; // ISO 8601 timestamp
  updated_at: string; // ISO 8601 timestamp
} 