-
Notifications
You must be signed in to change notification settings - Fork 2
/
storage.d.ts
117 lines (97 loc) · 2.8 KB
/
storage.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import type {TusProtocolExtension} from './tus';
import type {TussleIncomingRequest} from './request';
import type {Observable} from 'rxjs';
export interface TussleStorageCreateFileParams {
path: string;
uploadLength: number;
uploadMetadata: Record<string, string | number>;
uploadConcat: UploadConcatPartial | UploadConcatFinal | null;
}
export interface TussleStorageCreateFileResponse {
location: string;
success: boolean;
metadata?: Record<string, unknown>;
uploadConcat?: UploadConcatPartial | UploadConcatFinal | null;
offset: number;
error?: unknown;
}
export interface TussleStoragePatchFileParams<Req = unknown, U = unknown> {
length: number;
location: string;
offset: number;
request: TussleIncomingRequest<Req, U>;
}
interface Details {
[key: string]: unknown,
tussleUploadMetadata: Record<string, unknown>,
}
export interface TussleStoragePatchFileResponse {
location: string;
success: boolean;
offset?: number; // only if success
complete: boolean; // signifies that upload is complete
details?: Details;
error?: unknown;
}
export interface TussleStoragePatchFileCompleteResponse {
location: string;
success: boolean;
offset: number;
complete: true;
details: Details;
}
export interface TussleStorageDeleteFileParams {
location: string;
}
export interface TussleStorageDeleteFileResponse {
location: string;
success: boolean;
}
export interface TussleStorageFileInfoParams {
location: string;
}
export interface TussleStorageFileInfo {
location: string;
info: {
currentOffset: number;
uploadLength?: number;
uploadConcat?: UploadConcatPartial | UploadConcatFinal | null;
} | null;
details?: unknown;
}
export interface UploadConcatPartial {
action: 'partial';
}
export interface UploadConcatFinal {
action: 'final';
parts: string[];
}
export interface TussleStorageService {
readonly extensionsRequired: TusProtocolExtension[];
readonly extensionsSupported?: TusProtocolExtension[];
createFile(
params: TussleStorageCreateFileParams
): Observable<TussleStorageCreateFileResponse>;
patchFile<Req, U>(
params: TussleStoragePatchFileParams<Req, U>
): Observable<TussleStoragePatchFileResponse>;
getFileInfo(
params: TussleStorageFileInfoParams
): Observable<TussleStorageFileInfo>;
deleteFile?(
params: TussleStorageDeleteFileParams,
): Observable<TussleStorageDeleteFileResponse>;
event$?: Observable<TussleStoragePerfEvent>;
}
export type TussleStorageServiceWithDeleteCapability = Required<TussleStorageService>;
export interface TussleStoragePerfEvent {
storage: Readonly<TussleStorageService>;
action: 'create'|'patch'|'info'|'delete';
location: string;
bytes: number;
elapsed_time_ms: number;
success: boolean;
}
export interface TussleStorageServiceWithPerformanceEvents<T extends TussleStoragePerfEvent> extends TussleStorageService {
event$: Observable<T>;
}