@firebase/storage 0.9.10 → 0.9.11-20221010190246

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.
@@ -21,12 +21,18 @@
21
21
  declare type id = (p1: boolean) => void;
22
22
  export { id };
23
23
  /**
24
- * @param f May be invoked
25
- * before the function returns.
26
- * @param callback Get all the arguments passed to the function
27
- * passed to f, including the initial boolean.
24
+ * Accepts a callback for an action to perform (`doRequest`),
25
+ * and then a callback for when the backoff has completed (`backoffCompleteCb`).
26
+ * The callback sent to start requires an argument to call (`onRequestComplete`).
27
+ * When `start` calls `doRequest`, it passes a callback for when the request has
28
+ * completed, `onRequestComplete`. Based on this, the backoff continues, with
29
+ * another call to `doRequest` and the above loop continues until the timeout
30
+ * is hit, or a successful response occurs.
31
+ * @description
32
+ * @param doRequest Callback to perform request
33
+ * @param backoffCompleteCb Callback to call when backoff has been completed
28
34
  */
29
- export declare function start(f: (p1: (success: boolean) => void, canceled: boolean) => void, callback: (...args: any[]) => unknown, timeout: number): id;
35
+ export declare function start(doRequest: (onRequestComplete: (success: boolean) => void, canceled: boolean) => void, backoffCompleteCb: (...args: any[]) => unknown, timeout: number): id;
30
36
  /**
31
37
  * Stops the retry loop from repeating.
32
38
  * If the function is currently "in between" retries, it is invoked immediately
@@ -37,6 +37,10 @@ export declare const DEFAULT_MAX_OPERATION_RETRY_TIME: number;
37
37
  * The timeout for upload.
38
38
  */
39
39
  export declare const DEFAULT_MAX_UPLOAD_RETRY_TIME: number;
40
+ /**
41
+ * 1 second
42
+ */
43
+ export declare const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;
40
44
  /**
41
45
  * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported
42
46
  * enough for us to use it directly.
@@ -20,6 +20,7 @@ import { FirebaseError } from '@firebase/util';
20
20
  * @public
21
21
  */
22
22
  export declare class StorageError extends FirebaseError {
23
+ private status_;
23
24
  private readonly _baseMessage;
24
25
  /**
25
26
  * Stores custom error data unque to StorageError.
@@ -31,8 +32,11 @@ export declare class StorageError extends FirebaseError {
31
32
  * @param code - A StorageErrorCode string to be prefixed with 'storage/' and
32
33
  * added to the end of the message.
33
34
  * @param message - Error message.
35
+ * @param status_ - Corresponding HTTP Status Code
34
36
  */
35
- constructor(code: StorageErrorCode, message: string);
37
+ constructor(code: StorageErrorCode, message: string, status_?: number);
38
+ get status(): number;
39
+ set status(status: number);
36
40
  /**
37
41
  * Compares a StorageErrorCode against this error's code, filtering out the prefix.
38
42
  */
@@ -44,4 +44,4 @@ export declare function addAuthHeader_(headers: Headers, authToken: string | nul
44
44
  export declare function addVersionHeader_(headers: Headers, firebaseVersion?: string): void;
45
45
  export declare function addGmpidHeader_(headers: Headers, appId: string | null): void;
46
46
  export declare function addAppCheckHeader_(headers: Headers, appCheckToken: string | null): void;
47
- export declare function makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection<I>, firebaseVersion?: string): Request<O>;
47
+ export declare function makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection<I>, firebaseVersion?: string, retry?: boolean): Request<O>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Checks the status code to see if the action should be retried.
19
+ *
20
+ * @param status Current HTTP status code returned by server.
21
+ * @param additionalRetryCodes additional retry codes to check against
22
+ */
23
+ export declare function isRetryStatusCode(status: number, additionalRetryCodes: number[]): boolean;
@@ -125,6 +125,6 @@ export declare class FirebaseStorageImpl implements FirebaseStorage {
125
125
  * @param requestInfo - HTTP RequestInfo object
126
126
  * @param authToken - Firebase auth token
127
127
  */
128
- _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request<O>;
128
+ _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request<O>;
129
129
  makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>): Promise<O>;
