@firebase/storage 0.8.7 → 0.9.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/CHANGELOG.md +10 -0
- package/dist/index.browser.cjs.js +198 -25
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.esm2017.js +177 -26
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +196 -26
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +245 -45
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +189 -46
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api.browser.d.ts +32 -1
- package/dist/node-esm/src/api.d.ts +15 -0
- package/dist/node-esm/src/api.node.d.ts +32 -1
- package/dist/node-esm/src/implementation/connection.d.ts +14 -4
- package/dist/node-esm/src/implementation/request.d.ts +5 -5
- package/dist/node-esm/src/implementation/requestinfo.d.ts +14 -6
- package/dist/node-esm/src/implementation/requests.d.ts +17 -16
- package/dist/node-esm/src/platform/browser/connection.d.ts +24 -7
- package/dist/node-esm/src/platform/connection.d.ts +6 -2
- package/dist/node-esm/src/platform/node/connection.d.ts +30 -14
- package/dist/node-esm/src/reference.d.ts +13 -0
- package/dist/node-esm/src/service.d.ts +3 -3
- package/dist/node-esm/test/integration/integration.test.d.ts +4 -0
- package/dist/node-esm/test/{unit → node}/connection.test.d.ts +0 -0
- package/dist/{test/unit/connection.test.d.ts → node-esm/test/node/stream.test.d.ts} +0 -0
- package/dist/node-esm/test/unit/connection.d.ts +4 -3
- package/dist/node-esm/test/unit/testshared.d.ts +2 -2
- package/dist/src/api.browser.d.ts +32 -1
- package/dist/src/api.d.ts +15 -0
- package/dist/src/api.node.d.ts +32 -1
- package/dist/src/implementation/connection.d.ts +14 -4
- package/dist/src/implementation/request.d.ts +5 -5
- package/dist/src/implementation/requestinfo.d.ts +14 -6
- package/dist/src/implementation/requests.d.ts +17 -16
- package/dist/src/platform/browser/connection.d.ts +24 -7
- package/dist/src/platform/connection.d.ts +6 -2
- package/dist/src/platform/node/connection.d.ts +30 -14
- package/dist/src/reference.d.ts +13 -0
- package/dist/src/service.d.ts +3 -3
- package/dist/storage-public.d.ts +46 -0
- package/dist/storage.d.ts +80 -11
- package/dist/test/integration/integration.test.d.ts +4 -0
- package/dist/test/node/connection.test.d.ts +17 -0
- package/dist/test/node/stream.test.d.ts +17 -0
- package/dist/test/unit/connection.d.ts +4 -3
- package/dist/test/unit/testshared.d.ts +2 -2
- package/package.json +2 -2
|
@@ -14,21 +14,31 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
/// <reference types="node" />
|
|
17
18
|
/** Network headers */
|
|
18
19
|
export declare type Headers = Record<string, string>;
|
|
20
|
+
/** Response type exposed by the networking APIs. */
|
|
21
|
+
export declare type ConnectionType = string | ArrayBuffer | Blob | NodeJS.ReadableStream;
|
|
19
22
|
/**
|
|
20
23
|
* A lightweight wrapper around XMLHttpRequest with a
|
|
21
24
|
* goog.net.XhrIo-like interface.
|
|
25
|
+
*
|
|
26
|
+
* You can create a new connection by invoking `newTextConnection()`,
|
|
27
|
+
* `newBytesConnection()` or `newStreamConnection()`.
|
|
22
28
|
*/
|
|
23
|
-
export interface Connection {
|
|
29
|
+
export interface Connection<T extends ConnectionType> {
|
|
24
30
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
31
|
+
* Sends a request to the provided URL.
|
|
32
|
+
*
|
|
33
|
+
* This method never rejects its promise. In case of encountering an error,
|
|
34
|
+
* it sets an error code internally which can be accessed by calling
|
|
35
|
+
* getErrorCode() by callers.
|
|
27
36
|
*/
|
|
28
37
|
send(url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>;
|
|
29
38
|
getErrorCode(): ErrorCode;
|
|
30
39
|
getStatus(): number;
|
|
31
|
-
|
|
40
|
+
getResponse(): T;
|
|
41
|
+
getErrorText(): string;
|
|
32
42
|
/**
|
|
33
43
|
* Abort the request.
|
|
34
44
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { RequestInfo } from './requestinfo';
|
|
18
|
-
import { Headers,
|
|
18
|
+
import { Connection, Headers, ConnectionType } from './connection';
|
|
19
19
|
export interface Request<T> {
|
|
20
20
|
getPromise(): Promise<T>;
|
|
21
21
|
/**
|
|
@@ -31,17 +31,17 @@ export interface Request<T> {
|
|
|
31
31
|
* A collection of information about the result of a network request.
|
|
32
32
|
* @param opt_canceled - Defaults to false.
|
|
33
33
|
*/
|
|
34
|
-
export declare class RequestEndStatus {
|
|
34
|
+
export declare class RequestEndStatus<I extends ConnectionType> {
|
|
35
35
|
wasSuccessCode: boolean;
|
|
36
|
-
connection: Connection | null;
|
|
36
|
+
connection: Connection<I> | null;
|
|
37
37
|
/**
|
|
38
38
|
* True if the request was canceled.
|
|
39
39
|
*/
|
|
40
40
|
canceled: boolean;
|
|
41
|
-
constructor(wasSuccessCode: boolean, connection: Connection | null, canceled?: boolean);
|
|
41
|
+
constructor(wasSuccessCode: boolean, connection: Connection<I> | null, canceled?: boolean);
|
|
42
42
|
}
|
|
43
43
|
export declare function addAuthHeader_(headers: Headers, authToken: string | null): void;
|
|
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<
|
|
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>;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { StorageError } from './error';
|
|
18
|
-
import { Headers, Connection } from './connection';
|
|
18
|
+
import { Headers, Connection, ConnectionType } from './connection';
|
|
19
19
|
/**
|
|
20
20
|
* Type for url params stored in RequestInfo.
|
|
21
21
|
*/
|
|
@@ -29,8 +29,16 @@ export interface UrlParams {
|
|
|
29
29
|
* @param I - the type of the backend's network response
|
|
30
30
|
* @param O - the output response type used by the rest of the SDK.
|
|
31
31
|
*/
|
|
32
|
-
export declare type RequestHandler<I, O> = (connection: Connection
|
|
33
|
-
|
|
32
|
+
export declare type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O;
|
|
33
|
+
/** A function to handle an error. */
|
|
34
|
+
export declare type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError) => StorageError;
|
|
35
|
+
/**
|
|
36
|
+
* Contains a fully specified request.
|
|
37
|
+
*
|
|
38
|
+
* @param I - the type of the backend's network response.
|
|
39
|
+
* @param O - the output response type used by the rest of the SDK.
|
|
40
|
+
*/
|
|
41
|
+
export declare class RequestInfo<I extends ConnectionType, O> {
|
|
34
42
|
url: string;
|
|
35
43
|
method: string;
|
|
36
44
|
/**
|
|
@@ -40,12 +48,12 @@ export declare class RequestInfo<T> {
|
|
|
40
48
|
* Note: The XhrIo passed to this function may be reused after this callback
|
|
41
49
|
* returns. Do not keep a reference to it in any way.
|
|
42
50
|
*/
|
|
43
|
-
handler: RequestHandler<
|
|
51
|
+
handler: RequestHandler<I, O>;
|
|
44
52
|
timeout: number;
|
|
45
53
|
urlParams: UrlParams;
|
|
46
54
|
headers: Headers;
|
|
47
55
|
body: Blob | string | Uint8Array | null;
|
|
48
|
-
errorHandler:
|
|
56
|
+
errorHandler: ErrorHandler | null;
|
|
49
57
|
/**
|
|
50
58
|
* Called with the current number of bytes uploaded and total size (-1 if not
|
|
51
59
|
* computable) of the request body (i.e. used to report upload progress).
|
|
@@ -61,5 +69,5 @@ export declare class RequestInfo<T> {
|
|
|
61
69
|
* Note: The XhrIo passed to this function may be reused after this callback
|
|
62
70
|
* returns. Do not keep a reference to it in any way.
|
|
63
71
|
*/
|
|
64
|
-
handler: RequestHandler<
|
|
72
|
+
handler: RequestHandler<I, O>, timeout: number);
|
|
65
73
|
}
|
|
@@ -24,28 +24,29 @@ import { StorageError } from './error';
|
|
|
24
24
|
import { Location } from './location';
|
|
25
25
|
import { Mappings } from './metadata';
|
|
26
26
|
import { RequestInfo } from './requestinfo';
|
|
27
|
-
import { Connection } from './connection';
|
|
27
|
+
import { Connection, ConnectionType } from './connection';
|
|
28
28
|
import { FirebaseStorageImpl } from '../service';
|
|
29
29
|
/**
|
|
30
30
|
* Throws the UNKNOWN StorageError if cndn is false.
|
|
31
31
|
*/
|
|
32
32
|
export declare function handlerCheck(cndn: boolean): void;
|
|
33
|
-
export declare function metadataHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection
|
|
34
|
-
export declare function listHandler(service: FirebaseStorageImpl, bucket: string): (p1: Connection
|
|
35
|
-
export declare function downloadUrlHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection
|
|
36
|
-
export declare function sharedErrorHandler(location: Location): (p1: Connection
|
|
37
|
-
export declare function objectErrorHandler(location: Location): (p1: Connection
|
|
38
|
-
export declare function getMetadata(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<Metadata>;
|
|
39
|
-
export declare function list(service: FirebaseStorageImpl, location: Location, delimiter?: string, pageToken?: string | null, maxResults?: number | null): RequestInfo<ListResult>;
|
|
40
|
-
export declare function
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
33
|
+
export declare function metadataHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection<string>, p2: string) => Metadata;
|
|
34
|
+
export declare function listHandler(service: FirebaseStorageImpl, bucket: string): (p1: Connection<string>, p2: string) => ListResult;
|
|
35
|
+
export declare function downloadUrlHandler(service: FirebaseStorageImpl, mappings: Mappings): (p1: Connection<string>, p2: string) => string | null;
|
|
36
|
+
export declare function sharedErrorHandler(location: Location): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError;
|
|
37
|
+
export declare function objectErrorHandler(location: Location): (p1: Connection<ConnectionType>, p2: StorageError) => StorageError;
|
|
38
|
+
export declare function getMetadata(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<string, Metadata>;
|
|
39
|
+
export declare function list(service: FirebaseStorageImpl, location: Location, delimiter?: string, pageToken?: string | null, maxResults?: number | null): RequestInfo<string, ListResult>;
|
|
40
|
+
export declare function getBytes<I extends ConnectionType>(service: FirebaseStorageImpl, location: Location, maxDownloadSizeBytes?: number): RequestInfo<I, I>;
|
|
41
|
+
export declare function getDownloadUrl(service: FirebaseStorageImpl, location: Location, mappings: Mappings): RequestInfo<string, string | null>;
|
|
42
|
+
export declare function updateMetadata(service: FirebaseStorageImpl, location: Location, metadata: Partial<Metadata>, mappings: Mappings): RequestInfo<string, Metadata>;
|
|
43
|
+
export declare function deleteObject(service: FirebaseStorageImpl, location: Location): RequestInfo<string, void>;
|
|
43
44
|
export declare function determineContentType_(metadata: Metadata | null, blob: FbsBlob | null): string;
|
|
44
45
|
export declare function metadataForUpload_(location: Location, blob: FbsBlob, metadata?: Metadata | null): Metadata;
|
|
45
46
|
/**
|
|
46
47
|
* Prepare RequestInfo for uploads as Content-Type: multipart.
|
|
47
48
|
*/
|
|
48
|
-
export declare function multipartUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<Metadata>;
|
|
49
|
+
export declare function multipartUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string, Metadata>;
|
|
49
50
|
/**
|
|
50
51
|
* @param current The number of bytes that have been uploaded so far.
|
|
51
52
|
* @param total The total number of bytes in the upload.
|
|
@@ -60,12 +61,12 @@ export declare class ResumableUploadStatus {
|
|
|
60
61
|
metadata: Metadata | null;
|
|
61
62
|
constructor(current: number, total: number, finalized?: boolean, metadata?: Metadata | null);
|
|
62
63
|
}
|
|
63
|
-
export declare function checkResumeHeader_(xhr: Connection
|
|
64
|
-
export declare function createResumableUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string>;
|
|
64
|
+
export declare function checkResumeHeader_(xhr: Connection<string>, allowed?: string[]): string;
|
|
65
|
+
export declare function createResumableUpload(service: FirebaseStorageImpl, location: Location, mappings: Mappings, blob: FbsBlob, metadata?: Metadata | null): RequestInfo<string, string>;
|
|
65
66
|
/**
|
|
66
67
|
* @param url From a call to fbs.requests.createResumableUpload.
|
|
67
68
|
*/
|
|
68
|
-
export declare function getResumableUploadStatus(service: FirebaseStorageImpl, location: Location, url: string, blob: FbsBlob): RequestInfo<ResumableUploadStatus>;
|
|
69
|
+
export declare function getResumableUploadStatus(service: FirebaseStorageImpl, location: Location, url: string, blob: FbsBlob): RequestInfo<string, ResumableUploadStatus>;
|
|
69
70
|
/**
|
|
70
71
|
* Any uploads via the resumable upload API must transfer a number of bytes
|
|
71
72
|
* that is a multiple of this number.
|
|
@@ -80,4 +81,4 @@ export declare const RESUMABLE_UPLOAD_CHUNK_SIZE: number;
|
|
|
80
81
|
* has a final size inconsistent with the blob, or the blob cannot be sliced
|
|
81
82
|
* for upload.
|
|
82
83
|
*/
|
|
83
|
-
export declare function continueResumableUpload(location: Location, service: FirebaseStorageImpl, url: string, blob: FbsBlob, chunkSize: number, mappings: Mappings, status?: ResumableUploadStatus | null, progressCallback?: ((p1: number, p2: number) => void) | null): RequestInfo<ResumableUploadStatus>;
|
|
84
|
+
export declare function continueResumableUpload(location: Location, service: FirebaseStorageImpl, url: string, blob: FbsBlob, chunkSize: number, mappings: Mappings, status?: ResumableUploadStatus | null, progressCallback?: ((p1: number, p2: number) => void) | null): RequestInfo<string, ResumableUploadStatus>;
|
|
@@ -14,26 +14,43 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
/// <reference types="node" />
|
|
18
|
+
import { Connection, ConnectionType, ErrorCode, Headers } from '../../implementation/connection';
|
|
18
19
|
/**
|
|
19
20
|
* Network layer for browsers. We use this instead of goog.net.XhrIo because
|
|
20
21
|
* goog.net.XhrIo is hyuuuuge and doesn't work in React Native on Android.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
declare abstract class XhrConnection<T extends ConnectionType> implements Connection<T> {
|
|
24
|
+
protected xhr_: XMLHttpRequest;
|
|
24
25
|
private errorCode_;
|
|
25
26
|
private sendPromise_;
|
|
26
|
-
|
|
27
|
+
protected sent_: boolean;
|
|
27
28
|
constructor();
|
|
29
|
+
abstract initXhr(): void;
|
|
28
30
|
send(url: string, method: string, body?: ArrayBufferView | Blob | string, headers?: Headers): Promise<void>;
|
|
29
31
|
getErrorCode(): ErrorCode;
|
|
30
32
|
getStatus(): number;
|
|
31
|
-
|
|
33
|
+
getResponse(): T;
|
|
34
|
+
getErrorText(): string;
|
|
32
35
|
/** Aborts the request. */
|
|
33
36
|
abort(): void;
|
|
34
37
|
getResponseHeader(header: string): string | null;
|
|
35
38
|
addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
36
39
|
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
37
40
|
}
|
|
38
|
-
export declare
|
|
39
|
-
|
|
41
|
+
export declare class XhrTextConnection extends XhrConnection<string> {
|
|
42
|
+
initXhr(): void;
|
|
43
|
+
}
|
|
44
|
+
export declare function newTextConnection(): Connection<string>;
|
|
45
|
+
export declare class XhrBytesConnection extends XhrConnection<ArrayBuffer> {
|
|
46
|
+
private data_?;
|
|
47
|
+
initXhr(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare function newBytesConnection(): Connection<ArrayBuffer>;
|
|
50
|
+
export declare class XhrBlobConnection extends XhrConnection<Blob> {
|
|
51
|
+
initXhr(): void;
|
|
52
|
+
}
|
|
53
|
+
export declare function newBlobConnection(): Connection<Blob>;
|
|
54
|
+
export declare function newStreamConnection(): Connection<NodeJS.ReadableStream>;
|
|
55
|
+
export declare function injectTestConnection(factory: (() => Connection<string>) | null): void;
|
|
56
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2020 Google LLC
|
|
@@ -15,5 +16,8 @@
|
|
|
15
16
|
* limitations under the License.
|
|
16
17
|
*/
|
|
17
18
|
import { Connection } from '../implementation/connection';
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function injectTestConnection(factory: (() => Connection<string>) | null): void;
|
|
20
|
+
export declare function newTextConnection(): Connection<string>;
|
|
21
|
+
export declare function newBytesConnection(): Connection<ArrayBuffer>;
|
|
22
|
+
export declare function newBlobConnection(): Connection<Blob>;
|
|
23
|
+
export declare function newStreamConnection(): Connection<NodeJS.ReadableStream>;
|
|
@@ -14,32 +14,48 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
/// <reference types="node" />
|
|
18
|
+
import { Connection, ConnectionType, ErrorCode } from '../../implementation/connection';
|
|
19
|
+
import nodeFetch, { Headers } from 'node-fetch';
|
|
18
20
|
/**
|
|
19
21
|
* Network layer that works in Node.
|
|
20
22
|
*
|
|
21
23
|
* This network implementation should not be used in browsers as it does not
|
|
22
24
|
* support progress updates.
|
|
23
25
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
declare abstract class FetchConnection<T extends ConnectionType> implements Connection<T> {
|
|
27
|
+
protected errorCode_: ErrorCode;
|
|
28
|
+
protected statusCode_: number | undefined;
|
|
29
|
+
protected body_: ArrayBuffer | undefined;
|
|
30
|
+
protected errorText_: string;
|
|
31
|
+
protected headers_: Headers | undefined;
|
|
32
|
+
protected sent_: boolean;
|
|
33
|
+
protected fetch_: typeof nodeFetch;
|
|
31
34
|
constructor();
|
|
32
35
|
send(url: string, method: string, body?: ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>;
|
|
33
36
|
getErrorCode(): ErrorCode;
|
|
34
37
|
getStatus(): number;
|
|
35
|
-
|
|
38
|
+
abstract getResponse(): T;
|
|
39
|
+
getErrorText(): string;
|
|
36
40
|
abort(): void;
|
|
37
41
|
getResponseHeader(header: string): string | null;
|
|
38
42
|
addUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
39
|
-
/**
|
|
40
|
-
* @override
|
|
41
|
-
*/
|
|
42
43
|
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
43
44
|
}
|
|
44
|
-
export declare
|
|
45
|
-
|
|
45
|
+
export declare class FetchTextConnection extends FetchConnection<string> {
|
|
46
|
+
getResponse(): string;
|
|
47
|
+
}
|
|
48
|
+
export declare function newTextConnection(): Connection<string>;
|
|
49
|
+
export declare class FetchBytesConnection extends FetchConnection<ArrayBuffer> {
|
|
50
|
+
getResponse(): ArrayBuffer;
|
|
51
|
+
}
|
|
52
|
+
export declare function newBytesConnection(): Connection<ArrayBuffer>;
|
|
53
|
+
export declare class FetchStreamConnection extends FetchConnection<NodeJS.ReadableStream> {
|
|
54
|
+
private stream_;
|
|
55
|
+
send(url: string, method: string, body?: ArrayBufferView | Blob | string, headers?: Record<string, string>): Promise<void>;
|
|
56
|
+
getResponse(): NodeJS.ReadableStream;
|
|
57
|
+
}
|
|
58
|
+
export declare function newStreamConnection(): Connection<NodeJS.ReadableStream>;
|
|
59
|
+
export declare function newBlobConnection(): Connection<Blob>;
|
|
60
|
+
export declare function injectTestConnection(factory: (() => Connection<string>) | null): void;
|
|
61
|
+
export {};
|
package/dist/src/reference.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
/// <reference types="node" />
|
|
17
18
|
import { Location } from './implementation/location';
|
|
18
19
|
import { ListOptions, UploadResult } from './public-types';
|
|
19
20
|
import { StringFormat } from './implementation/string';
|
|
@@ -75,6 +76,18 @@ export declare class Reference {
|
|
|
75
76
|
*/
|
|
76
77
|
_throwIfRoot(name: string): void;
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Download the bytes at the object's location.
|
|
81
|
+
* @returns A Promise containing the downloaded bytes.
|
|
82
|
+
*/
|
|
83
|
+
export declare function getBytesInternal(ref: Reference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
|
|
84
|
+
/**
|
|
85
|
+
* Download the bytes at the object's location.
|
|
86
|
+
* @returns A Promise containing the downloaded blob.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getBlobInternal(ref: Reference, maxDownloadSizeBytes?: number): Promise<Blob>;
|
|
89
|
+
/** Stream the bytes at the object's location. */
|
|
90
|
+
export declare function getStreamInternal(ref: Reference, maxDownloadSizeBytes?: number): NodeJS.ReadableStream;
|
|
78
91
|
/**
|
|
79
92
|
* Uploads data to this object's location.
|
|
80
93
|
* The upload is not resumable.
|
package/dist/src/service.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types
|
|
|
24
24
|
import { FirebaseApp } from '@firebase/app';
|
|
25
25
|
import { FirebaseStorage } from './public-types';
|
|
26
26
|
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
27
|
-
import { Connection } from './implementation/connection';
|
|
27
|
+
import { Connection, ConnectionType } from './implementation/connection';
|
|
28
28
|
export declare function isUrl(path?: string): boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Returns a storage Reference for the given url.
|
|
@@ -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<
|
|
129
|
-
makeRequestWithTokens<
|
|
128
|
+
_makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request<O>;
|
|
129
|
+
makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>): Promise<O>;
|
|
130
130
|
}
|
package/dist/storage-public.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
+
/// <reference types="node" />
|
|
6
7
|
import { CompleteFn , EmulatorMockTokenOptions , NextFn , Subscribe , Unsubscribe } from '@firebase/util';
|
|
7
8
|
import { FirebaseApp } from '@firebase/app';
|
|
8
9
|
/**
|
|
@@ -98,6 +99,38 @@ export declare interface FullMetadata extends UploadMetadata {
|
|
|
98
99
|
*/
|
|
99
100
|
ref?: StorageReference | undefined;
|
|
100
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Downloads the data at the object's location. Returns an error if the object
|
|
104
|
+
* is not found.
|
|
105
|
+
*
|
|
106
|
+
* To use this functionality, you have to whitelist your app's origin in your
|
|
107
|
+
* Cloud Storage bucket. See also
|
|
108
|
+
* https://cloud.google.com/storage/docs/configuring-cors
|
|
109
|
+
*
|
|
110
|
+
* This API is not available in Node.
|
|
111
|
+
*
|
|
112
|
+
* @public
|
|
113
|
+
* @param ref - StorageReference where data should be downloaded.
|
|
114
|
+
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
|
|
115
|
+
* retrieve.
|
|
116
|
+
* @returns A Promise that resolves with a Blob containing the object's bytes
|
|
117
|
+
*/
|
|
118
|
+
export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>;
|
|
119
|
+
/**
|
|
120
|
+
* Downloads the data at the object's location. Returns an error if the object
|
|
121
|
+
* is not found.
|
|
122
|
+
*
|
|
123
|
+
* To use this functionality, you have to whitelist your app's origin in your
|
|
124
|
+
* Cloud Storage bucket. See also
|
|
125
|
+
* https://cloud.google.com/storage/docs/configuring-cors
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @param ref - StorageReference where data should be downloaded.
|
|
129
|
+
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
|
|
130
|
+
* retrieve.
|
|
131
|
+
* @returns A Promise containing the object's bytes
|
|
132
|
+
*/
|
|
133
|
+
export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
|
|
101
134
|
/* Excluded from this release type: _getChild */
|
|
102
135
|
/**
|
|
103
136
|
* Returns the download URL for the given {@link StorageReference}.
|
|
@@ -124,6 +157,19 @@ export declare function getMetadata(ref: StorageReference): Promise<FullMetadata
|
|
|
124
157
|
* @returns A {@link FirebaseStorage} instance.
|
|
125
158
|
*/
|
|
126
159
|
export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
|
|
160
|
+
/**
|
|
161
|
+
* Downloads the data at the object's location. Raises an error event if the
|
|
162
|
+
* object is not found.
|
|
163
|
+
*
|
|
164
|
+
* This API is only available in Node.
|
|
165
|
+
*
|
|
166
|
+
* @public
|
|
167
|
+
* @param ref - StorageReference where data should be downloaded.
|
|
168
|
+
* @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
|
|
169
|
+
* retrieve.
|
|
170
|
+
* @returns A stream with the object's data as bytes
|
|
171
|
+
*/
|
|
172
|
+
export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): NodeJS.ReadableStream;
|
|
127
173
|
/* Excluded from this release type: _invalidArgument */
|
|
128
174
|
/* Excluded from this release type: _invalidRootOperation */
|
|
129
175
|
/**
|
package/dist/storage.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/// <reference types="node" />
|
|
7
8
|
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
8
9
|
import { CompleteFn } from '@firebase/util';
|
|
9
10
|
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
@@ -24,16 +25,23 @@ declare type CompleteFn_2 = () => void;
|
|
|
24
25
|
/**
|
|
25
26
|
* A lightweight wrapper around XMLHttpRequest with a
|
|
26
27
|
* goog.net.XhrIo-like interface.
|
|
28
|
+
*
|
|
29
|
+
* You can create a new connection by invoking `newTextConnection()`,
|
|
30
|
+
* `newBytesConnection()` or `newStreamConnection()`.
|
|
27
31
|
*/
|
|
28
|
-
declare interface Connection {
|
|
32
|
+
declare interface Connection<T extends ConnectionType> {
|
|
29
33
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
34
|
+
* Sends a request to the provided URL.
|
|
35
|
+
*
|
|
36
|
+
* This method never rejects its promise. In case of encountering an error,
|
|
37
|
+
* it sets an error code internally which can be accessed by calling
|
|
38
|
+
* getErrorCode() by callers.
|
|
32
39
|
*/
|
|
33
40
|
send(url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers_2): Promise<void>;
|
|
34
41
|
getErrorCode(): ErrorCode;
|
|
35
42
|
getStatus(): number;
|
|
36
|
-
|
|
43
|
+
getResponse(): T;
|
|
44
|
+
getErrorText(): string;
|
|
37
45
|
/**
|
|
38
46
|
* Abort the request.
|
|
39
47
|
*/
|
|
@@ -43,6 +51,9 @@ declare interface Connection {
|
|
|
43
51
|
removeUploadProgressListener(listener: (p1: ProgressEvent) => void): void;
|
|
44
52
|
}
|
|
45
53
|
|
|
54
|
+
/** Response type exposed by the networking APIs. */
|
|
55
|
+
declare type ConnectionType = string | ArrayBuffer | Blob | NodeJS.ReadableStream;
|
|
56
|
+
|
|
46
57
|
/**
|
|
47
58
|
* Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
|
|
48
59
|
*
|
|
@@ -86,6 +97,9 @@ declare enum ErrorCode {
|
|
|
86
97
|
*/
|
|
87
98
|
declare type ErrorFn = (error: StorageError_2) => void;
|
|
88
99
|
|
|
100
|
+
/** A function to handle an error. */
|
|
101
|
+
declare type ErrorHandler = (connection: Connection<ConnectionType>, response: StorageError_2) => StorageError_2;
|
|
102
|
+
|
|
89
103
|
/**
|
|
90
104
|
* @license
|
|
91
105
|
* Copyright 2017 Google LLC
|
|
@@ -221,8 +235,8 @@ export declare class _FirebaseStorageImpl implements FirebaseStorage {
|
|
|
221
235
|
* @param requestInfo - HTTP RequestInfo object
|
|
222
236
|
* @param authToken - Firebase auth token
|
|
223
237
|
*/
|
|
224
|
-
_makeRequest<
|
|
225
|
-
makeRequestWithTokens<
|
|
238
|
+
_makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null): Request_2<O>;
|
|
239
|
+
makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo_2<I, O>, requestFactory: () => Connection<I>): Promise<O>;
|
|
226
240
|
}
|
|
227
241
|
|
|
228
242
|
/**
|
|
@@ -275,6 +289,40 @@ export declare interface FullMetadata extends UploadMetadata {
|
|
|
275
289
|
ref?: StorageReference | undefined;
|
|
276
290
|
}
|
|
277
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
|
+
|
|
278
326
|
/**
|
|
279
327
|
* @internal
|
|
280
328
|
*/
|
|
@@ -308,6 +356,20 @@ export declare function getMetadata(ref: StorageReference): Promise<FullMetadata
|
|
|
308
356
|
*/
|
|
309
357
|
export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
|
|
310
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): NodeJS.ReadableStream;
|
|
372
|
+
|
|
311
373
|
/**
|
|
312
374
|
* @license
|
|
313
375
|
* Copyright 2017 Google LLC
|
|
@@ -324,6 +386,7 @@ export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): Fireb
|
|
|
324
386
|
* See the License for the specific language governing permissions and
|
|
325
387
|
* limitations under the License.
|
|
326
388
|
*/
|
|
389
|
+
/// <reference types="node" />
|
|
327
390
|
/** Network headers */
|
|
328
391
|
declare type Headers_2 = Record<string, string>;
|
|
329
392
|
|
|
@@ -579,9 +642,15 @@ declare interface Request_2<T> {
|
|
|
579
642
|
* @param I - the type of the backend's network response
|
|
580
643
|
* @param O - the output response type used by the rest of the SDK.
|
|
581
644
|
*/
|
|
582
|
-
declare type RequestHandler<I, O> = (connection: Connection
|
|
645
|
+
declare type RequestHandler<I extends ConnectionType, O> = (connection: Connection<I>, response: I) => O;
|
|
583
646
|
|
|
584
|
-
|
|
647
|
+
/**
|
|
648
|
+
* Contains a fully specified request.
|
|
649
|
+
*
|
|
650
|
+
* @param I - the type of the backend's network response.
|
|
651
|
+
* @param O - the output response type used by the rest of the SDK.
|
|
652
|
+
*/
|
|
653
|
+
declare class RequestInfo_2<I extends ConnectionType, O> {
|
|
585
654
|
url: string;
|
|
586
655
|
method: string;
|
|
587
656
|
/**
|
|
@@ -591,12 +660,12 @@ declare class RequestInfo_2<T> {
|
|
|
591
660
|
* Note: The XhrIo passed to this function may be reused after this callback
|
|
592
661
|
* returns. Do not keep a reference to it in any way.
|
|
593
662
|
*/
|
|
594
|
-
handler: RequestHandler<
|
|
663
|
+
handler: RequestHandler<I, O>;
|
|
595
664
|
timeout: number;
|
|
596
665
|
urlParams: UrlParams;
|
|
597
666
|
headers: Headers_2;
|
|
598
667
|
body: Blob | string | Uint8Array | null;
|
|
599
|
-
errorHandler:
|
|
668
|
+
errorHandler: ErrorHandler | null;
|
|
600
669
|
/**
|
|
601
670
|
* Called with the current number of bytes uploaded and total size (-1 if not
|
|
602
671
|
* computable) of the request body (i.e. used to report upload progress).
|
|
@@ -612,7 +681,7 @@ declare class RequestInfo_2<T> {
|
|
|
612
681
|
* Note: The XhrIo passed to this function may be reused after this callback
|
|
613
682
|
* returns. Do not keep a reference to it in any way.
|
|
614
683
|
*/
|
|
615
|
-
handler: RequestHandler<
|
|
684
|
+
handler: RequestHandler<I, O>, timeout: number);
|
|
616
685
|
}
|
|
617
686
|
|
|
618
687
|
/**
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { FirebaseApp } from '@firebase/app';
|
|
18
|
+
import * as types from '../../src/public-types';
|
|
17
19
|
export declare const PROJECT_ID: any;
|
|
18
20
|
export declare const STORAGE_BUCKET: any;
|
|
19
21
|
export declare const API_KEY: any;
|
|
20
22
|
export declare const AUTH_DOMAIN: any;
|
|
23
|
+
export declare function createApp(): Promise<FirebaseApp>;
|
|
24
|
+
export declare function createStorage(app: FirebaseApp): types.FirebaseStorage;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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 {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 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 {};
|