@depup/firebase__storage 0.14.1-depup.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.
Files changed (101) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/index.browser.cjs.js +3685 -0
  4. package/dist/index.browser.cjs.js.map +1 -0
  5. package/dist/index.cjs.js +3685 -0
  6. package/dist/index.cjs.js.map +1 -0
  7. package/dist/index.esm.js +3656 -0
  8. package/dist/index.esm.js.map +1 -0
  9. package/dist/index.node.cjs.js +3710 -0
  10. package/dist/index.node.cjs.js.map +1 -0
  11. package/dist/node-esm/index.node.esm.js +3681 -0
  12. package/dist/node-esm/index.node.esm.js.map +1 -0
  13. package/dist/node-esm/package.json +1 -0
  14. package/dist/node-esm/src/api.browser.d.ts +47 -0
  15. package/dist/node-esm/src/api.d.ts +200 -0
  16. package/dist/node-esm/src/api.node.d.ts +47 -0
  17. package/dist/node-esm/src/constants.d.ts +20 -0
  18. package/dist/node-esm/src/implementation/async.d.ts +22 -0
  19. package/dist/node-esm/src/implementation/backoff.d.ts +43 -0
  20. package/dist/node-esm/src/implementation/blob.d.ts +34 -0
  21. package/dist/node-esm/src/implementation/connection.d.ts +56 -0
  22. package/dist/node-esm/src/implementation/constants.d.ts +48 -0
  23. package/dist/node-esm/src/implementation/error.d.ts +126 -0
  24. package/dist/node-esm/src/implementation/failrequest.d.ts +29 -0
  25. package/dist/node-esm/src/implementation/fs.d.ts +17 -0
  26. package/dist/node-esm/src/implementation/json.d.ts +7 -0
  27. package/dist/node-esm/src/implementation/list.d.ts +19 -0
  28. package/dist/node-esm/src/implementation/location.d.ts +32 -0
  29. package/dist/node-esm/src/implementation/metadata.d.ts +40 -0
  30. package/dist/node-esm/src/implementation/observer.d.ts +47 -0
  31. package/dist/node-esm/src/implementation/path.d.ts +31 -0
  32. package/dist/node-esm/src/implementation/request.d.ts +47 -0
  33. package/dist/node-esm/src/implementation/requestinfo.d.ts +73 -0
  34. package/dist/node-esm/src/implementation/requests.d.ts +84 -0
  35. package/dist/node-esm/src/implementation/string.d.ts +73 -0
  36. package/dist/node-esm/src/implementation/taskenums.d.ts +77 -0
  37. package/dist/node-esm/src/implementation/type.d.ts +23 -0
  38. package/dist/node-esm/src/implementation/url.d.ts +22 -0
  39. package/dist/node-esm/src/implementation/utils.d.ts +23 -0
  40. package/dist/node-esm/src/index.d.ts +7 -0
  41. package/dist/node-esm/src/index.node.d.ts +7 -0
  42. package/dist/node-esm/src/list.d.ts +41 -0
  43. package/dist/node-esm/src/metadata.d.ts +27 -0
  44. package/dist/node-esm/src/platform/base64.d.ts +20 -0
  45. package/dist/node-esm/src/platform/browser/base64.d.ts +19 -0
  46. package/dist/node-esm/src/platform/browser/connection.d.ts +55 -0
  47. package/dist/node-esm/src/platform/connection.d.ts +22 -0
  48. package/dist/node-esm/src/platform/node/base64.d.ts +19 -0
  49. package/dist/node-esm/src/platform/node/connection.d.ts +58 -0
  50. package/dist/node-esm/src/public-types.d.ts +424 -0
  51. package/dist/node-esm/src/reference.d.ts +208 -0
  52. package/dist/node-esm/src/service.d.ts +131 -0
  53. package/dist/node-esm/src/task.d.ts +148 -0
  54. package/dist/node-esm/test/unit/connection.d.ts +47 -0
  55. package/dist/node-esm/test/unit/testshared.d.ts +60 -0
  56. package/dist/src/api.browser.d.ts +47 -0
  57. package/dist/src/api.d.ts +200 -0
  58. package/dist/src/api.node.d.ts +47 -0
  59. package/dist/src/constants.d.ts +20 -0
  60. package/dist/src/implementation/async.d.ts +22 -0
  61. package/dist/src/implementation/backoff.d.ts +43 -0
  62. package/dist/src/implementation/blob.d.ts +34 -0
  63. package/dist/src/implementation/connection.d.ts +56 -0
  64. package/dist/src/implementation/constants.d.ts +48 -0
  65. package/dist/src/implementation/error.d.ts +126 -0
  66. package/dist/src/implementation/failrequest.d.ts +29 -0
  67. package/dist/src/implementation/fs.d.ts +17 -0
  68. package/dist/src/implementation/json.d.ts +7 -0
  69. package/dist/src/implementation/list.d.ts +19 -0
  70. package/dist/src/implementation/location.d.ts +32 -0
  71. package/dist/src/implementation/metadata.d.ts +40 -0
  72. package/dist/src/implementation/observer.d.ts +47 -0
  73. package/dist/src/implementation/path.d.ts +31 -0
  74. package/dist/src/implementation/request.d.ts +47 -0
  75. package/dist/src/implementation/requestinfo.d.ts +73 -0
  76. package/dist/src/implementation/requests.d.ts +84 -0
  77. package/dist/src/implementation/string.d.ts +73 -0
  78. package/dist/src/implementation/taskenums.d.ts +77 -0
  79. package/dist/src/implementation/type.d.ts +23 -0
  80. package/dist/src/implementation/url.d.ts +22 -0
  81. package/dist/src/implementation/utils.d.ts +23 -0
  82. package/dist/src/index.d.ts +7 -0
  83. package/dist/src/index.node.d.ts +7 -0
  84. package/dist/src/list.d.ts +41 -0
  85. package/dist/src/metadata.d.ts +27 -0
  86. package/dist/src/platform/base64.d.ts +20 -0
  87. package/dist/src/platform/browser/base64.d.ts +19 -0
  88. package/dist/src/platform/browser/connection.d.ts +55 -0
  89. package/dist/src/platform/connection.d.ts +22 -0
  90. package/dist/src/platform/node/base64.d.ts +19 -0
  91. package/dist/src/platform/node/connection.d.ts +58 -0
  92. package/dist/src/public-types.d.ts +424 -0
  93. package/dist/src/reference.d.ts +208 -0
  94. package/dist/src/service.d.ts +131 -0
  95. package/dist/src/task.d.ts +148 -0
  96. package/dist/src/tsdoc-metadata.json +11 -0
  97. package/dist/storage-public.d.ts +725 -0
  98. package/dist/storage.d.ts +1391 -0
  99. package/dist/test/unit/connection.d.ts +47 -0
  100. package/dist/test/unit/testshared.d.ts +60 -0
  101. package/package.json +98 -0
