import { FeatureType, SubscriptionStatus } from './graphql/generated/gqlTypes';

export type Consumption = {
  budget: number | null;
  used: number;
  overageEnabled: boolean;
};

export type Group = {
  id: string;
  name?: string | null;
  email?: string | null;
  metadata?: Record<string, unknown>;
};

export type Package = {
  id: string;
  name: string;
  isAddon: boolean;
  metadata?: Record<string, unknown>;
};

export type Entitlement = {
  access: boolean;
  reason: string;
  consumption?: Consumption;
};

export type Feature = {
  id: string;
  name: string;
  type: FeatureType;
  metadata?: Record<string, unknown>;
  unitLabel?: string | null;
  unitLabelPlural?: string | null;
};

export type PackageSubscription = {
  id: string;
  name?: string | null | undefined;
  email?: string | null | undefined;
  metadata?: Record<string, unknown> | null | undefined;
  subscriptions: Array<{
    status: SubscriptionStatus;
    package: {
      id: string;
      name: string;
      isAddon: boolean;
      metadata?: Record<string, unknown> | null | undefined;
      features: Array<{
        id: string;
        name: string;
        type: FeatureType;
        metadata?: Record<string, unknown> | null | undefined;
        consumption?:
          | {
              used: number;
              budget?: number | null | undefined;
              overageEnabled: boolean;
            }
          | null
          | undefined;
      }>;
    };
  }>;
};

export type RequestResult<T, E> = { data?: T; error?: E };
