@vidispine/vdt-js 23.4.0-pre.3 → 23.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +349 -10
- package/dist/index.js +1437 -885
- package/dist/index.umd.cjs +3 -3
- package/package.json +15 -14
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
|
|
7
9
|
import type { AudioComponentType } from '@vidispine/types';
|
|
8
10
|
import type { BinaryComponentType } from '@vidispine/types';
|
|
9
11
|
import type { CollectionType } from '@vidispine/types';
|
|
@@ -30,6 +32,271 @@ import type { VideoComponentType } from '@vidispine/types';
|
|
|
30
32
|
|
|
31
33
|
declare type ArrayElement<ArrayType> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
|
32
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Representation of a chunk sent by `ChunkUpload`
|
|
37
|
+
*
|
|
38
|
+
* @category Upload
|
|
39
|
+
*/
|
|
40
|
+
export declare class Chunk {
|
|
41
|
+
state: ChunkState;
|
|
42
|
+
eventBus: ChunkedUploadEventBus;
|
|
43
|
+
tryTimeout: NodeJS.Timeout;
|
|
44
|
+
transferPromise: any;
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
fileSize: number;
|
|
48
|
+
blobSlice: any;
|
|
49
|
+
api: {
|
|
50
|
+
method?: (options: {
|
|
51
|
+
file: any;
|
|
52
|
+
onUploadProgress: (progressEvent: {
|
|
53
|
+
loaded: number;
|
|
54
|
+
}) => void;
|
|
55
|
+
headers?: {
|
|
56
|
+
index: number;
|
|
57
|
+
size: number;
|
|
58
|
+
};
|
|
59
|
+
}) => any;
|
|
60
|
+
props?: any;
|
|
61
|
+
};
|
|
62
|
+
constructor(props?: ChunkProps);
|
|
63
|
+
/**
|
|
64
|
+
* Attempt to transfer chunk with some fault resilience.
|
|
65
|
+
*
|
|
66
|
+
* - 3 retires with 1 second apart in case of failure
|
|
67
|
+
* - Pauses/resumes chunk transfer when network is offline/online
|
|
68
|
+
*
|
|
69
|
+
* @returns Promise of the transfer request
|
|
70
|
+
*/
|
|
71
|
+
tryTransfer(): Promise<Chunk>;
|
|
72
|
+
/**
|
|
73
|
+
* Transfers `blobSlice` on this object with the `api.method`
|
|
74
|
+
*
|
|
75
|
+
* Triggers: `EVENTS.progress`
|
|
76
|
+
* Status: `STATUSES.transferring`
|
|
77
|
+
*
|
|
78
|
+
* @returns Promise for the transfer
|
|
79
|
+
*/
|
|
80
|
+
transfer(): any;
|
|
81
|
+
pause(): void;
|
|
82
|
+
resume(): void;
|
|
83
|
+
cancel(): void;
|
|
84
|
+
get transferRate(): number;
|
|
85
|
+
private onComplete;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Class for sending and controlling multiple `ChunkedUpload` objects
|
|
90
|
+
*
|
|
91
|
+
* @category Upload
|
|
92
|
+
*/
|
|
93
|
+
export declare class ChunkedTransferManager {
|
|
94
|
+
initialState: ChunkedTransferManagerState;
|
|
95
|
+
state: ChunkedTransferManagerState;
|
|
96
|
+
options: ChunkedTransferManagerOptions;
|
|
97
|
+
events: ChunkedUploadEventBus;
|
|
98
|
+
constructor(options?: ChunkedTransferManagerOptions);
|
|
99
|
+
get transfers(): ChunkedUpload[];
|
|
100
|
+
get status(): number;
|
|
101
|
+
set status(value: number);
|
|
102
|
+
get bytesTotal(): number;
|
|
103
|
+
get bytesDone(): number;
|
|
104
|
+
get isUploading(): boolean;
|
|
105
|
+
get paused(): boolean;
|
|
106
|
+
bindNetworkEvents(): void;
|
|
107
|
+
addChunkedUpload(chunkedUpload: ChunkedUpload): void;
|
|
108
|
+
removeChunkedUpload(InstanceOrFileOrTransferId: ChunkedUpload | File | string, force?: boolean): void;
|
|
109
|
+
onProgress(): void;
|
|
110
|
+
onComplete(): void;
|
|
111
|
+
exists(file: File): ChunkedUpload;
|
|
112
|
+
isTransferAvailable(transfer: any): boolean;
|
|
113
|
+
pause(): Promise<any>;
|
|
114
|
+
resume(): void;
|
|
115
|
+
retry(): void;
|
|
116
|
+
upload(): void;
|
|
117
|
+
onFail(error: any, state: ChunkedUpload['state']): void;
|
|
118
|
+
reset(): void;
|
|
119
|
+
destroy(): void;
|
|
120
|
+
get hasCompleted(): boolean;
|
|
121
|
+
updateStats(): void;
|
|
122
|
+
get percentDone(): number;
|
|
123
|
+
get fileList(): any[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export declare type ChunkedTransferManagerOptions = {
|
|
127
|
+
maxConcurrentFileTransfers: number;
|
|
128
|
+
autoResume: boolean;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export declare type ChunkedTransferManagerState = {
|
|
132
|
+
status: number;
|
|
133
|
+
transfers: ChunkedUpload[];
|
|
134
|
+
bytesDone: number;
|
|
135
|
+
bytesTotal: number;
|
|
136
|
+
lastStats: {
|
|
137
|
+
bytesDone: number;
|
|
138
|
+
bytesTotal: number;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Class for dividing blobs/files into chunks and sending them through the supplied `options.api.method`
|
|
144
|
+
*
|
|
145
|
+
* @category Upload
|
|
146
|
+
*/
|
|
147
|
+
export declare class ChunkedUpload {
|
|
148
|
+
readonly DEFAULT_OPTIONS: ChunkedUploadOptions;
|
|
149
|
+
eventBus: ChunkedUploadEventBus;
|
|
150
|
+
options: ChunkedUploadOptions;
|
|
151
|
+
state: ChunkedUploadState;
|
|
152
|
+
constructor(file: File, options: ChunkedUploadOptions);
|
|
153
|
+
upload(): void;
|
|
154
|
+
getByteRangesForChunks(blob: Blob, chunkSize?: number): any[];
|
|
155
|
+
addChunksFromBlob(blob: Blob): void;
|
|
156
|
+
retry(): void;
|
|
157
|
+
resume(): void;
|
|
158
|
+
pause(): Promise<Chunk[]>;
|
|
159
|
+
cancel(): Promise<Chunk[]>;
|
|
160
|
+
autoAdjustMaxConcurrentTransfers(stats: any): void;
|
|
161
|
+
onProgress(): void;
|
|
162
|
+
onComplete(): void;
|
|
163
|
+
getStats(): {
|
|
164
|
+
totalChunks: number;
|
|
165
|
+
completedChunks: number;
|
|
166
|
+
totalBytes: number;
|
|
167
|
+
transferredBytes: number;
|
|
168
|
+
avgTransferRate: number;
|
|
169
|
+
concurrentTransfers: number;
|
|
170
|
+
};
|
|
171
|
+
set concurrentTransfers(int: any);
|
|
172
|
+
set rate(int: number);
|
|
173
|
+
get rate(): number;
|
|
174
|
+
get finalResponse(): false | object;
|
|
175
|
+
get transferId(): string;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Event bus used by `Chunk`, `ChunkedUpload` and `ChunkedTransferManager` to communicate
|
|
180
|
+
*
|
|
181
|
+
* @category Upload
|
|
182
|
+
*/
|
|
183
|
+
export declare class ChunkedUploadEventBus {
|
|
184
|
+
events: ChunkedUploadEventBusEvents;
|
|
185
|
+
constructor();
|
|
186
|
+
/**
|
|
187
|
+
* Add a callback for a specific event type
|
|
188
|
+
*
|
|
189
|
+
* @param event event type
|
|
190
|
+
* @param callback function receiving state of chunk, transfer manager or chunked upload instance
|
|
191
|
+
*/
|
|
192
|
+
on(event: EVENTS, callback: (data: Chunk['state'] | ChunkedTransferManager['state'] | ChunkedUpload['state'], error?: any) => void): void;
|
|
193
|
+
/**
|
|
194
|
+
* Remove all callbacks for a specific event type
|
|
195
|
+
*
|
|
196
|
+
* @param event event type
|
|
197
|
+
*/
|
|
198
|
+
off(event: EVENTS): void;
|
|
199
|
+
/**
|
|
200
|
+
* Trigger callbacks for a specific event
|
|
201
|
+
*
|
|
202
|
+
* @param event
|
|
203
|
+
* @param data
|
|
204
|
+
* @returns
|
|
205
|
+
*/
|
|
206
|
+
trigger(event: EVENTS, data: Chunk['state'] | ChunkedTransferManager['state'] | ChunkedUpload['state'], error?: any): void;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare type ChunkedUploadEventBusEvents = {
|
|
210
|
+
[key in EVENTS]?: Array<(data: Chunk['state'] | ChunkedTransferManager['state'] | ChunkedUpload['state'], error?: any) => void>;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export declare type ChunkedUploadOptions = {
|
|
214
|
+
targetRate?: number;
|
|
215
|
+
chunkSize?: number;
|
|
216
|
+
minChunkSize?: number;
|
|
217
|
+
maxConcurrentTransfers?: number;
|
|
218
|
+
maxConcurrentFileTransfers?: number;
|
|
219
|
+
autoMaxConcurrentTransfers?: boolean;
|
|
220
|
+
minFileSize?: number;
|
|
221
|
+
api?: {
|
|
222
|
+
props?: {
|
|
223
|
+
pathParams?: {
|
|
224
|
+
[key: string]: any;
|
|
225
|
+
};
|
|
226
|
+
queryParams?: {
|
|
227
|
+
transferId?: string;
|
|
228
|
+
[key: string]: any;
|
|
229
|
+
};
|
|
230
|
+
data?: any;
|
|
231
|
+
};
|
|
232
|
+
method?: any;
|
|
233
|
+
[key: string]: any;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* ChunkedTransferManager -> automatically resume transfers when network connection become active
|
|
237
|
+
*/
|
|
238
|
+
autoResume?: boolean;
|
|
239
|
+
onComplete?: (finalResponse?: false | object) => void;
|
|
240
|
+
onProgress?: (stats?: ChunkedUploadStats) => void;
|
|
241
|
+
onFail?: (error?: any) => void;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export declare type ChunkedUploadState = {
|
|
245
|
+
blob: {
|
|
246
|
+
name: string;
|
|
247
|
+
lastModified: number;
|
|
248
|
+
size: number;
|
|
249
|
+
};
|
|
250
|
+
chunks: Chunk[];
|
|
251
|
+
status: number;
|
|
252
|
+
transferPromises: Promise<Chunk>[];
|
|
253
|
+
targetRate: number;
|
|
254
|
+
rate: number;
|
|
255
|
+
autoMaxConcurrentTransfers: boolean;
|
|
256
|
+
maxConcurrentTransfers: number;
|
|
257
|
+
mime: string;
|
|
258
|
+
transferId: string;
|
|
259
|
+
lastStats: {};
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export declare type ChunkedUploadStats = {
|
|
263
|
+
totalChunks?: number;
|
|
264
|
+
completedChunks?: number;
|
|
265
|
+
totalBytes?: number;
|
|
266
|
+
transferredBytes?: number;
|
|
267
|
+
avgTransferRate?: number;
|
|
268
|
+
concurrentTransfers?: number;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export declare type ChunkProps = {
|
|
272
|
+
start?: number;
|
|
273
|
+
end?: number;
|
|
274
|
+
fileSize?: number;
|
|
275
|
+
blobSlice?: any;
|
|
276
|
+
api?: {
|
|
277
|
+
method?: (options?: {
|
|
278
|
+
file?: any;
|
|
279
|
+
onUploadProgress?: (progressEvent: {
|
|
280
|
+
loaded: number;
|
|
281
|
+
}) => void;
|
|
282
|
+
headers?: {
|
|
283
|
+
index: number;
|
|
284
|
+
size: number;
|
|
285
|
+
};
|
|
286
|
+
}) => any;
|
|
287
|
+
props?: any;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export declare type ChunkState = {
|
|
292
|
+
retries: number;
|
|
293
|
+
status: number;
|
|
294
|
+
startTime: number | null;
|
|
295
|
+
completeTime: number | null;
|
|
296
|
+
response: any;
|
|
297
|
+
bytesTransferred: number | null;
|
|
298
|
+
};
|
|
299
|
+
|
|
33
300
|
/**
|
|
34
301
|
* Create a VidiCore metadata object from a more dense/simplified structure
|
|
35
302
|
*
|
|
@@ -83,8 +350,6 @@ export declare const createTimeCode: (timeCode: TimeCodeInput | string | number,
|
|
|
83
350
|
|
|
84
351
|
export declare type CreateTimeCodeOptions = TimeCodeInputOptions | FormatTimeCodeSmpteOptions | FormatTimeCodeSecondsOptions | FormatTimeCodeTextOptions;
|
|
85
352
|
|
|
86
|
-
export declare const defaultOptions: ParseSearchResultEventsOptions;
|
|
87
|
-
|
|
88
353
|
/**
|
|
89
354
|
* Const object with document types
|
|
90
355
|
*
|
|
@@ -101,6 +366,27 @@ export declare const DOCUMENT_TYPES: {
|
|
|
101
366
|
declare type DocumentType_2 = keyof typeof DOCUMENT_TYPES;
|
|
102
367
|
export { DocumentType_2 as DocumentType }
|
|
103
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Chunked upload event types
|
|
371
|
+
*
|
|
372
|
+
* @category Upload
|
|
373
|
+
*/
|
|
374
|
+
export declare enum EVENTS {
|
|
375
|
+
progress = "progress",
|
|
376
|
+
update = "update",
|
|
377
|
+
complete = "complete",
|
|
378
|
+
error = "error",
|
|
379
|
+
added = "upload-added",
|
|
380
|
+
removed = "upload-removed",
|
|
381
|
+
failed = "upload-failed",
|
|
382
|
+
retry = "retry",
|
|
383
|
+
pausing = "pausing",
|
|
384
|
+
paused = "paused",
|
|
385
|
+
resuming = "resuming",
|
|
386
|
+
offline = "offline",
|
|
387
|
+
online = "online"
|
|
388
|
+
}
|
|
389
|
+
|
|
104
390
|
/**
|
|
105
391
|
* Array with all available metadata field attributes
|
|
106
392
|
*
|
|
@@ -156,8 +442,38 @@ export declare const FILE_STATES: {
|
|
|
156
442
|
readonly AWAITING_SYNC: "AWAITING_SYNC";
|
|
157
443
|
};
|
|
158
444
|
|
|
445
|
+
export declare type FileLike = Partial<File> & {
|
|
446
|
+
path?: string;
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Converts a list of files into a tree structure
|
|
451
|
+
*
|
|
452
|
+
* Works with `path` or the native `webkitRelativePath`
|
|
453
|
+
*
|
|
454
|
+
* @param files An array of file like objects
|
|
455
|
+
* @returns A file tree object
|
|
456
|
+
*
|
|
457
|
+
* @category Upload
|
|
458
|
+
*/
|
|
459
|
+
export declare const fileListToFileTree: (files: FileLike[]) => {
|
|
460
|
+
[key: string]: FileTree;
|
|
461
|
+
};
|
|
462
|
+
|
|
159
463
|
export declare type FileStateTypes = keyof typeof FILE_STATES;
|
|
160
464
|
|
|
465
|
+
export declare type FileTree = {
|
|
466
|
+
file: File;
|
|
467
|
+
path?: string;
|
|
468
|
+
progress?: {
|
|
469
|
+
totalBytes: number;
|
|
470
|
+
transferredBytes: number;
|
|
471
|
+
};
|
|
472
|
+
files?: {
|
|
473
|
+
[fileName: string]: FileTree;
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
|
|
161
477
|
export declare type FilteredShapeListObject = {
|
|
162
478
|
src: string;
|
|
163
479
|
type: string;
|
|
@@ -662,7 +978,7 @@ export declare type ParsedMetadataType<TOptions> = (TOptions extends {
|
|
|
662
978
|
includeMetadataAttributes?: true | string[];
|
|
663
979
|
} ? ParsedMetadataAttributes : {});
|
|
664
980
|
|
|
665
|
-
|
|
981
|
+
declare type ParsedSearchResultEntryTimespanType = {
|
|
666
982
|
entityType?: 'Item' | 'Collection';
|
|
667
983
|
entityId?: string;
|
|
668
984
|
group?: MetadataGroupValueType;
|
|
@@ -673,7 +989,7 @@ export declare type ParsedSearchResultEntryTimespanType = {
|
|
|
673
989
|
endSeconds?: number;
|
|
674
990
|
};
|
|
675
991
|
|
|
676
|
-
|
|
992
|
+
declare type ParsedSearchResultEntryType = {
|
|
677
993
|
entityType: 'Item' | 'Collection';
|
|
678
994
|
entityId: string;
|
|
679
995
|
events?: ParsedSearchResultEntryTimespanType[];
|
|
@@ -681,7 +997,7 @@ export declare type ParsedSearchResultEntryType = {
|
|
|
681
997
|
collectionType?: CollectionType;
|
|
682
998
|
};
|
|
683
999
|
|
|
684
|
-
|
|
1000
|
+
declare type ParsedSearchResultEvents<TOptions> = TOptions extends {
|
|
685
1001
|
flatEvents?: true;
|
|
686
1002
|
} ? ParsedSearchResultEntryTimespanType[] : ParsedSearchResultEntryType[];
|
|
687
1003
|
|
|
@@ -1002,13 +1318,15 @@ export declare const parseNowDate: (value?: string) => Date;
|
|
|
1002
1318
|
* - https://apidoc.vidispine.com/latest/ref/search.html#search-collection-and-item-by-metadata-group
|
|
1003
1319
|
* - https://apidoc.vidispine.com/latest/item/search.html#find-item-and-collections-by-their-metadata-groups
|
|
1004
1320
|
*
|
|
1005
|
-
* @param searchResult
|
|
1006
|
-
* @param options
|
|
1007
|
-
* @returns
|
|
1321
|
+
* @param searchResult Metadata-group search results that should be parsed into events
|
|
1322
|
+
* @param options options for tweaking how search results should be parsed
|
|
1323
|
+
* @returns Search results converted to an array of more event-like objects
|
|
1324
|
+
*
|
|
1325
|
+
* @category Search
|
|
1008
1326
|
*/
|
|
1009
1327
|
export declare const parseSearchResultEvents: <TOptions extends ParseSearchResultEventsOptions = ParseSearchResultEventsOptions>(searchResult?: SearchResultType, options?: TOptions) => ParsedSearchResultEvents<TOptions>;
|
|
1010
1328
|
|
|
1011
|
-
|
|
1329
|
+
declare type ParseSearchResultEventsOptions = {
|
|
1012
1330
|
/**
|
|
1013
1331
|
* Append matching group with metadata
|
|
1014
1332
|
*/
|
|
@@ -1296,6 +1614,21 @@ export declare const SHAPE_MEDIA_TYPES: {
|
|
|
1296
1614
|
|
|
1297
1615
|
export declare type ShapeMediaType = keyof typeof SHAPE_MEDIA_TYPES;
|
|
1298
1616
|
|
|
1617
|
+
/**
|
|
1618
|
+
* Chunked upload status types
|
|
1619
|
+
*
|
|
1620
|
+
* @category Upload
|
|
1621
|
+
*/
|
|
1622
|
+
export declare enum STATUSES {
|
|
1623
|
+
transferring = 1,
|
|
1624
|
+
paused = 2,
|
|
1625
|
+
complete = 3,
|
|
1626
|
+
failed = 4,
|
|
1627
|
+
idle = 5,
|
|
1628
|
+
canceled = 6,
|
|
1629
|
+
offline = 7
|
|
1630
|
+
}
|
|
1631
|
+
|
|
1299
1632
|
/**
|
|
1300
1633
|
* Array with all available VidiCore system/default field group names
|
|
1301
1634
|
*
|
|
@@ -1540,9 +1873,11 @@ export declare class TimeCode {
|
|
|
1540
1873
|
/**
|
|
1541
1874
|
* Get TimeCode in a smpte representation
|
|
1542
1875
|
*
|
|
1876
|
+
* @param {Object} options
|
|
1877
|
+
* @param {boolean} options.uniformSeparators Use the frame separator for all separators in the smpte string
|
|
1543
1878
|
* @returns Smpte representation of the TimeCode
|
|
1544
1879
|
*/
|
|
1545
|
-
toSmpte(): string;
|
|
1880
|
+
toSmpte(options?: ToSmpteOptions): string;
|
|
1546
1881
|
/**
|
|
1547
1882
|
* Get TimeCode as a VidiCore TimeCodeType object
|
|
1548
1883
|
*
|
|
@@ -1594,4 +1929,8 @@ declare type TimeCodeToSecondsOptions = {
|
|
|
1594
1929
|
round?: boolean;
|
|
1595
1930
|
};
|
|
1596
1931
|
|
|
1932
|
+
export declare type ToSmpteOptions = {
|
|
1933
|
+
uniformSeparators?: boolean;
|
|
1934
|
+
};
|
|
1935
|
+
|
|
1597
1936
|
export { }
|