@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,131 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 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
+ import { Location } from './implementation/location';
18
+ import { Request } from './implementation/request';
19
+ import { RequestInfo } from './implementation/requestinfo';
20
+ import { Reference } from './reference';
21
+ import { Provider } from '@firebase/component';
22
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
23
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
24
+ import { FirebaseApp } from '@firebase/app';
25
+ import { FirebaseStorage } from './public-types';
26
+ import { EmulatorMockTokenOptions } from '@firebase/util';
27
+ import { Connection, ConnectionType } from './implementation/connection';
28
+ export declare function isUrl(path?: string): boolean;
29
+ /**
30
+ * Returns a storage Reference for the given url.
31
+ * @param storage - `Storage` instance.
32
+ * @param url - URL. If empty, returns root reference.
33
+ * @public
34
+ */
35
+ export declare function ref(storage: FirebaseStorageImpl, url?: string): Reference;
36
+ /**
37
+ * Returns a storage Reference for the given path in the
38
+ * default bucket.
39
+ * @param storageOrRef - `Storage` service or storage `Reference`.
40
+ * @param pathOrUrlStorage - path. If empty, returns root reference (if Storage
41
+ * instance provided) or returns same reference (if Reference provided).
42
+ * @public
43
+ */
44
+ export declare function ref(storageOrRef: FirebaseStorageImpl | Reference, path?: string): Reference;
45
+ export declare function connectStorageEmulator(storage: FirebaseStorageImpl, host: string, port: number, options?: {
46
+ mockUserToken?: EmulatorMockTokenOptions | string;
47
+ }): void;
48
+ /**
49
+ * A service that provides Firebase Storage Reference instances.
50
+ * @param opt_url - gs:// url to a custom Storage Bucket
51
+ *
52
+ * @internal
53
+ */
54
+ export declare class FirebaseStorageImpl implements FirebaseStorage {
55
+ /**
56
+ * FirebaseApp associated with this StorageService instance.
57
+ */
58
+ readonly app: FirebaseApp;
59
+ readonly _authProvider: Provider<FirebaseAuthInternalName>;
60
+ /**
61
+ * @internal
62
+ */
63
+ readonly _appCheckProvider: Provider<AppCheckInternalComponentName>;
64
+ /**
65
+ * @internal
66
+ */
67
+ readonly _url?: string | undefined;
68
+ readonly _firebaseVersion?: string | undefined;
69
+ _isUsingEmulator: boolean;
70
+ _bucket: Location | null;
71
+ /**
72
+ * This string can be in the formats:
73
+ * - host
74
+ * - host:port
75
+ */
76
+ private _host;
77
+ _protocol: string;
78
+ protected readonly _appId: string | null;
79
+ private readonly _requests;
80
+ private _deleted;
81
+ private _maxOperationRetryTime;
82
+ private _maxUploadRetryTime;
83
+ _overrideAuthToken?: string;
84
+ constructor(
85
+ /**
86
+ * FirebaseApp associated with this StorageService instance.
87
+ */
88
+ app: FirebaseApp, _authProvider: Provider<FirebaseAuthInternalName>,
89
+ /**
90
+ * @internal
91
+ */
92
+ _appCheckProvider: Provider<AppCheckInternalComponentName>,
93
+ /**
94
+ * @internal
95
+ */
96
+ _url?: string | undefined, _firebaseVersion?: string | undefined, _isUsingEmulator?: boolean);
97
+ /**
98
+ * The host string for this service, in the form of `host` or
99
+ * `host:port`.
100
+ */
101
+ get host(): string;
102
+ set host(host: string);
103
+ /**
104
+ * The maximum time to retry uploads in milliseconds.
105
+ */
106
+ get maxUploadRetryTime(): number;
107
+ set maxUploadRetryTime(time: number);
108
+ /**
109
+ * The maximum time to retry operations other than uploads or downloads in
110
+ * milliseconds.
111
+ */
112
+ get maxOperationRetryTime(): number;
113
+ set maxOperationRetryTime(time: number);
114
+ _getAuthToken(): Promise<string | null>;
115
+ _getAppCheckToken(): Promise<string | null>;
116
+ /**
117
+ * Stop running requests and prevent more from being created.
118
+ */
119
+ _delete(): Promise<void>;
120
+ /**
121
+ * Returns a new firebaseStorage.Reference object referencing this StorageService
122
+ * at the given Location.
123
+ */
124
+ _makeStorageReference(loc: Location): Reference;
125
+ /**
126
+ * @param requestInfo - HTTP RequestInfo object
127
+ * @param authToken - Firebase auth token
128
+ */
129
+ _makeRequest<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>, authToken: string | null, appCheckToken: string | null, retry?: boolean): Request<O>;
130
+ makeRequestWithTokens<I extends ConnectionType, O>(requestInfo: RequestInfo<I, O>, requestFactory: () => Connection<I>): Promise<O>;
131
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 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
+ * @fileoverview Defines types for interacting with blob transfer tasks.
19
+ */
20
+ import { FbsBlob } from './implementation/blob';
21
+ import { StorageError } from './implementation/error';
22
+ import { InternalTaskState, TaskEvent } from './implementation/taskenums';
23
+ import { Metadata } from './metadata';
24
+ import { Subscribe, Unsubscribe } from './implementation/observer';
25
+ import { UploadTaskSnapshot, StorageObserver } from './public-types';
26
+ import { Reference } from './reference';
27
+ import { CompleteFn } from '@firebase/util';
28
+ /**
29
+ * Represents a blob being uploaded. Can be used to pause/resume/cancel the
30
+ * upload and manage callbacks for various events.
31
+ * @internal
32
+ */
33
+ export declare class UploadTask {
34
+ private _ref;
35
+ /**
36
+ * The data to be uploaded.
37
+ */
38
+ _blob: FbsBlob;
39
+ /**
40
+ * Metadata related to the upload.
41
+ */
42
+ _metadata: Metadata | null;
43
+ private _mappings;
44
+ /**
45
+ * Number of bytes transferred so far.
46
+ */
47
+ _transferred: number;
48
+ private _needToFetchStatus;
49
+ private _needToFetchMetadata;
50
+ private _observers;
51
+ private _resumable;
52
+ /**
53
+ * Upload state.
54
+ */
55
+ _state: InternalTaskState;
56
+ private _error?;
57
+ private _uploadUrl?;
58
+ private _request?;
59
+ private _chunkMultiplier;
60
+ private _errorHandler;
61
+ private _metadataErrorHandler;
62
+ private _resolve?;
63
+ private _reject?;
64
+ private pendingTimeout?;
65
+ private _promise;
66
+ private sleepTime;
67
+ private maxSleepTime;
68
+ isExponentialBackoffExpired(): boolean;
69
+ /**
70
+ * @param ref - The firebaseStorage.Reference object this task came
71
+ * from, untyped to avoid cyclic dependencies.
72
+ * @param blob - The blob to upload.
73
+ */
74
+ constructor(ref: Reference, blob: FbsBlob, metadata?: Metadata | null);
75
+ private _makeProgressCallback;
76
+ private _shouldDoResumable;
77
+ private _start;
78
+ private _resolveToken;
79
+ private _createResumable;
80
+ private _fetchStatus;
81
+ private _continueUpload;
82
+ private _increaseMultiplier;
83
+ private _fetchMetadata;
84
+ private _oneShotUpload;
85
+ private _updateProgress;
86
+ private _transition;
87
+ private completeTransitions_;
88
+ /**
89
+ * A snapshot of the current task state.
90
+ */
91
+ get snapshot(): UploadTaskSnapshot;
92
+ /**
93
+ * Adds a callback for an event.
94
+ * @param type - The type of event to listen for.
95
+ * @param nextOrObserver -
96
+ * The `next` function, which gets called for each item in
97
+ * the event stream, or an observer object with some or all of these three
98
+ * properties (`next`, `error`, `complete`).
99
+ * @param error - A function that gets called with a `StorageError`
100
+ * if the event stream ends due to an error.
101
+ * @param completed - A function that gets called if the
102
+ * event stream ends normally.
103
+ * @returns
104
+ * If only the event argument is passed, returns a function you can use to
105
+ * add callbacks (see the examples above). If more than just the event
106
+ * argument is passed, returns a function you can call to unregister the
107
+ * callbacks.
108
+ */
109
+ on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | null | ((snapshot: UploadTaskSnapshot) => unknown), error?: ((a: StorageError) => unknown) | null, completed?: CompleteFn | null): Unsubscribe | Subscribe<UploadTaskSnapshot>;
110
+ /**
111
+ * This object behaves like a Promise, and resolves with its snapshot data
112
+ * when the upload completes.
113
+ * @param onFulfilled - The fulfillment callback. Promise chaining works as normal.
114
+ * @param onRejected - The rejection callback.
115
+ */
116
+ then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: StorageError) => U | Promise<U>) | null): Promise<U>;
117
+ /**
118
+ * Equivalent to calling `then(null, onRejected)`.
119
+ */
120
+ catch<T>(onRejected: (p1: StorageError) => T | Promise<T>): Promise<T>;
121
+ /**
122
+ * Adds the given observer.
123
+ */
124
+ private _addObserver;
125
+ /**
126
+ * Removes the given observer.
127
+ */
128
+ private _removeObserver;
129
+ private _notifyObservers;
130
+ private _finishPromise;
131
+ private _notifyObserver;
132
+ /**
133
+ * Resumes a paused task. Has no effect on a currently running or failed task.
134
+ * @returns True if the operation took effect, false if ignored.
135
+ */
136
+ resume(): boolean;
137
+ /**
138
+ * Pauses a currently running task. Has no effect on a paused or failed task.
139
+ * @returns True if the operation took effect, false if ignored.
140
+ */
141
+ pause(): boolean;
142
+ /**
143
+ * Cancels a currently running or paused task. Has no effect on a complete or
144
+ * failed task.
145
+ * @returns True if the operation took effect, false if ignored.
146
+ */
147
+ cancel(): boolean;
148
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 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
+ import { ErrorCode, Headers, Connection } from '../../src/implementation/connection';
18
+ export type SendHook = (connection: TestingConnection, url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => void;
19
+ export declare enum State {
20
+ START = 0,
21
+ SENT = 1,
22
+ DONE = 2
23
+ }
24
+ export declare class TestingConnection implements Connection<string> {
25
+ private state;
26
+ private sendPromise;
27
+ private resolve;
28
+ private sendHook;
29
+ private status;
30
+ private responseText;
31
+ private headers;
32
+ private errorCode;
33
+ constructor(sendHook: SendHook | null);
34
+ send(url: string, method: string, _isUsingEmulator: boolean, body?: ArrayBufferView | Blob | string | null, headers?: Headers): Promise<void>;
35
+ simulateResponse(status: number, body: string, headers: {
36
+ [key: string]: string;
37
+ }): void;
38
+ getErrorCode(): ErrorCode;
39
+ getStatus(): number;
40
+ getResponse(): string;
41
+ getErrorText(): string;
42
+ abort(): void;
43
+ getResponseHeader(header: string): string | null;
44
+ addUploadProgressListener(): void;
45
+ removeUploadProgressListener(): void;
46
+ }
47
+ export declare function newTestConnection(sendHook?: SendHook | null): Connection<string>;
@@ -0,0 +1,60 @@
1
+ import { FirebaseApp } from '@firebase/app-types';
2
+ import { StorageError } from '../../src/implementation/error';
3
+ import { Headers, Connection, ConnectionType } from '../../src/implementation/connection';
4
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
5
+ import { Provider } from '@firebase/component';
6
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
7
+ import { FirebaseStorageImpl } from '../../src/service';
8
+ import { Metadata } from '../../src/metadata';
9
+ export declare const authToken = "totally-legit-auth-token";
10
+ export declare const appCheckToken = "totally-shady-token";
11
+ export declare const bucket = "mybucket";
12
+ export declare const fakeApp: FirebaseApp;
13
+ export declare const fakeAuthProvider: Provider<"auth-internal">;
14
+ export declare const emptyAuthProvider: Provider<"auth-internal">;
15
+ export declare const fakeAppCheckTokenProvider: Provider<"app-check-internal">;
16
+ export declare function makeFakeApp(bucketArg?: string): FirebaseApp;
17
+ export declare function makeFakeAuthProvider(token: {
18
+ accessToken: string;
19
+ }): Provider<FirebaseAuthInternalName>;
20
+ export declare function makeFakeAppCheckProvider(tokenResult: {
21
+ token: string;
22
+ }): Provider<AppCheckInternalComponentName>;
23
+ /**
24
+ * Returns something that looks like an fbs.XhrIo with the given headers
25
+ * and status.
26
+ */
27
+ export declare function fakeXhrIo<I extends ConnectionType = string>(headers: Headers, status?: number): Connection<I>;
28
+ /**
29
+ * Binds ignoring types. Used to test calls involving improper arguments.
30
+ */
31
+ export declare function bind(f: Function, ctx: any, ...args: any[]): () => void;
32
+ export declare function assertThrows(f: () => void, code: string): StorageError;
33
+ export declare function assertUint8ArrayEquals(arr1: Uint8Array, arr2: Uint8Array): void;
34
+ export declare function assertObjectIncludes(included: {
35
+ [name: string]: any;
36
+ }, obj: {
37
+ [name: string]: any;
38
+ }): void;
39
+ interface Response {
40
+ status: number;
41
+ body: string;
42
+ headers: Headers;
43
+ }
44
+ export type RequestHandler = (url: string, method: string, body?: ArrayBufferView | Blob | string | null, headers?: Headers) => Response;
45
+ export declare function storageServiceWithHandler(handler: RequestHandler, shouldResponseCb?: () => boolean): FirebaseStorageImpl;
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 finalize
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>, cb?: () => void): RequestHandler;
59
+ export declare function fakeOneShot503ServerHandler(fakeMetadata?: Partial<Metadata>): RequestHandler;
60
+ export {};
@@ -0,0 +1,47 @@
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
+ import { StorageReference } from './public-types';
18
+ /**
19
+ * Downloads the data at the object's location. Returns an error if the object
20
+ * is not found.
21
+ *
22
+ * To use this functionality, you have to whitelist your app's origin in your
23
+ * Cloud Storage bucket. See also
24
+ * https://cloud.google.com/storage/docs/configuring-cors
25
+ *
26
+ * This API is not available in Node.
27
+ *
28
+ * @public
29
+ * @param ref - StorageReference where data should be downloaded.
30
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
31
+ * retrieve.
32
+ * @returns A Promise that resolves with a Blob containing the object's bytes
33
+ */
34
+ export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>;
35
+ /**
36
+ * Downloads the data at the object's location. Raises an error event if the
37
+ * object is not found.
38
+ *
39
+ * This API is only available in Node.
40
+ *
41
+ * @public
42
+ * @param ref - StorageReference where data should be downloaded.
43
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
44
+ * retrieve.
45
+ * @returns A stream with the object's data as bytes
46
+ */
47
+ export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream;
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 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
+ import { FirebaseApp } from '@firebase/app';
18
+ import { StorageReference, FirebaseStorage, UploadResult, ListOptions, ListResult, UploadTask, SettableMetadata, UploadMetadata, FullMetadata } from './public-types';
19
+ import { Reference } from './reference';
20
+ import { EmulatorMockTokenOptions } from '@firebase/util';
21
+ import { StringFormat } from './implementation/string';
22
+ export { EmulatorMockTokenOptions } from '@firebase/util';
23
+ export { StorageError, StorageErrorCode } from './implementation/error';
24
+ /**
25
+ * Public types.
26
+ */
27
+ export * from './public-types';
28
+ export { Location as _Location } from './implementation/location';
29
+ export { UploadTask as _UploadTask } from './task';
30
+ export type { Reference as _Reference } from './reference';
31
+ export type { FirebaseStorageImpl as _FirebaseStorageImpl } from './service';
32
+ export { FbsBlob as _FbsBlob } from './implementation/blob';
33
+ export { dataFromString as _dataFromString } from './implementation/string';
34
+ export { invalidRootOperation as _invalidRootOperation, invalidArgument as _invalidArgument } from './implementation/error';
35
+ export { TaskEvent as _TaskEvent, TaskState as _TaskState } from './implementation/taskenums';
36
+ export { StringFormat };
37
+ /**
38
+ * Downloads the data at the object's location. Returns an error if the object
39
+ * is not found.
40
+ *
41
+ * To use this functionality, you have to whitelist your app's origin in your
42
+ * Cloud Storage bucket. See also
43
+ * https://cloud.google.com/storage/docs/configuring-cors
44
+ *
45
+ * @public
46
+ * @param ref - StorageReference where data should be downloaded.
47
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
48
+ * retrieve.
49
+ * @returns A Promise containing the object's bytes
50
+ */
51
+ export declare function getBytes(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<ArrayBuffer>;
52
+ /**
53
+ * Uploads data to this object's location.
54
+ * The upload is not resumable.
55
+ * @public
56
+ * @param ref - {@link StorageReference} where data should be uploaded.
57
+ * @param data - The data to upload.
58
+ * @param metadata - Metadata for the data to upload.
59
+ * @returns A Promise containing an UploadResult
60
+ */
61
+ export declare function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): Promise<UploadResult>;
62
+ /**
63
+ * Uploads a string to this object's location.
64
+ * The upload is not resumable.
65
+ * @public
66
+ * @param ref - {@link StorageReference} where string should be uploaded.
67
+ * @param value - The string to upload.
68
+ * @param format - The format of the string to upload.
69
+ * @param metadata - Metadata for the string to upload.
70
+ * @returns A Promise containing an UploadResult
71
+ */
72
+ export declare function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: UploadMetadata): Promise<UploadResult>;
73
+ /**
74
+ * Uploads data to this object's location.
75
+ * The upload can be paused and resumed, and exposes progress updates.
76
+ * @public
77
+ * @param ref - {@link StorageReference} where data should be uploaded.
78
+ * @param data - The data to upload.
79
+ * @param metadata - Metadata for the data to upload.
80
+ * @returns An UploadTask
81
+ */
82
+ export declare function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: UploadMetadata): UploadTask;
83
+ /**
84
+ * A `Promise` that resolves with the metadata for this object. If this
85
+ * object doesn't exist or metadata cannot be retrieved, the promise is
86
+ * rejected.
87
+ * @public
88
+ * @param ref - {@link StorageReference} to get metadata from.
89
+ */
90
+ export declare function getMetadata(ref: StorageReference): Promise<FullMetadata>;
91
+ /**
92
+ * Updates the metadata for this object.
93
+ * @public
94
+ * @param ref - {@link StorageReference} to update metadata for.
95
+ * @param metadata - The new metadata for the object.
96
+ * Only values that have been explicitly set will be changed. Explicitly
97
+ * setting a value to null will remove the metadata.
98
+ * @returns A `Promise` that resolves with the new metadata for this object.
99
+ */
100
+ export declare function updateMetadata(ref: StorageReference, metadata: SettableMetadata): Promise<FullMetadata>;
101
+ /**
102
+ * List items (files) and prefixes (folders) under this storage reference.
103
+ *
104
+ * List API is only available for Firebase Rules Version 2.
105
+ *
106
+ * GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
107
+ * delimited folder structure.
108
+ * Refer to GCS's List API if you want to learn more.
109
+ *
110
+ * To adhere to Firebase Rules's Semantics, Firebase Storage does not
111
+ * support objects whose paths end with "/" or contain two consecutive
112
+ * "/"s. Firebase Storage List API will filter these unsupported objects.
113
+ * list() may fail if there are too many unsupported objects in the bucket.
114
+ * @public
115
+ *
116
+ * @param ref - {@link StorageReference} to get list from.
117
+ * @param options - See {@link ListOptions} for details.
118
+ * @returns A `Promise` that resolves with the items and prefixes.
119
+ * `prefixes` contains references to sub-folders and `items`
120
+ * contains references to objects in this folder. `nextPageToken`
121
+ * can be used to get the rest of the results.
122
+ */
123
+ export declare function list(ref: StorageReference, options?: ListOptions): Promise<ListResult>;
124
+ /**
125
+ * List all items (files) and prefixes (folders) under this storage reference.
126
+ *
127
+ * This is a helper method for calling list() repeatedly until there are
128
+ * no more results. The default pagination size is 1000.
129
+ *
130
+ * Note: The results may not be consistent if objects are changed while this
131
+ * operation is running.
132
+ *
133
+ * Warning: `listAll` may potentially consume too many resources if there are
134
+ * too many results.
135
+ * @public
136
+ * @param ref - {@link StorageReference} to get list from.
137
+ *
138
+ * @returns A `Promise` that resolves with all the items and prefixes under
139
+ * the current storage reference. `prefixes` contains references to
140
+ * sub-directories and `items` contains references to objects in this
141
+ * folder. `nextPageToken` is never returned.
142
+ */
143
+ export declare function listAll(ref: StorageReference): Promise<ListResult>;
144
+ /**
145
+ * Returns the download URL for the given {@link StorageReference}.
146
+ * @public
147
+ * @param ref - {@link StorageReference} to get the download URL for.
148
+ * @returns A `Promise` that resolves with the download
149
+ * URL for this object.
150
+ */
151
+ export declare function getDownloadURL(ref: StorageReference): Promise<string>;
152
+ /**
153
+ * Deletes the object at this location.
154
+ * @public
155
+ * @param ref - {@link StorageReference} for object to delete.
156
+ * @returns A `Promise` that resolves if the deletion succeeds.
157
+ */
158
+ export declare function deleteObject(ref: StorageReference): Promise<void>;
159
+ /**
160
+ * Returns a {@link StorageReference} for the given url.
161
+ * @param storage - {@link FirebaseStorage} instance.
162
+ * @param url - URL. If empty, returns root reference.
163
+ * @public
164
+ */
165
+ export declare function ref(storage: FirebaseStorage, url?: string): StorageReference;
166
+ /**
167
+ * Returns a {@link StorageReference} for the given path in the
168
+ * default bucket.
169
+ * @param storageOrRef - {@link FirebaseStorage} or {@link StorageReference}.
170
+ * @param pathOrUrlStorage - path. If empty, returns root reference (if {@link FirebaseStorage}
171
+ * instance provided) or returns same reference (if {@link StorageReference} provided).
172
+ * @public
173
+ */
174
+ export declare function ref(storageOrRef: FirebaseStorage | StorageReference, path?: string): StorageReference;
175
+ /**
176
+ * @internal
177
+ */
178
+ export declare function _getChild(ref: StorageReference, childPath: string): Reference;
179
+ /**
180
+ * Gets a {@link FirebaseStorage} instance for the given Firebase app.
181
+ * @public
182
+ * @param app - Firebase app to get {@link FirebaseStorage} instance for.
183
+ * @param bucketUrl - The gs:// url to your Firebase Storage Bucket.
184
+ * If not passed, uses the app's default Storage Bucket.
185
+ * @returns A {@link FirebaseStorage} instance.
186
+ */
187
+ export declare function getStorage(app?: FirebaseApp, bucketUrl?: string): FirebaseStorage;
188
+ /**
189
+ * Modify this {@link FirebaseStorage} instance to communicate with the Cloud Storage emulator.
190
+ *
191
+ * @param storage - The {@link FirebaseStorage} instance
192
+ * @param host - The emulator host (ex: localhost)
193
+ * @param port - The emulator port (ex: 5001)
194
+ * @param options - Emulator options. `options.mockUserToken` is the mock auth
195
+ * token to use for unit testing Security Rules.
196
+ * @public
197
+ */
198
+ export declare function connectStorageEmulator(storage: FirebaseStorage, host: string, port: number, options?: {
199
+ mockUserToken?: EmulatorMockTokenOptions | string;
200
+ }): void;
@@ -0,0 +1,47 @@
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
+ import { StorageReference } from './public-types';
18
+ /**
19
+ * Downloads the data at the object's location. Returns an error if the object
20
+ * is not found.
21
+ *
22
+ * To use this functionality, you have to whitelist your app's origin in your
23
+ * Cloud Storage bucket. See also
24
+ * https://cloud.google.com/storage/docs/configuring-cors
25
+ *
26
+ * This API is not available in Node.
27
+ *
28
+ * @public
29
+ * @param ref - StorageReference where data should be downloaded.
30
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
31
+ * retrieve.
32
+ * @returns A Promise that resolves with a Blob containing the object's bytes
33
+ */
34
+ export declare function getBlob(ref: StorageReference, maxDownloadSizeBytes?: number): Promise<Blob>;
35
+ /**
36
+ * Downloads the data at the object's location. Raises an error event if the
37
+ * object is not found.
38
+ *
39
+ * This API is only available in Node.
40
+ *
41
+ * @public
42
+ * @param ref - StorageReference where data should be downloaded.
43
+ * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to
44
+ * retrieve.
45
+ * @returns A stream with the object's data as bytes
46
+ */
47
+ export declare function getStream(ref: StorageReference, maxDownloadSizeBytes?: number): ReadableStream;