130
130
  }
@@ -24,6 +24,7 @@ import { Metadata } from './metadata';
24
24
  import { Subscribe, Unsubscribe } from './implementation/observer';
25
25
  import { UploadTaskSnapshot, StorageObserver } from './public-types';
26
26
  import { Reference } from './reference';
27
+ import { CompleteFn } from '@firebase/util';
27
28
  /**
28
29
  * Represents a blob being uploaded. Can be used to pause/resume/cancel the
29
30
  * upload and manage callbacks for various events.
@@ -61,6 +62,9 @@ export declare class UploadTask {
61
62
  private _resolve?;
62
63
  private _reject?;
63
64
  private _promise;
65
+ private sleepTime;
66
+ private maxSleepTime;
67
+ isExponentialBackoffExpired(): boolean;
64
68
  /**
65
69
  * @param ref - The firebaseStorage.Reference object this task came
66
70
  * from, untyped to avoid cyclic dependencies.
@@ -101,7 +105,7 @@ export declare class UploadTask {
101
105
  * argument is passed, returns a function you can call to unregister the
102
106
  * callbacks.
103
107
  */
104
- on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
108
+ on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
105
109
  /**
106
110
  * This object behaves like a Promise, and resolves with its snapshot data
107
111
  * when the upload completes.
@@ -41,7 +41,20 @@ interface Response {
41
41
  body: string;
42
42
  headers: Headers;
43
43
  }
44
- declare type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
44
+ export declare type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
45
45
  export declare function storageServiceWithHandler(handler: RequestHandler): FirebaseStorageImpl;
46
46
  export declare function fakeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
47
+ /**
48
+ * Responds with a 503 for finalize.
49
+ * @param fakeMetadata metadata to respond with for query
50
+ * @returns a handler for requests
51
+ */
52
+ export declare function fake503ForFinalizeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
53
+ /**
54
+ * Responds with a 503 for upload.
55
+ * @param fakeMetadata metadata to respond with for query
56
+ * @returns a handler for requests
57
+ */
58
+ export declare function fake503ForUploadServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
59
+ export declare function fakeOneShot503ServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
47
60
  export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};
@@ -21,12 +21,18 @@
21
21
  declare type id = (p1: boolean) => void;
22
22
  export { id };
23
23
  /**
24
- * @param f May be invoked
25
- * before the function returns.
26
- * @param callback Get all the arguments passed to the function
27
- * passed to f, including the initial boolean.
24
+ * Accepts a callback for an action to perform (`doRequest`),
25
+ * and then a callback for when the backoff has completed (`backoffCompleteCb`).
26
+ * The callback sent to start requires an argument to call (`onRequestComplete`).
27
+ * When `start` calls `doRequest`, it passes a callback for when the request has
28
+ * completed, `onRequestComplete`. Based on this, the backoff continues, with
29
+ * another call to `doRequest` and the above loop continues until the timeout
30
+ * is hit, or a successful response occurs.
31
+ * @description
32
+ * @param doRequest Callback to perform request
33
+ * @param backoffCompleteCb Callback to call when backoff has been completed
28
34
  */
29
- export declare function start(f: (p1: (success: boolean) => void, canceled: boolean) => void, callback: (...args: any[]) => unknown, timeout: number): id;
35
+ export declare function start(doRequest: (onRequestComplete: (success: boolean) => void, canceled: boolean) => void, backoffCompleteCb: (...args: any[]) => unknown, timeout: number): id;
30
36
  /**
31
37
  * Stops the retry loop from repeating.
32
38
  * If the function is currently "in between" retries, it is invoked immediately
@@ -37,6 +37,10 @@ export declare const DEFAULT_MAX_OPERATION_RETRY_TIME: number;
37
37
  * The timeout for upload.
38
38
  */
39
39
  export declare const DEFAULT_MAX_UPLOAD_RETRY_TIME: number;
