1 /* eslint-disable max-classes-per-file */
3 export enum TransferState {
4 Initializing = 'initializing',
7 SignatureIssue = 'signatureIssue',
8 ScanIssue = 'scanIssue',
10 Finalizing = 'finalizing',
13 Canceled = 'canceled',
15 NetworkError = 'networkError',
19 export interface TransferProgresses {
23 export interface TransferMeta {
29 export interface TransferSummary {
34 export class TransferCancel extends Error {
35 constructor(options: { id: string } | { message: string }) {
36 super('id' in options ? `Transfer ${options.id} canceled` : options.message);
37 this.name = 'TransferCancel';
40 export class TransferSkipped extends Error {
41 constructor(options: { id: string } | { message: string }) {
42 super('id' in options ? `Transfer ${options.id} skipped` : options.message);
43 this.name = 'TransferSkipped';
47 export class TransferConflict extends Error {
48 constructor(options: { id: string } | { message: string }) {
49 super('id' in options ? `Transfer ${options.id} is conflicting` : options.message);
50 this.name = 'TransferConflict';
54 export interface Upload {
65 export interface Download {
71 scanIssueError?: Error;
74 export type Transfer = Upload | Download;
76 export interface TransferHistoryStats {
82 export interface TransfersHistoryStats {
84 stats: { [id: string]: TransferHistoryStats };
87 export interface TransferStats {
92 export interface TransfersStats {
93 [id: string]: TransferStats;
96 export enum TransferType {
97 Download = 'download',
101 export enum TransferGroup {
108 export const STATE_TO_GROUP_MAP = {
109 [TransferState.Progress]: TransferGroup.ACTIVE,
110 [TransferState.Finalizing]: TransferGroup.ACTIVE,
111 [TransferState.Paused]: TransferGroup.ACTIVE,
112 [TransferState.SignatureIssue]: TransferGroup.ACTIVE,
113 [TransferState.ScanIssue]: TransferGroup.ACTIVE,
114 [TransferState.Skipped]: TransferGroup.FAILURE,
115 [TransferState.Canceled]: TransferGroup.FAILURE,
116 [TransferState.NetworkError]: TransferGroup.FAILURE,
117 [TransferState.Done]: TransferGroup.DONE,
118 [TransferState.Error]: TransferGroup.FAILURE,
119 [TransferState.Initializing]: TransferGroup.QUEUED,
120 [TransferState.Conflict]: TransferGroup.QUEUED,
121 [TransferState.Pending]: TransferGroup.QUEUED,