@@ -0,0 +1,1391 @@
1
+ /**
2
+ * Cloud Storage for Firebase
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
8
+ import { CompleteFn } from '@firebase/util';
9
+ import { EmulatorMockTokenOptions } from '@firebase/util';
10
+ import { FirebaseApp } from '@firebase/app';
11
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
12
+ import { FirebaseError } from '@firebase/util';
13
+ import { _FirebaseService } from '@firebase/app';
14
+ import { NextFn } from '@firebase/util';
15
+ import { Provider } from '@firebase/component';
16
+ import { Subscribe } from '@firebase/util';
17
+ import { Unsubscribe } from '@firebase/util';
18
+
19
+ /**
20
+ * A function that is called if the event stream ends normally.
21
+ */
22
+ declare type CompleteFn_2 = () => void;
23
+
24
+ /**
25
+ * A lightweight wrapper around XMLHttpRequest with a
26
+ * goog.net.XhrIo-like interface.
27
+ *
28
+ * You can create a new connection by invoking `newTextConnection()`,
29
+ * `newBytesConnection()` or `newStreamConnection()`.
30
+ */
31
+ declare interface Connection<T extends ConnectionType> {
32
+ /**
33
+ * Sends a request to the provided URL.
34
+ *
35
+ * This method never rejects its promise. In case of encountering an error,
36
+ * it sets an error code internally which can be accessed by calling
37
+ * getErrorCode() by callers.
38
+ */
39
+ send(url: string, method: string, isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers_2): Promise<void>;
40
+ getErrorCode(): ErrorCode;
41
+ getStatus(): number;
42
+ getResponse(): T;
43
+ getErrorText(): string;
44
+ /**
45
+ * Abort the request.
46
+ */
47
+ abort(): void;
48
+ getResponseHeader(header: string): string | null;
49
+ addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
50
+ removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
51
+ }
52
+
53
+ /** Response type exposed by the networking APIs. */
54
+ declare type ConnectionType = string | ArrayBuffer | Blob | ReadableStream<Uint8Array>;
55
+
56
+ /**
57
+ * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
58
+ *
59
+ * @param storage - The {@link FirebaseStorage} instance
60
+ * @param host - The emulator host (ex: localhost)
61
+ * @param port - The emulator port (ex: 5001)
62
+ * @param options - Emulator options. `options.mockUserToken` is the mock auth
63
+ * token to use for unit testing Security Rules.
64
+ * @public
65
+ */
66
+ export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: {
67
+ mockUserToken?: EmulatorMockTokenOptions | string;
68
+ }): void;
69
+
70
+ /**
71
+ * @internal
72
+ */
73
+ export declare function _dataFromString(format: StringFormat, stringData: string): StringData;
74
+
75
+ /**
76
+ * Deletes the object at this location.
77
+ * @public
78
+ * @param ref - {@link StorageReference} for object to delete.
79
+ * @returns A `Promise` that resolves if the deletion succeeds.
80
+ */
81
+ export declare function deleteObject(ref: StorageReference): Promise<void>;
82
+ export { EmulatorMockTokenOptions }
83
+
84
+ /**
85
+ * Error codes for requests made by the XhrIo wrapper.
86
+ */
87
+ declare enum ErrorCode {
88
+ NO_ERROR = 0,
89
+ NETWORK_ERROR = 1,
90
+ ABORT = 2
91
+ }
92
+
93
+ /**
94
+ * A function that is called with a `StorageError`
95
+ * if the event stream ends due to an error.
96
+ */
97
+ declare type ErrorFn = (error: StorageError) => void;
98
+
99
+ /** A function to handle an error. */
100
+ declare type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError) => StorageError;
101
+
102
+ /**
103
+ * @license
104
+ * Copyright 2017 Google LLC
105
+ *
106
+ * Licensed under the Apache License, Version 2.0 (the "License");
107
+ * you may not use this file except in compliance with the License.
108
+ * You may obtain a copy of the License at
109
+ *
110
+ * http://www.apache.org/licenses/LICENSE-2.0
111
+ *
112
+ * Unless required by applicable law or agreed to in writing, software
113
+ * distributed under the License is distributed on an "AS IS" BASIS,
114
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
115
+ * See the License for the specific language governing permissions and
116
+ * limitations under the License.
117
+ */
118
+ /**
119
+ * @param opt_elideCopy - If true, doesn't copy mutable input data
120
+ * (e.g. Uint8Arrays). Pass true only if you know the objects will not be
121
+ * modified after this blob's construction.
122
+ *
123
+ * @internal
124
+ */
125
+ export declare class _FbsBlob {
126
+ private data_;
127
+ private size_;
128
+ private type_;
129
+ constructor(data: Blob | Uint8Array | ArrayBuffer, elideCopy?: boolean);
130
+ size(): number;
131
+ type(): string;
132
+ slice(startByte: number, endByte: number): _FbsBlob | null;
133
+ static getBlob(...args: Array<string | _FbsBlob>): _FbsBlob | null;
134
+ uploadData(): Blob | Uint8Array;
135
+ }
136
+
137
+ /**
138
+ * A Firebase Storage instance.
139
+ * @public
140
+ */
141
+ export declare interface FirebaseStorage extends _FirebaseService {
142
+ /**
143
+ * The {@link @firebase/app#FirebaseApp} associated with this `FirebaseStorage` instance.
144
+ */
145
+ readonly app: FirebaseApp;
146
+ /**
147
+ * The maximum time to retry uploads in milliseconds.
148
+ */
149
+ maxUploadRetryTime: number;
150
+ /**
151
+ * The maximum time to retry operations other than uploads or downloads in
152
+ * milliseconds.
153
+ */
154
+ maxOperationRetryTime: number;
155
+ }
156
+
157
+ /**
158
+ * A service that provides Firebase Storage Reference instances.
159
+ * @param opt_url - gs:// url to a custom Storage Bucket
160
+ *
161
+ * @internal
162
+ */
163
+ export declare class _FirebaseStorageImpl implements FirebaseStorage {
164
+ /**
165
+ * FirebaseApp associated with this StorageService instance.
166
+ */
167
+ readonly app: FirebaseApp;
168
+ readonly _authProvider: Provider<FirebaseAuthInternalName>;
169
+ /**
170
+ * @internal
171
+ */
172
+ readonly _appCheckProvider: Provider<AppCheckInternalComponentName>;
173
+ /**
174
+ * @internal
175
+ */
176
+ readonly _url?: string | undefined;
177
+ readonly _firebaseVersion?: string | undefined;
178
+ _isUsingEmulator: boolean;
179
+ _bucket: _Location | null;
180
+ /**
181
+ * This string can be in the formats:
182
+ * - host
183
+ * - host:port
184
+ */
185
+ private _host;
186
+ _protocol: string;
187
+ protected readonly _appId: string | null;
188
+ private readonly _requests;
189
+ private _deleted;
190
+ private _maxOperationRetryTime;
191
+ private _maxUploadRetryTime;
192
+ _overrideAuthToken?: string;
193
+ constructor(
194
+ /**
195
+ * FirebaseApp associated with this StorageService instance.
196
+ */
197
+ app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>,
198
+ /**
199
+ * @internal
200
+ */
201
+ _appCheckProvider: Provider<AppCheckInternalComponentName>,
202
+ /**
203
+ * @internal
204
+ */
205
+ _url?: string | undefined, _firebaseVersion?: string | undefined, _isUsingEmulator?: boolean);
206
+ /**
207
+ * The host string for this service, in the form of `host` or
208
+ * `host:port`.
209
+ */
210
+ get host(): string;
211
+ set host(host: string);
212
+ /**
213
+ * The maximum time to retry uploads in milliseconds.
214
+ */
215
+ get maxUploadRetryTime(): number;
216
+ set maxUploadRetryTime(time: number);
217
+ /**
218
+ * The maximum time to retry operations other than uploads or downloads in
219
+ * milliseconds.
220
+ */
221
+ get maxOperationRetryTime(): number;
222
+ set maxOperationRetryTime(time: number);
223
+ _getAuthToken(): Promise<string | null>;
224
+ _getAppCheckToken(): Promise<string | null>;
225
+ /**
226
+ * Stop running requests and prevent more from being created.
227
+ */
228
+ _delete(): Promise<void>;
229
+ /**
230
+ * Returns a new firebaseStorage.Reference object referencing this StorageService
231
+ * at the given Location.
232
+ */
233
+ _makeStorageReference(loc: _Location): _Reference;
234
+ /**
235
+ * @param requestInfo - HTTP RequestInfo object
236
+ * @param authToken - Firebase auth token
237
+ */
238
+ _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request_2<O>;
239
+ makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>;
240
+ }
241
+
242
+ /**
243
+ * The full set of object metadata, including read-only properties.
244
+ * @public
245
+ */
246
+ export declare interface FullMetadata extends UploadMetadata {
247
+ /**
248
+ * The bucket this object is contained in.
249
+ */
250
+ bucket: string;
251
+ /**
252
+ * The full path of this object.
253
+ */
254
+ fullPath: string;
255
+ /**
256
+ * The object's generation.
257
+ * {@link https://cloud.google.com/storage/docs/metadata#generation-number}
258
+ */
259
+ generation: string;
260
+ /**
261
+ * The object's metageneration.
262
+ * {@link https://cloud.google.com/storage/docs/metadata#generation-number}
263
+ */
264
+ metageneration: string;
265
+ /**
266
+ * The short name of this object, which is the last component of the full path.
267
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
268
+ */
269
+ name: string;
270
+ /**
271
+ * The size of this object, in bytes.
272
+ */
273
+ size: number;
274
+ /**
275
+ * A date string representing when this object was created.
276
+ */
277
+ timeCreated: string;
278
+ /**
279
+ * A date string representing when this object was last updated.
280
+ */
281
+ updated: string;
282
+ /**
283
+ * Tokens to allow access to the download URL.
284
+ */
285
+ downloadTokens: string[] | undefined;
286
+ /**
287
+ * `StorageReference` associated with this upload.
288
+ */
289
+ ref?: StorageReference | undefined;
290
+ }
291
+
292
+ /**
293
+ * Downloads the data at the object's location. Returns an error if the object
294
+ * is not found.
295
+ *
296
+ * To use this functionality, you have to whitelist your app's origin in your
297
+ * Cloud Storage bucket. See also
298
+ * https://cloud.google.com/storage/docs/configuring-cors
299
+ *
300
+ * This API is not available in Node.
301
+ *
302
+ * @public
303
+ * @param ref - StorageReference where data should be downloaded.
304
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
305
+ * retrieve.
306
+ * @returns A Promise that resolves with a Blob containing the object's bytes
307
+ */
308
+ export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>;
309
+
310
+ /**
311
+ * Downloads the data at the object's location. Returns an error if the object
312
+ * is not found.
313
+ *
314
+ * To use this functionality, you have to whitelist your app's origin in your
315
+ * Cloud Storage bucket. See also
316
+ * https://cloud.google.com/storage/docs/configuring-cors
317
+ *
318
+ * @public
319
+ * @param ref - StorageReference where data should be downloaded.
320
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
321
+ * retrieve.
322
+ * @returns A Promise containing the object's bytes
323
+ */
324
+ export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
325
+
326
+ /**
327
+ * @internal
328
+ */
329
+ export declare function _getChild(ref: StorageReference, childPath: string): _Reference;
330
+
331
+ /**
332
+ * Returns the download URL for the given {@link StorageReference}.
333
+ * @public
334
+ * @param ref - {@link StorageReference} to get the download URL for.
335
+ * @returns A `Promise` that resolves with the download
336
+ * URL for this object.
337
+ */
338
+ export declare function getDownloadURL(ref: StorageReference): Promise<string>;
339
+
340
+ /**
341
+ * A `Promise` that resolves with the metadata for this object. If this
342
+ * object doesn't exist or metadata cannot be retrieved, the promise is
343
+ * rejected.
344
+ * @public
345
+ * @param ref - {@link StorageReference} to get metadata from.
346
+ */
347
+ export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>;
348
+
349
+ /**
350
+ * Gets a {@link FirebaseStorage} instance for the given Firebase app.
351
+ * @public
352
+ * @param app - Firebase app to get {@link FirebaseStorage} instance for.
353
+ * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.
354
+ * If not passed, uses the app's default Storage Bucket.
355
+ * @returns A {@link FirebaseStorage} instance.
356
+ */
357
+ export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
358
+
359
+ /**
360
+ * Downloads the data at the object's location. Raises an error event if the
361
+ * object is not found.
362
+ *
363
+ * This API is only available in Node.
364
+ *
365
+ * @public
366
+ * @param ref - StorageReference where data should be downloaded.
367
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
368
+ * retrieve.
369
+ * @returns A stream with the object's data as bytes
370
+ */
371
+ export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream;
372
+
373
+ /**
374
+ * @license
375
+ * Copyright 2017 Google LLC
376
+ *
377
+ * Licensed under the Apache License, Version 2.0 (the "License");
378
+ * you may not use this file except in compliance with the License.
379
+ * You may obtain a copy of the License at
380
+ *
381
+ * http://www.apache.org/licenses/LICENSE-2.0
382
+ *
383
+ * Unless required by applicable law or agreed to in writing, software
384
+ * distributed under the License is distributed on an "AS IS" BASIS,
385
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
386
+ * See the License for the specific language governing permissions and
387
+ * limitations under the License.
388
+ */
389
+ /** Network headers */
390
+ declare type Headers_2 = Record<string, string>;
391
+
392
+ /**
393
+ * Internal enum for task state.
394
+ */
395
+ declare const enum InternalTaskState {
396
+ RUNNING = "running",
397
+ PAUSING = "pausing",
398
+ PAUSED = "paused",
399
+ SUCCESS = "success",
400
+ CANCELING = "canceling",
401
+ CANCELED = "canceled",
402
+ ERROR = "error"
403
+ }
404
+
405
+ /**
406
+ * @internal
407
+ */
408
+ export declare function _invalidArgument(message: string): StorageError;
409
+
410
+ /**
411
+ * @param name - The name of the operation that was invalid.
412
+ *
413
+ * @internal
414
+ */
415
+ export declare function _invalidRootOperation(name: string): StorageError;
416
+
417
+ /**
418
+ * List items (files) and prefixes (folders) under this storage reference.
419
+ *
420
+ * List API is only available for Firebase Rules Version 2.
421
+ *
422
+ * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
423
+ * delimited folder structure.
424
+ * Refer to GCS's List API if you want to learn more.
425
+ *
426
+ * To adhere to Firebase Rules's Semantics, Firebase Storage does not
427
+ * support objects whose paths end with "/" or contain two consecutive
428
+ * "/"s. Firebase Storage List API will filter these unsupported objects.
429
+ * list() may fail if there are too many unsupported objects in the bucket.
430
+ * @public
431
+ *
432
+ * @param ref - {@link StorageReference} to get list from.
433
+ * @param options - See {@link ListOptions} for details.
434
+ * @returns A `Promise` that resolves with the items and prefixes.
435
+ * `prefixes` contains references to sub-folders and `items`
436
+ * contains references to objects in this folder. `nextPageToken`
437
+ * can be used to get the rest of the results.
438
+ */
439
+ export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>;
440
+
441
+ /**
442
+ * List all items (files) and prefixes (folders) under this storage reference.
443
+ *
444
+ * This is a helper method for calling list() repeatedly until there are
445
+ * no more results. The default pagination size is 1000.
446
+ *
447
+ * Note: The results may not be consistent if objects are changed while this
448
+ * operation is running.
449
+ *
450
+ * Warning: `listAll` may potentially consume too many resources if there are
451
+ * too many results.
452
+ * @public
453
+ * @param ref - {@link StorageReference} to get list from.
454
+ *
455
+ * @returns A `Promise` that resolves with all the items and prefixes under
456
+ * the current storage reference. `prefixes` contains references to
457
+ * sub-directories and `items` contains references to objects in this
458
+ * folder. `nextPageToken` is never returned.
459
+ */
460
+ export declare function listAll(ref: StorageReference): Promise<ListResult>;
461
+
462
+ /**
463
+ * The options `list()` accepts.
464
+ * @public
465
+ */
466
+ export declare interface ListOptions {
467
+ /**
468
+ * If set, limits the total number of `prefixes` and `items` to return.
469
+ * The default and maximum maxResults is 1000.
470
+ */
471
+ maxResults?: number | null;
472
+ /**
473
+ * The `nextPageToken` from a previous call to `list()`. If provided,
474
+ * listing is resumed from the previous position.
475
+ */
476
+ pageToken?: string | null;
477
+ }
478
+
479
+ /**
480
+ * Result returned by list().
481
+ * @public
482
+ */
483
+ export declare interface ListResult {
484
+ /**
485
+ * References to prefixes (sub-folders). You can call list() on them to
486
+ * get its contents.
487
+ *
488
+ * Folders are implicit based on '/' in the object paths.
489
+ * For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
490
+ * will return '/a/b' as a prefix.
491
+ */
492
+ prefixes: StorageReference[];
493
+ /**
494
+ * Objects in this directory.
495
+ * You can call getMetadata() and getDownloadUrl() on them.
496
+ */
497
+ items: StorageReference[];
498
+ /**
499
+ * If set, there might be more results for this list. Use this token to resume the list.
500
+ */
501
+ nextPageToken?: string;
502
+ }
503
+
504
+ /**
505
+ * @license
506
+ * Copyright 2017 Google LLC
507
+ *
508
+ * Licensed under the Apache License, Version 2.0 (the "License");
509
+ * you may not use this file except in compliance with the License.
510
+ * You may obtain a copy of the License at
511
+ *
512
+ * http://www.apache.org/licenses/LICENSE-2.0
513
+ *
514
+ * Unless required by applicable law or agreed to in writing, software
515
+ * distributed under the License is distributed on an "AS IS" BASIS,
516
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
517
+ * See the License for the specific language governing permissions and
518
+ * limitations under the License.
519
+ */
520
+ /**
521
+ * Firebase Storage location data.
522
+ *
523
+ * @internal
524
+ */
525
+ export declare class _Location {
526
+ readonly bucket: string;
527
+ private path_;
528
+ constructor(bucket: string, path: string);
529
+ get path(): string;
530
+ get isRoot(): boolean;
531
+ fullServerUrl(): string;
532
+ bucketOnlyServerUrl(): string;
533
+ static makeFromBucketSpec(bucketString: string, host: string): _Location;
534
+ static makeFromUrl(url: string, host: string): _Location;
535
+ }
536
+
537
+ /**
538
+ * @fileoverview Documentation for the metadata format.
539
+ */
540
+ /**
541
+ * The full set of object metadata, including read-only properties.
542
+ */
543
+ declare interface Metadata extends FullMetadata {
544
+ [prop: string]: unknown;
545
+ }
546
+
547
+ /**
548
+ * Function that is called once for each value in a stream of values.
549
+ */
550
+ declare type NextFn_2<T> = (value: T) => void;
551
+
552
+ /**
553
+ * Returns a {@link StorageReference} for the given url.
554
+ * @param storage - {@link FirebaseStorage} instance.
555
+ * @param url - URL. If empty, returns root reference.
556
+ * @public
557
+ */
558
+ export declare function ref(storage: FirebaseStorage, url?: string): StorageReference;
559
+
560
+ /**
561
+ * Returns a {@link StorageReference} for the given path in the
562
+ * default bucket.
563
+ * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.
564
+ * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}
565
+ * instance provided) or returns same reference (if {@link StorageReference} provided).
566
+ * @public
567
+ */
568
+ export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference;
569
+
570
+ /**
571
+ * Provides methods to interact with a bucket in the Firebase Storage service.
572
+ * @internal
573
+ * @param _location - An fbs.location, or the URL at
574
+ * which to base this object, in one of the following forms:
575
+ * gs://<bucket>/<object-path>
576
+ * http[s]://firebasestorage.googleapis.com/
577
+ * <api-version>/b/<bucket>/o/<object-path>
578
+ * Any query or fragment strings will be ignored in the http[s]
579
+ * format. If no value is passed, the storage object will use a URL based on
580
+ * the project ID of the base firebase.App instance.
581
+ */
582
+ export declare class _Reference {
583
+ private _service;
584
+ _location: _Location;
585
+ constructor(_service: _FirebaseStorageImpl, location: string | _Location);
586
+ /**
587
+ * Returns the URL for the bucket and path this object references,
588
+ * in the form gs://<bucket>/<object-path>
589
+ * @override
590
+ */
591
+ toString(): string;
592
+ protected _newRef(service: _FirebaseStorageImpl, location: _Location): _Reference;
593
+ /**
594
+ * A reference to the root of this object's bucket.
595
+ */
596
+ get root(): _Reference;
597
+ /**
598
+ * The name of the bucket containing this reference's object.
599
+ */
600
+ get bucket(): string;
601
+ /**
602
+ * The full path of this object.
603
+ */
604
+ get fullPath(): string;
605
+ /**
606
+ * The short name of this object, which is the last component of the full path.
607
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
608
+ */
609
+ get name(): string;
610
+ /**
611
+ * The `StorageService` instance this `StorageReference` is associated with.
612
+ */
613
+ get storage(): _FirebaseStorageImpl;
614
+ /**
615
+ * A `StorageReference` pointing to the parent location of this `StorageReference`, or null if
616
+ * this reference is the root.
617
+ */
618
+ get parent(): _Reference | null;
619
+ /**
620
+ * Utility function to throw an error in methods that do not accept a root reference.
621
+ */
622
+ _throwIfRoot(name: string): void;
623
+ }
624
+
625
+ declare interface Request_2<T> {
626
+ getPromise(): Promise<T>;
627
+ /**
628
+ * Cancels the request. IMPORTANT: the promise may still be resolved with an
629
+ * appropriate value (if the request is finished before you call this method,
630
+ * but the promise has not yet been resolved), so don't just assume it will be
631
+ * rejected if you call this function.
632
+ * @param appDelete - True if the cancelation came from the app being deleted.
633
+ */
634
+ cancel(appDelete?: boolean): void;
635
+ }
636
+
637
+ /**
638
+ * A function that converts a server response to the API type expected by the
639
+ * SDK.
640
+ *
641
+ * @param I - the type of the backend's network response
642
+ * @param O - the output response type used by the rest of the SDK.
643
+ */
644
+ declare type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O;
645
+
646
+ /**
647
+ * Contains a fully specified request.
648
+ *
649
+ * @param I - the type of the backend's network response.
650
+ * @param O - the output response type used by the rest of the SDK.
651
+ */
652
+ declare class RequestInfo_2<I extends ConnectionType, O> {
653
+ url: string;
654
+ method: string;
655
+ /**
656
+ * Returns the value with which to resolve the request's promise. Only called
657
+ * if the request is successful. Throw from this function to reject the
658
+ * returned Request's promise with the thrown error.
659
+ * Note: The XhrIo passed to this function may be reused after this callback
660
+ * returns. Do not keep a reference to it in any way.
661
+ */
662
+ handler: RequestHandler<I, O>;
663
+ timeout: number;
664
+ urlParams: UrlParams;
665
+ headers: Headers_2;
666
+ body: Blob | string | Uint8Array | null;
667
+ errorHandler: ErrorHandler | null;
668
+ /**
669
+ * Called with the current number of bytes uploaded and total size (-1 if not
670
+ * computable) of the request body (i.e. used to report upload progress).
671
+ */
672
+ progressCallback: ((p1: number, p2: number) => void) | null;
673
+ successCodes: number[];
674
+ additionalRetryCodes: number[];
675
+ constructor(url: string, method: string,
676
+ /**
677
+ * Returns the value with which to resolve the request's promise. Only called
678
+ * if the request is successful. Throw from this function to reject the
679
+ * returned Request's promise with the thrown error.
680
+ * Note: The XhrIo passed to this function may be reused after this callback
681
+ * returns. Do not keep a reference to it in any way.
682
+ */
683
+ handler: RequestHandler<I, O>, timeout: number);
684
+ }
685
+
686
+ /**
687
+ * Object metadata that can be set at any time.
688
+ * @public
689
+ */
690
+ export declare interface SettableMetadata {
691
+ /**
692
+ * Served as the 'Cache-Control' header on object download.
693
+ */
694
+ cacheControl?: string | undefined;
695
+ /**
696
+ * Served as the 'Content-Disposition' header on object download.
697
+ */
698
+ contentDisposition?: string | undefined;
699
+ /**
700
+ * Served as the 'Content-Encoding' header on object download.
701
+ */
702
+ contentEncoding?: string | undefined;
703
+ /**
704
+ * Served as the 'Content-Language' header on object download.
705
+ */
706
+ contentLanguage?: string | undefined;
707
+ /**
708
+ * Served as the 'Content-Type' header on object download.
709
+ */
710
+ contentType?: string | undefined;
711
+ /**
712
+ * Additional user-defined custom metadata.
713
+ */
714
+ customMetadata?: {
715
+ [key: string]: string;
716
+ } | undefined;
717
+ }
718
+
719
+ /**
720
+ * An error returned by the Firebase Storage SDK.
721
+ * @public
722
+ */
723
+ export declare class StorageError extends FirebaseError {
724
+ private status_;
725
+ private readonly _baseMessage;
726
+ /**
727
+ * Stores custom error data unique to the `StorageError`.
728
+ */
729
+ customData: {
730
+ serverResponse: string | null;
731
+ };
732
+ /**
733
+ * @param code - A `StorageErrorCode` string to be prefixed with 'storage/' and
734
+ * added to the end of the message.
735
+ * @param message - Error message.
736
+ * @param status_ - Corresponding HTTP Status Code
737
+ */
738
+ constructor(code: StorageErrorCode, message: string, status_?: number);
739
+ get status(): number;
740
+ set status(status: number);
741
+ /**
742
+ * Compares a `StorageErrorCode` against this error's code, filtering out the prefix.
743
+ */
744
+ _codeEquals(code: StorageErrorCode): boolean;
745
+ /**
746
+ * Optional response message that was added by the server.
747
+ */
748
+ get serverResponse(): null | string;
749
+ set serverResponse(serverResponse: string | null);
750
+ }
751
+
752
+ /**
753
+ * @public
754
+ * Error codes that can be attached to `StorageError` objects.
755
+ */
756
+ export declare enum StorageErrorCode {
757
+ UNKNOWN = "unknown",
758
+ OBJECT_NOT_FOUND = "object-not-found",
759
+ BUCKET_NOT_FOUND = "bucket-not-found",
760
+ PROJECT_NOT_FOUND = "project-not-found",
761
+ QUOTA_EXCEEDED = "quota-exceeded",
762
+ UNAUTHENTICATED = "unauthenticated",
763
+ UNAUTHORIZED = "unauthorized",
764
+ UNAUTHORIZED_APP = "unauthorized-app",
765
+ RETRY_LIMIT_EXCEEDED = "retry-limit-exceeded",
766
+ INVALID_CHECKSUM = "invalid-checksum",
767
+ CANCELED = "canceled",
768
+ INVALID_EVENT_NAME = "invalid-event-name",
769
+ INVALID_URL = "invalid-url",
770
+ INVALID_DEFAULT_BUCKET = "invalid-default-bucket",
771
+ NO_DEFAULT_BUCKET = "no-default-bucket",
772
+ CANNOT_SLICE_BLOB = "cannot-slice-blob",
773
+ SERVER_FILE_WRONG_SIZE = "server-file-wrong-size",
774
+ NO_DOWNLOAD_URL = "no-download-url",
775
+ INVALID_ARGUMENT = "invalid-argument",
776
+ INVALID_ARGUMENT_COUNT = "invalid-argument-count",
777
+ APP_DELETED = "app-deleted",
778
+ INVALID_ROOT_OPERATION = "invalid-root-operation",
779
+ INVALID_FORMAT = "invalid-format",
780
+ INTERNAL_ERROR = "internal-error",
781
+ UNSUPPORTED_ENVIRONMENT = "unsupported-environment"
782
+ }
783
+
784
+ /**
785
+ * A stream observer for Firebase Storage.
786
+ * @public
787
+ */
788
+ export declare interface StorageObserver<T> {
789
+ next?: NextFn<T> | null;
790
+ error?: (error: StorageError) => void | null;
791
+ complete?: CompleteFn | null;
792
+ }
793
+
794
+ /**
795
+ * An observer identical to the `Observer` defined in packages/util except the
796
+ * error passed into the ErrorFn is specifically a `StorageError`.
797
+ */
798
+ declare interface StorageObserver_2<T> {
799
+ /**
800
+ * Function that is called once for each value in the event stream.
801
+ */
802
+ next?: NextFn_2<T>;
803
+ /**
804
+ * A function that is called with a `StorageError`
805
+ * if the event stream ends due to an error.
806
+ */
807
+ error?: ErrorFn;
808
+ /**
809
+ * A function that is called if the event stream ends normally.
810
+ */
811
+ complete?: CompleteFn_2;
812
+ }
813
+
814
+ /**
815
+ * Represents a reference to a Google Cloud Storage object. Developers can
816
+ * upload, download, and delete objects, as well as get/set object metadata.
817
+ * @public
818
+ */
819
+ export declare interface StorageReference {
820
+ /**
821
+ * Returns a gs:// URL for this object in the form
822
+ * `gs://<bucket>/<path>/<to>/<object>`
823
+ * @returns The gs:// URL.
824
+ */
825
+ toString(): string;
826
+ /**
827
+ * A reference to the root of this object's bucket.
828
+ */
829
+ root: StorageReference;
830
+ /**
831
+ * The name of the bucket containing this reference's object.
832
+ */
833
+ bucket: string;
834
+ /**
835
+ * The full path of this object.
836
+ */
837
+ fullPath: string;
838
+ /**
839
+ * The short name of this object, which is the last component of the full path.
840
+ * For example, if fullPath is 'full/path/image.png', name is 'image.png'.
841
+ */
842
+ name: string;
843
+ /**
844
+ * The {@link FirebaseStorage} instance associated with this reference.
845
+ */
846
+ storage: FirebaseStorage;
847
+ /**
848
+ * A reference pointing to the parent location of this reference, or null if
849
+ * this reference is the root.
850
+ */
851
+ parent: StorageReference | null;
852
+ }
853
+
854
+ declare class StringData {
855
+ data: Uint8Array;
856
+ contentType: string | null;
857
+ constructor(data: Uint8Array, contentType?: string | null);
858
+ }
859
+
860
+ /**
861
+ * @license
862
+ * Copyright 2017 Google LLC
863
+ *
864
+ * Licensed under the Apache License, Version 2.0 (the "License");
865
+ * you may not use this file except in compliance with the License.
866
+ * You may obtain a copy of the License at
867
+ *
868
+ * http://www.apache.org/licenses/LICENSE-2.0
869
+ *
870
+ * Unless required by applicable law or agreed to in writing, software
871
+ * distributed under the License is distributed on an "AS IS" BASIS,
872
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
873
+ * See the License for the specific language governing permissions and
874
+ * limitations under the License.
875
+ */
876
+ /**
877
+ * An enumeration of the possible string formats for upload.
878
+ * @public
879
+ */
880
+ export declare type StringFormat = (typeof StringFormat)[keyof typeof StringFormat];
881
+
882
+ /**
883
+ * An enumeration of the possible string formats for upload.
884
+ * @public
885
+ */
886
+ export declare const StringFormat: {
887
+ /**
888
+ * Indicates the string should be interpreted "raw", that is, as normal text.
889
+ * The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte
890
+ * sequence.
891
+ * Example: The string 'Hello! \\ud83d\\ude0a' becomes the byte sequence
892
+ * 48 65 6c 6c 6f 21 20 f0 9f 98 8a
893
+ */
894
+ readonly RAW: "raw";
895
+ /**
896
+ * Indicates the string should be interpreted as base64-encoded data.
897
+ * Padding characters (trailing '='s) are optional.
898
+ * Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence
899
+ * ad 69 8e fb e1 3a b7 bf eb 97
900
+ */
901
+ readonly BASE64: "base64";
902
+ /**
903
+ * Indicates the string should be interpreted as base64url-encoded data.
904
+ * Padding characters (trailing '='s) are optional.
905
+ * Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence
906
+ * ad 69 8e fb e1 3a b7 bf eb 97
907
+ */
908
+ readonly BASE64URL: "base64url";
909
+ /**
910
+ * Indicates the string is a data URL, such as one obtained from
911
+ * canvas.toDataURL().
912
+ * Example: the string 'data:application/octet-stream;base64,aaaa'
913
+ * becomes the byte sequence
914
+ * 69 a6 9a
915
+ * (the content-type "application/octet-stream" is also applied, but can
916
+ * be overridden in the metadata object).
917
+ */
918
+ readonly DATA_URL: "data_url";
919
+ };
920
+
921
+ /**
922
+ * Subscribes to an event stream.
923
+ */
924
+ declare type Subscribe_2<T> = (next?: NextFn_2<T> | StorageObserver_2<T>, error?: ErrorFn, complete?: CompleteFn_2) => Unsubscribe_2;
925
+
926
+ /**
927
+ * An event that is triggered on a task.
928
+ * @public
929
+ */
930
+ export declare type TaskEvent = 'state_changed';
931
+
932
+ /**
933
+ * @license
934
+ * Copyright 2017 Google LLC
935
+ *
936
+ * Licensed under the Apache License, Version 2.0 (the "License");
937
+ * you may not use this file except in compliance with the License.
938
+ * You may obtain a copy of the License at
939
+ *
940
+ * http://www.apache.org/licenses/LICENSE-2.0
941
+ *
942
+ * Unless required by applicable law or agreed to in writing, software
943
+ * distributed under the License is distributed on an "AS IS" BASIS,
944
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
945
+ * See the License for the specific language governing permissions and
946
+ * limitations under the License.
947
+ */
948
+ /**
949
+ * @fileoverview Enumerations used for upload tasks.
950
+ */
951
+ /**
952
+ * An event that is triggered on a task.
953
+ * @internal
954
+ */
955
+ export declare type _TaskEvent = string;
956
+
957
+ /**
958
+ * An event that is triggered on a task.
959
+ * @internal
960
+ */
961
+ export declare const _TaskEvent: {
962
+ /**
963
+ * For this event,
964
+ * <ul>
965
+ * <li>The `next` function is triggered on progress updates and when the
966
+ * task is paused/resumed with an `UploadTaskSnapshot` as the first
967
+ * argument.</li>
968
+ * <li>The `error` function is triggered if the upload is canceled or fails
969
+ * for another reason.</li>
970
+ * <li>The `complete` function is triggered if the upload completes
971
+ * successfully.</li>
972
+ * </ul>
973
+ */
974
+ STATE_CHANGED: string;
975
+ };
976
+
977
+ /**
978
+ * Represents the current state of a running upload.
979
+ * @public
980
+ */
981
+ export declare type TaskState = 'running' | 'paused' | 'success' | 'canceled' | 'error';
982
+
983
+ /**
984
+ * Represents the current state of a running upload.
985
+ * @internal
986
+ */
987
+ export declare type _TaskState = (typeof _TaskState)[keyof typeof _TaskState];
988
+
989
+ /**
990
+ * Represents the current state of a running upload.
991
+ * @internal
992
+ */
993
+ export declare const _TaskState: {
994
+ /** The task is currently transferring data. */
995
+ readonly RUNNING: "running";
996
+ /** The task was paused by the user. */
997
+ readonly PAUSED: "paused";
998
+ /** The task completed successfully. */
999
+ readonly SUCCESS: "success";
1000
+ /** The task was canceled. */
1001
+ readonly CANCELED: "canceled";
1002
+ /** The task failed with an error. */
1003
+ readonly ERROR: "error";
1004
+ };
1005
+
1006
+ /**
1007
+ * Unsubscribes from a stream.
1008
+ */
1009
+ declare type Unsubscribe_2 = () => void;
1010
+
1011
+ /**
1012
+ * Updates the metadata for this object.
1013
+ * @public
1014
+ * @param ref - {@link StorageReference} to update metadata for.
1015
+ * @param metadata - The new metadata for the object.
1016
+ * Only values that have been explicitly set will be changed. Explicitly
1017
+ * setting a value to null will remove the metadata.
1018
+ * @returns A `Promise` that resolves with the new metadata for this object.
1019
+ */
1020
+ export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>;
1021
+
1022
+ /**
1023
+ * Uploads data to this object's location.
1024
+ * The upload is not resumable.
1025
+ * @public
1026
+ * @param ref - {@link StorageReference} where data should be uploaded.
1027
+ * @param data - The data to upload.
1028
+ * @param metadata - Metadata for the data to upload.
1029
+ * @returns A Promise containing an UploadResult
1030
+ */
1031
+ export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>;
1032
+
1033
+ /**
1034
+ * Uploads data to this object's location.
1035
+ * The upload can be paused and resumed, and exposes progress updates.
1036
+ * @public
1037
+ * @param ref - {@link StorageReference} where data should be uploaded.
1038
+ * @param data - The data to upload.
1039
+ * @param metadata - Metadata for the data to upload.
1040
+ * @returns An UploadTask
1041
+ */
1042
+ export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask;
1043
+
1044
+ /**
1045
+ * Object metadata that can be set at upload.
1046
+ * @public
1047
+ */
1048
+ export declare interface UploadMetadata extends SettableMetadata {
1049
+ /**
1050
+ * A Base64-encoded MD5 hash of the object being uploaded.
1051
+ */
1052
+ md5Hash?: string | undefined;
1053
+ }
1054
+
1055
+ /**
1056
+ * Result returned from a non-resumable upload.
1057
+ * @public
1058
+ */
1059
+ export declare interface UploadResult {
1060
+ /**
1061
+ * Contains the metadata sent back from the server.
1062
+ */
1063
+ readonly metadata: FullMetadata;
1064
+ /**
1065
+ * The reference that spawned this upload.
1066
+ */
1067
+ readonly ref: StorageReference;
1068
+ }
1069
+
1070
+ /**
1071
+ * Uploads a string to this object's location.
1072
+ * The upload is not resumable.
1073
+ * @public
1074
+ * @param ref - {@link StorageReference} where string should be uploaded.
1075
+ * @param value - The string to upload.
1076
+ * @param format - The format of the string to upload.
1077
+ * @param metadata - Metadata for the string to upload.
1078
+ * @returns A Promise containing an UploadResult
1079
+ */
1080
+ export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>;
1081
+
1082
+ /**
1083
+ * Represents the process of uploading an object. Allows you to monitor and
1084
+ * manage the upload.
1085
+ * @public
1086
+ */
1087
+ export declare interface UploadTask {
1088
+ /**
1089
+ * Cancels a running task. Has no effect on a complete or failed task.
1090
+ * @returns True if the cancel had an effect.
1091
+ */
1092
+ cancel(): boolean;
1093
+ /**
1094
+ * Equivalent to calling `then(null, onRejected)`.
1095
+ */
1096
+ catch(onRejected: (error: StorageError) => unknown): Promise<unknown>;
1097
+ /**
1098
+ * Listens for events on this task.
1099
+ *
1100
+ * Events have three callback functions (referred to as `next`, `error`, and
1101
+ * `complete`).
1102
+ *
1103
+ * If only the event is passed, a function that can be used to register the
1104
+ * callbacks is returned. Otherwise, the callbacks are passed after the event.
1105
+ *
1106
+ * Callbacks can be passed either as three separate arguments <em>or</em> as the
1107
+ * `next`, `error`, and `complete` properties of an object. Any of the three
1108
+ * callbacks is optional, as long as at least one is specified. In addition,
1109
+ * when you add your callbacks, you get a function back. You can call this
1110
+ * function to unregister the associated callbacks.
1111
+ *
1112
+ * @example **Pass callbacks separately or in an object.**
1113
+ * ```javascript
1114
+ * var next = function(snapshot) {};
1115
+ * var error = function(error) {};
1116
+ * var complete = function() {};
1117
+ *
1118
+ * // The first example.
1119
+ * uploadTask.on(
1120
+ * firebase.storage.TaskEvent.STATE_CHANGED,
1121
+ * next,
1122
+ * error,
1123
+ * complete);
1124
+ *
1125
+ * // This is equivalent to the first example.
1126
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
1127
+ * 'next': next,
1128
+ * 'error': error,
1129
+ * 'complete': complete
1130
+ * });
1131
+ *
1132
+ * // This is equivalent to the first example.
1133
+ * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
1134
+ * subscribe(next, error, complete);
1135
+ *
1136
+ * // This is equivalent to the first example.
1137
+ * var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
1138
+ * subscribe({
1139
+ * 'next': next,
1140
+ * 'error': error,
1141
+ * 'complete': complete
1142
+ * });
1143
+ * ```
1144
+ *
1145
+ * @example **Any callback is optional.**
1146
+ * ```javascript
1147
+ * // Just listening for completion, this is legal.
1148
+ * uploadTask.on(
1149
+ * firebase.storage.TaskEvent.STATE_CHANGED,
1150
+ * null,
1151
+ * null,
1152
+ * function() {
1153
+ * console.log('upload complete!');
1154
+ * });
1155
+ *
1156
+ * // Just listening for progress/state changes, this is legal.
1157
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
1158
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
1159
+ * console.log(percent + "% done");
1160
+ * });
1161
+ *
1162
+ * // This is also legal.
1163
+ * uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
1164
+ * 'complete': function() {
1165
+ * console.log('upload complete!');
1166
+ * }
1167
+ * });
1168
+ * ```
1169
+ *
1170
+ * @example **Use the returned function to remove callbacks.**
1171
+ * ```javascript
1172
+ * var unsubscribe = uploadTask.on(
1173
+ * firebase.storage.TaskEvent.STATE_CHANGED,
1174
+ * function(snapshot) {
1175
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
1176
+ * console.log(percent + "% done");
1177
+ * // Stop after receiving one update.
1178
+ * unsubscribe();
1179
+ * });
1180
+ *
1181
+ * // This code is equivalent to the above.
1182
+ * var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
1183
+ * unsubscribe = handle(function(snapshot) {
1184
+ * var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
1185
+ * console.log(percent + "% done");
1186
+ * // Stop after receiving one update.
1187
+ * unsubscribe();
1188
+ * });
1189
+ * ```
1190
+ *
1191
+ * @param event - The type of event to listen for.
1192
+ * @param nextOrObserver -
1193
+ * The `next` function, which gets called for each item in
1194
+ * the event stream, or an observer object with some or all of these three
1195
+ * properties (`next`, `error`, `complete`).
1196
+ * @param error - A function that gets called with a `StorageError`
1197
+ * if the event stream ends due to an error.
1198
+ * @param completed - A function that gets called if the
1199
+ * event stream ends normally.
1200
+ * @returns
1201
+ * If only the event argument is passed, returns a function you can use to
1202
+ * add callbacks (see the examples above). If more than just the event
1203
+ * argument is passed, returns a function you can call to unregister the
1204
+ * callbacks.
1205
+ */
1206
+ on(event: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, complete?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
1207
+ /**
1208
+ * Pauses a currently running task. Has no effect on a paused or failed task.
1209
+ * @returns True if the operation took effect, false if ignored.
1210
+ */
1211
+ pause(): boolean;
1212
+ /**
1213
+ * Resumes a paused task. Has no effect on a currently running or failed task.
1214
+ * @returns True if the operation took effect, false if ignored.
1215
+ */
1216
+ resume(): boolean;
1217
+ /**
1218
+ * A snapshot of the current task state.
1219
+ */
1220
+ snapshot: UploadTaskSnapshot;
1221
+ /**
1222
+ * This object behaves like a Promise, and resolves with its snapshot data
1223
+ * when the upload completes.
1224
+ * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
1225
+ * @param onRejected - The rejection callback.
1226
+ */
1227
+ then(onFulfilled?: ((snapshot: UploadTaskSnapshot) => unknown) | null, onRejected?: ((error: StorageError) => unknown) | null): Promise<unknown>;
1228
+ }
1229
+
1230
+ /**
1231
+ * Represents a blob being uploaded. Can be used to pause/resume/cancel the
1232
+ * upload and manage callbacks for various events.
1233
+ * @internal
1234
+ */
1235
+ export declare class _UploadTask {
1236
+ private _ref;
1237
+ /**
1238
+ * The data to be uploaded.
1239
+ */
1240
+ _blob: _FbsBlob;
1241
+ /**
1242
+ * Metadata related to the upload.
1243
+ */
1244
+ _metadata: Metadata | null;
1245
+ private _mappings;
1246
+ /**
1247
+ * Number of bytes transferred so far.
1248
+ */
1249
+ _transferred: number;
1250
+ private _needToFetchStatus;
1251
+ private _needToFetchMetadata;
1252
+ private _observers;
1253
+ private _resumable;
1254
+ /**
1255
+ * Upload state.
1256
+ */
1257
+ _state: InternalTaskState;
1258
+ private _error?;
1259
+ private _uploadUrl?;
1260
+ private _request?;
1261
+ private _chunkMultiplier;
1262
+ private _errorHandler;
1263
+ private _metadataErrorHandler;
1264
+ private _resolve?;
1265
+ private _reject?;
1266
+ private pendingTimeout?;
1267
+ private _promise;
1268
+ private sleepTime;
1269
+ private maxSleepTime;
1270
+ isExponentialBackoffExpired(): boolean;
1271
+ /**
1272
+ * @param ref - The firebaseStorage.Reference object this task came
1273
+ * from, untyped to avoid cyclic dependencies.
1274
+ * @param blob - The blob to upload.
1275
+ */
1276
+ constructor(ref: _Reference, blob: _FbsBlob, metadata?: Metadata | null);
1277
+ private _makeProgressCallback;
1278
+ private _shouldDoResumable;
1279
+ private _start;
1280
+ private _resolveToken;
1281
+ private _createResumable;
1282
+ private _fetchStatus;
1283
+ private _continueUpload;
1284
+ private _increaseMultiplier;
1285
+ private _fetchMetadata;
1286
+ private _oneShotUpload;
1287
+ private _updateProgress;
1288
+ private _transition;
1289
+ private completeTransitions_;
1290
+ /**
1291
+ * A snapshot of the current task state.
1292
+ */
1293
+ get snapshot(): UploadTaskSnapshot;
1294
+ /**
1295
+ * Adds a callback for an event.
1296
+ * @param type - The type of event to listen for.
1297
+ * @param nextOrObserver -
1298
+ * The `next` function, which gets called for each item in
1299
+ * the event stream, or an observer object with some or all of these three
1300
+ * properties (`next`, `error`, `complete`).
1301
+ * @param error - A function that gets called with a `StorageError`
1302
+ * if the event stream ends due to an error.
1303
+ * @param completed - A function that gets called if the
1304
+ * event stream ends normally.
1305
+ * @returns
1306
+ * If only the event argument is passed, returns a function you can use to
1307
+ * add callbacks (see the examples above). If more than just the event
1308
+ * argument is passed, returns a function you can call to unregister the
1309
+ * callbacks.
1310
+ */
1311
+ on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>;
1312
+ /**
1313
+ * This object behaves like a Promise, and resolves with its snapshot data
1314
+ * when the upload completes.
1315
+ * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
1316
+ * @param onRejected - The rejection callback.
1317
+ */
1318
+ then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>;
1319
+ /**
1320
+ * Equivalent to calling `then(null, onRejected)`.
1321
+ */
1322
+ catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>;
1323
+ /**
1324
+ * Adds the given observer.
1325
+ */
1326
+ private _addObserver;
1327
+ /**
1328
+ * Removes the given observer.
1329
+ */
1330
+ private _removeObserver;
1331
+ private _notifyObservers;
1332
+ private _finishPromise;
1333
+ private _notifyObserver;
1334
+ /**
1335
+ * Resumes a paused task. Has no effect on a currently running or failed task.
1336
+ * @returns True if the operation took effect, false if ignored.
1337
+ */
1338
+ resume(): boolean;
1339
+ /**
1340
+ * Pauses a currently running task. Has no effect on a paused or failed task.
1341
+ * @returns True if the operation took effect, false if ignored.
1342
+ */
1343
+ pause(): boolean;
1344
+ /**
1345
+ * Cancels a currently running or paused task. Has no effect on a complete or
1346
+ * failed task.
1347
+ * @returns True if the operation took effect, false if ignored.
1348
+ */
1349
+ cancel(): boolean;
1350
+ }
1351
+
1352
+ /**
1353
+ * Holds data about the current state of the upload task.
1354
+ * @public
1355
+ */
1356
+ export declare interface UploadTaskSnapshot {
1357
+ /**
1358
+ * The number of bytes that have been successfully uploaded so far.
1359
+ */
1360
+ bytesTransferred: number;
1361
+ /**
1362
+ * Before the upload completes, contains the metadata sent to the server.
1363
+ * After the upload completes, contains the metadata sent back from the server.
1364
+ */
1365
+ metadata: FullMetadata;
1366
+ /**
1367
+ * The reference that spawned this snapshot's upload task.
1368
+ */
1369
+ ref: StorageReference;
1370
+ /**
1371
+ * The current state of the task.
1372
+ */
1373
+ state: TaskState;
1374
+ /**
1375
+ * The task of which this is a snapshot.
1376
+ */
1377
+ task: UploadTask;
1378
+ /**
1379
+ * The total number of bytes to be uploaded.
1380
+ */
1381
+ totalBytes: number;
1382
+ }
1383
+
1384
+ /**
1385
+ * Type for url params stored in RequestInfo.
1386
+ */
1387
+ declare interface UrlParams {
1388
+ [name: string]: string | number;
1389
+ }
1390
+
1391
+ export { }