{"version":3,"file":"validator-types.cjs","sourceRoot":"","sources":["../../src/manifest/validator-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Promisable } from '../promise';\nimport type {\n  ExtendableManifest,\n  ExtendableSnapFiles,\n  UnvalidatedSnapFiles,\n} from '../types';\n\nexport type ValidatorFix = (files: {\n  manifest: ExtendableManifest;\n}) => Promisable<{ manifest: ExtendableManifest }>;\n\n/**\n * The options for the validator context.\n */\nexport type ValidatorContextOptions = {\n  /**\n   * An object containing the names of the handlers and their respective\n   * permission name. This must be provided to avoid circular dependencies\n   * between `@metamask/snaps-utils` and `@metamask/snaps-rpc-methods`.\n   */\n  handlerEndowments?: Record<string, string | null>;\n\n  /**\n   * Exports detected by evaluating the bundle. This may be used by one or more\n   * validators to determine whether the snap is valid.\n   */\n  exports?: string[];\n};\n\nexport type ValidatorSeverity = 'error' | 'warning';\n\nexport type ValidatorContext = {\n  readonly report: (id: string, message: string, fix?: ValidatorFix) => void;\n  readonly options?: ValidatorContextOptions;\n};\n\nexport type ValidatorReport = {\n  id: string;\n  severity: ValidatorSeverity;\n  message: string;\n  fix?: ValidatorFix;\n};\n\nexport type ValidatorMeta = {\n  severity: ValidatorSeverity;\n\n  /**\n   * 1. Run the validator on unverified files to ensure that the files are\n   * structurally sound.\n   *\n   * @param files - Files to be verified\n   * @param context - Validator context to report errors\n   */\n  structureCheck?: (\n    files: UnvalidatedSnapFiles,\n    context: ValidatorContext,\n  ) => void | Promise<void>;\n\n  /**\n   * 2. Run the validator after the files were checked to be structurally sound.\n   *\n   * @param files - Files to be verified\n   * @param context - Validator context to report errors\n   */\n  semanticCheck?: (\n    files: ExtendableSnapFiles,\n    context: ValidatorContext,\n  ) => void | Promise<void>;\n};\n"]}