declare module "univer:sac/facade-migration-pack" {
  interface FacadeMigrationPack {
    readonly id: string;
    readonly title: string;
    readonly appliesAfter: string | null;
    readonly files: readonly string[];
    readonly [key: string]: unknown;
  }

  interface SheetMigrationContext {
    readonly file: string;
    readonly pack: FacadeMigrationPack;
    readonly primarySheet: import("@univerjs/sheets/facade").FWorksheet;
    readonly sheet: import("@univerjs/sheets/facade").FWorksheet;
    readonly range?: import("@univerjs/sheets/facade").FRange;
    readonly univerAPI: import("@univerjs/core/facade").FUniver;
    readonly workbook: import("@univerjs/sheets/facade").FWorkbook;
  }

  interface SheetMigration {
    readonly sheet: {
      readonly id: string;
      readonly name: string;
      readonly create?: boolean;
    };
    readonly apply: (context: SheetMigrationContext) => void | Promise<void>;
    readonly [key: string]: unknown;
  }

  interface FacadeMigrationModule {
    readonly pack: FacadeMigrationPack;
    readonly sheetMigrations: readonly SheetMigration[];
  }

  function defineFacadeMigrationPack<T extends FacadeMigrationPack>(pack: T): T;
  function defineSheetMigration<T extends SheetMigration>(migration: T): T;
}

declare module "univer:sac/assertions" {
  type AssertionMatrix = readonly (readonly unknown[])[];

  interface AssertionSheetBuilder {
    exists(): void;
    usedRange(expectedA1: string): void;
  }

  interface AssertionRangeBuilder {
    values(expected: AssertionMatrix): void;
    formula(expected: string): void;
    formulas(expected: AssertionMatrix): void;
  }

  interface AssertionHelpers {
    sheet(name: string): AssertionSheetBuilder;
    range(targetA1: string): AssertionRangeBuilder;
  }

  interface AssertionSuite {
    readonly __sacAssertionSuite: true;
  }

  function defineAssertions(
    register: (helpers: AssertionHelpers) => void | Promise<void>
  ): AssertionSuite;
}
