{"version":3,"file":"UploaderInterface.mjs","sources":["../../src/UploaderInterface.ts"],"sourcesContent":["import type { Amount } from './Amount';\nimport { InterfaceImplementationMissingError } from './errors';\nimport type { GenericAbortSignal } from './GenericAbortSignal';\nimport type { GenericFile } from './GenericFile';\n\n/**\n * Defines the interface for an uploader.\n * It allows us to upload files and get their URIs.\n *\n * @category Context and Interfaces\n */\nexport interface UploaderInterface {\n  /** Uploads multiple files and returns their URIs. */\n  upload: (\n    files: GenericFile[],\n    options?: UploaderUploadOptions\n  ) => Promise<string[]>;\n\n  /** Uploads a JSON object and returns its URI. */\n  uploadJson: <T>(json: T, options?: UploaderUploadOptions) => Promise<string>;\n\n  /** Gets the price to upload a list of files. */\n  getUploadPrice: (\n    files: GenericFile[],\n    options?: UploaderGetUploadPriceOptions\n  ) => Promise<Amount>;\n}\n\n/**\n * The options that can be passed when fetching the upload price.\n * @category Storage\n */\nexport type UploaderGetUploadPriceOptions = {\n  signal?: GenericAbortSignal;\n};\n\n/**\n * The options that can be passed when uploading files.\n * @category Storage\n */\nexport type UploaderUploadOptions = {\n  onProgress?: (percent: number, ...args: any) => void;\n  signal?: GenericAbortSignal;\n  manifest?: boolean;\n};\n\n/**\n * An implementation of the {@link UploaderInterface} that throws an error when called.\n * @category Storage\n */\nexport function createNullUploader(): UploaderInterface {\n  const errorHandler = () => {\n    throw new InterfaceImplementationMissingError(\n      'UploaderInterface',\n      'uploader'\n    );\n  };\n  return {\n    upload: errorHandler,\n    uploadJson: errorHandler,\n    getUploadPrice: errorHandler,\n  };\n}\n"],"names":["createNullUploader","errorHandler","InterfaceImplementationMissingError","upload","uploadJson","getUploadPrice"],"mappings":";;AA8CA;AACA;AACA;AACA;AACO,SAASA,kBAAkB,GAAsB;EACtD,MAAMC,YAAY,GAAG,MAAM;AACzB,IAAA,MAAM,IAAIC,mCAAmC,CAC3C,mBAAmB,EACnB,UAAU,CACX,CAAA;GACF,CAAA;EACD,OAAO;AACLC,IAAAA,MAAM,EAAEF,YAAY;AACpBG,IAAAA,UAAU,EAAEH,YAAY;AACxBI,IAAAA,cAAc,EAAEJ,YAAAA;GACjB,CAAA;AACH;;;;"}