40
+ /**
41
+ * 1 second
42
+ */
43
+ export declare const DEFAULT_MIN_SLEEP_TIME_MILLIS = 1000;
40
44
  /**
41
45
  * This is the value of Number.MIN_SAFE_INTEGER, which is not well supported
42
46
  * enough for us to use it directly.
@@ -20,6 +20,7 @@ import { FirebaseError } from '@firebase/util';
20
20
  * @public
21
21
  */
22
22
  export declare class StorageError extends FirebaseError {
23
+ private status_;
23
24
  private readonly _baseMessage;
24
25
  /**
25
26
  * Stores custom error data unque to StorageError.
@@ -31,8 +32,11 @@ export declare class StorageError extends FirebaseError {
31
32
  * @param code - A StorageErrorCode string to be prefixed with 'storage/' and
32
33
  * added to the end of the message.
33
34
  * @param message - Error message.
35
+ * @param status_ - Corresponding HTTP Status Code
34
36
  */
35
- constructor(code: StorageErrorCode, message: string);
37
+ constructor(code: StorageErrorCode, message: string, status_?: number);
38
+ get status(): number;
39
+ set status(status: number);
36
40
  /**
37
41
  * Compares a StorageErrorCode against this error's code, filtering out the prefix.
38
42
  */
@@ -44,4 +44,4 @@ export declare function addAuthHeader_(headers: Headers, authToken: string | nul
44
44
  export declare function addVersionHeader_(headers: Headers, firebaseVersion?: string): void;
45
45
  export declare function addGmpidHeader_(headers: Headers, appId: string | null): void;
46
46
  export declare function addAppCheckHeader_(headers: Headers, appCheckToken: string | null): void;
47
- export declare function makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection<I>, firebaseVersion?: string): Request<O>;
47
+ export declare function makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, appId: string | null, authToken: string | null, appCheckToken: string | null, requestFactory: () => Connection<I>, firebaseVersion?: string, retry?: boolean): Request<O>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Checks the status code to see if the action should be retried.
19
+ *
20
+ * @param status Current HTTP status code returned by server.
21
+ * @param additionalRetryCodes additional retry codes to check against
22
+ */
23
+ export declare function isRetryStatusCode(status: number, additionalRetryCodes: number[]): boolean;
@@ -125,6 +125,6 @@ export declare class FirebaseStorageImpl implements FirebaseStorage {
125
125
  * @param requestInfo - HTTP RequestInfo object
126
126
  * @param authToken - Firebase auth token
127
127
  */
128
- _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request<O>;
128
+ _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request<O>;
129
129
  makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>): Promise<O>;
130
130
  }
@@ -24,6 +24,7 @@ import { Metadata } from './metadata';
24
24
  import { Subscribe, Unsubscribe } from './implementation/observer';
25
25
  import { UploadTaskSnapshot, StorageObserver } from './public-types';
26
26
  import { Reference } from './reference';
27
+ import { CompleteFn } from '@firebase/util';
27
28
  /**
28
29
  * Represents a blob being uploaded. Can be used to pause/resume/cancel the
29
30
  * upload and manage callbacks for various events.
@@ -61,6 +62,9 @@ export declare class UploadTask {
61
62
  private _resolve?;
62
63
  private _reject?;
63
64
  private _promise;
65
+ private sleepTime;
66
+ private maxSleepTime;
67
+ isExponentialBackoffExpired(): boolean;
64
68
  /**
65
69
  * @param ref - The firebaseStorage.Reference object this task came
66
70
  * from, untyped to avoid cyclic dependencies.
@@ -101,7 +105,7 @@ export declare class UploadTask {
101
105
  * argument is passed, returns a function you can call to unregister the
102
106
  * callbacks.
103
107
  */
104
- on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: Unsubscribe | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
108
+ on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
105
109
  /**
106
110
  * This object behaves like a Promise, and resolves with its snapshot data
107
111
  * when the upload completes.
package/dist/storage.d.ts CHANGED
@@ -235,7 +235,7 @@ export declare class _FirebaseStorageImpl implements FirebaseStorage {
235
235
  * @param requestInfo - HTTP RequestInfo object
236
236
  * @param authToken - Firebase auth token
237
237
  */
238
- _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request_2<O>;
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
239
  makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>;
240
240
  }
241
241
 
