export interface IRuntimeInventory {
  /**
   * Get schema for a given asset name and version
   */
  getSchema(
    name: string,
    version?: string
  ): any | undefined;

  /**
   * Get schema from destination for a given asset name and version
   */
  getSchemaFromDestination(
    name: string,
    version?: string
  ): any | undefined;

  /**
   * Get TypeScript definitions for a given asset name and version
   */
  getTypescript(
    name: string,
    version?: string
  ): Record<string, any> | undefined;

  /**
   * Get lint ruleset for a given asset name and version
   */
  getLintRuleset(
    name: string,
    version?: string
  ): Record<string, any> | undefined;

  /**
   * Get available policy sequence types
   */
  getPolicySequenceType(): { sequenceTypes: string[] } | undefined;

  /**
   * Get staged policies
   */
  getStagedPolicies():
    | Record<string, { stage: string; policies: PolicyInfo[] }>
    | undefined;

  /**
   * Get free-flow policies
   */
  getFreeFlowPolicies():
    | Record<string, { group: string; type: string; policies: PolicyInfo[] }>
    | undefined;

  /**
   * Get default version for a specific policy
   */
  getPolicyDefaultVersion(
    sequenceType: "staged" | "free-flow",
    groupName: string,
    policyName: string
  ): string | undefined;

  /**
   * Get the complete master content
   */
  getMasterContents(): MasterContent;

  /**
   * Get detailed information about a specific policy
   */
  getPolicyInfo(
    sequenceType: "staged" | "free-flow",
    groupName: string,
    policyName: string
  ):
    | {
      name: string;
      sequenceType: string;
      group: string;
      defaultVersion: string;
      policy: any;
    }
    | undefined;
    
  /**
   * Get the complete default versions mapping
   * @returns A record mapping kind names to their default API versions
   */
  getDefaultVersions(): Record<string, string>;
  
  /**
   * Get the list of required kinds
   * @returns An array of required kind names
   */
  getRequiredKinds(): string[];
  
  /**
   * Get the list of optional kinds
   * @returns An array of optional kind names
   */
  getOptionalKinds(): string[];
    
  /**
   * Extends or overrides the master content with custom data
   * @param customMasterContent - Custom master content to merge with existing data
   * @param overrideExisting - If true, will override existing entries; if false, will only add new entries
   */
  extendMasterContent(customMasterContent: Partial<MasterContent>, overrideExisting?: boolean): void;
  
  /**
   * Extends or overrides the schema definitions with custom schemas
   * @param customSchemas - Custom schemas to merge with existing schemas
   * @param overrideExisting - If true, will override existing schemas; if false, will only add new schemas
   */
  extendSchemaDefinitions(customSchemas: Record<string, any>, overrideExisting?: boolean): void;
  
  /**
   * Extends or overrides the default versions with custom default versions
   * @param customDefaultVersions - Custom default versions to merge with existing versions
   * @param overrideExisting - If true, will override existing versions; if false, will only add new versions
   */
  extendDefaultVersions(customDefaultVersions: Record<string, string>, overrideExisting?: boolean): void;
  
  /**
   * Extends or overrides the ruleset definitions with custom rulesets
   * @param customRulesets - Custom rulesets to merge with existing rulesets
   * @param overrideExisting - If true, will override existing rulesets; if false, will only add new rulesets
   */
  extendRulesetDefinitions(customRulesets: Record<string, any>, overrideExisting?: boolean): void;
  
  /**
   * Hook method for subclasses to provide overridden schema for a specific schema key
   * This is called automatically by getSchema() to check if there's an override
   * Extended classes can override this to provide custom schemas
   * @param schemaKey - The schema key (e.g., "api.ibm.com_v1_customkind.json")
   * @returns The overridden schema object or undefined if no override
   */
  getOverriddenSchema?(schemaKey: string): any | undefined;

  /**
   * Hook method for subclasses to provide overridden ruleset for a specific ruleset key
   * This is called automatically by getLintRuleset() to check if there's an override
   * Extended classes can override this to provide custom rulesets
   * @param rulesetKey - The ruleset key (e.g., "api.ibm.com_v1_customkind.ruleset.yaml")
   * @returns The overridden ruleset object or undefined if no override
   */
  getOverriddenRule?(rulesetKey: string): any | undefined;


}

export type PolicyInfo = {
  name: string;
  defaultVersion: string;
  type: "staged" | "free-flow";
};

export type AssetInfo = {
  kind: string;
  defautlVersion?: string;
};

export type StagedPolicyGroup = {
  key: string;
  label: string;
  assets: AssetInfo[];
};

export type MasterContent = {
  ["extension-key"]?: string;
  ["requiredKinds"]?: string[];
  ["optionalKinds"]?: string[];
  ["policy-sequences"]?: {
    staged?: StagedPolicyGroup[];
    ["free-flow"]?: Array<{
      name?: string;
      type: string;
      policies?: any[];
    }>;
  };
  [key: string]: any;
};