@@ -733,6 +733,7 @@ export declare interface StorageError extends FirebaseError {
733
733
  * @public
734
734
  */
735
735
  declare class StorageError_2 extends FirebaseError {
736
+ private status_;
736
737
  private readonly _baseMessage;
737
738
  /**
738
739
  * Stores custom error data unque to StorageError.
@@ -744,8 +745,11 @@ declare class StorageError_2 extends FirebaseError {
744
745
  * @param code - A StorageErrorCode string to be prefixed with 'storage/' and
745
746
  * added to the end of the message.
746
747
  * @param message - Error message.
748
+ * @param status_ - Corresponding HTTP Status Code
747
749
  */
748
- constructor(code: StorageErrorCode, message: string);
750
+ constructor(code: StorageErrorCode, message: string, status_?: number);
751
+ get status(): number;
752
+ set status(status: number);
749
753
  /**
750
754
  * Compares a StorageErrorCode against this error's code, filtering out the prefix.
751
755
  */
@@ -1272,6 +1276,9 @@ export declare class _UploadTask {
1272
1276
  private _resolve?;
1273
1277
  private _reject?;
1274
1278
  private _promise;
1279
+ private sleepTime;
1280
+ private maxSleepTime;
1281
+ isExponentialBackoffExpired(): boolean;
1275
1282
  /**
1276
1283
  * @param ref - The firebaseStorage.Reference object this task came
1277
1284
  * from, untyped to avoid cyclic dependencies.
@@ -1312,7 +1319,7 @@ export declare class _UploadTask {
1312
1319
  * argument is passed, returns a function you can call to unregister the
1313
1320
  * callbacks.
1314
1321
  */
1315
- on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError_2) => unknown) | null, completed?: Unsubscribe_2 | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>;
1322
+ on(type: _TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError_2) => unknown) | null, completed?: CompleteFn | null): Unsubscribe_2 | Subscribe_2<UploadTaskSnapshot>;
1316
1323
  /**
1317
1324
  * This object behaves like a Promise, and resolves with its snapshot data
1318
1325
  * when the upload completes.
@@ -41,7 +41,20 @@ interface Response {
41
41
  body: string;
42
42
  headers: Headers;
43
43
  }
44
- declare type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
44
+ export declare type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
45
45
  export declare function storageServiceWithHandler(handler: RequestHandler): FirebaseStorageImpl;
46
46
  export declare function fakeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
47
+ /**
48
+ * Responds with a 503 for finalize.
49
+ * @param fakeMetadata metadata to respond with for query
50
+ * @returns a handler for requests
51
+ */
52
+ export declare function fake503ForFinalizeServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
53
+ /**
54
+ * Responds with a 503 for upload.
55
+ * @param fakeMetadata metadata to respond with for query
56
+ * @returns a handler for requests
57
+ */
58
+ export declare function fake503ForUploadServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
59
+ export declare function fakeOneShot503ServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
47
60
  export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/storage",
3
- "version": "0.9.10",
3
+ "version": "0.9.11-20221010190246",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.node.cjs.js",
@@ -42,17 +42,17 @@
42
42
  },
43
43
  "license": "Apache-2.0",
44
44
  "dependencies": {
45
- "@firebase/util": "1.7.0",
46
- "@firebase/component": "0.5.18",
45
+ "@firebase/util": "1.7.1-20221010190246",
46
+ "@firebase/component": "0.5.19-20221010190246",
47
47
  "node-fetch": "2.6.7",
48
48
  "tslib": "^2.1.0"
49
49
  },
50
50
  "peerDependencies": {
51
- "@firebase/app": "0.x"
51
+ "@firebase/app": "0.8.1-20221010190246"
52
52
  },
53
53
  "devDependencies": {
54
- "@firebase/app": "0.8.0",
55
- "@firebase/auth": "0.20.8",
54
+ "@firebase/app": "0.8.1-20221010190246",
55
+ "@firebase/auth": "0.20.9-20221010190246",
56
56
  "rollup": "2.72.1",
57
57
  "@rollup/plugin-alias": "3.1.9",
58
58
  "@rollup/plugin-json": "4.1.0",