Skip to content

Commit 2615765

Browse files
committed
Address PR comments
1 parent 31538a9 commit 2615765

18 files changed

+255
-1075
lines changed

common/api-review/storage.api.md

Lines changed: 183 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,227 @@
44
55
```ts
66

7-
import { FirebaseApp } from '@firebase/app-types-exp';
7+
import { FirebaseApp } from '@firebase/app-types';
88
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
99
import { FirebaseError } from '@firebase/util';
10-
import { _FirebaseService } from '@firebase/app-types-exp';
10+
import { _FirebaseService } from '@firebase/app-types';
1111
import { Provider } from '@firebase/component';
1212
import * as types from '@firebase/storage-types';
1313

14-
// Warning: (ae-forgotten-export) The symbol "StorageReference" needs to be exported by the entry point index.d.ts
15-
//
1614
// @public
1715
export function deleteObject(ref: StorageReference): Promise<void>;
1816

1917
// @public
2018
export function getDownloadURL(ref: StorageReference): Promise<string>;
2119

22-
// Warning: (ae-forgotten-export) The symbol "Metadata" needs to be exported by the entry point index.d.ts
23-
//
2420
// @public
2521
export function getMetadata(ref: StorageReference): Promise<Metadata>;
2622

27-
// Warning: (ae-forgotten-export) The symbol "StorageService" needs to be exported by the entry point index.d.ts
28-
//
2923
// @public
3024
export function getStorage(app: FirebaseApp): StorageService;
3125

32-
// Warning: (ae-forgotten-export) The symbol "ListOptions" needs to be exported by the entry point index.d.ts
33-
// Warning: (ae-forgotten-export) The symbol "ListResult" needs to be exported by the entry point index.d.ts
34-
//
3526
// @public
3627
export function list(ref: StorageReference, options?: ListOptions | null): Promise<ListResult>;
3728

3829
// @public
3930
export function listAll(ref: StorageReference): Promise<ListResult>;
4031

32+
// @public
33+
export interface ListOptions extends types.ListOptions {
34+
}
35+
36+
// @public
37+
export interface ListResult {
38+
// (undocumented)
39+
items: StorageReference[];
40+
// (undocumented)
41+
nextPageToken?: string;
42+
// (undocumented)
43+
prefixes: StorageReference[];
44+
}
45+
46+
// @public
47+
export interface Metadata extends types.FullMetadata {
48+
// (undocumented)
49+
[prop: string]: unknown;
50+
// (undocumented)
51+
cacheControl: string | undefined;
52+
// (undocumented)
53+
contentDisposition: string | undefined;
54+
// (undocumented)
55+
contentEncoding: string | undefined;
56+
// (undocumented)
57+
contentLanguage: string | undefined;
58+
// (undocumented)
59+
contentType: string | undefined;
60+
// (undocumented)
61+
customMetadata: {
62+
[key: string]: string;
63+
} | undefined;
64+
// (undocumented)
65+
downloadTokens: string[] | undefined;
66+
// (undocumented)
67+
md5Hash: string | undefined;
68+
// (undocumented)
69+
ref: StorageReference | undefined;
70+
// (undocumented)
71+
type: string | undefined;
72+
}
73+
4174
// @public
4275
export function ref(storage: StorageService, url?: string): StorageReference;
4376

4477
// @public
4578
export function ref(storageOrRef: StorageService | StorageReference, path?: string): StorageReference;
4679

80+
// @public
81+
export class StorageReference {
82+
constructor(_service: StorageService, location: string | Location_2);
83+
// (undocumented)
84+
get bucket(): string;
85+
// (undocumented)
86+
get fullPath(): string;
87+
// Warning: (ae-forgotten-export) The symbol "Location" needs to be exported by the entry point index.d.ts
88+
//
89+
// @internal (undocumented)
90+
_location: Location_2;
91+
// (undocumented)
92+
get name(): string;
93+
// (undocumented)
94+
protected newRef(service: StorageService, location: Location_2): StorageReference;
95+
// (undocumented)
96+
get parent(): StorageReference | null;
97+
// (undocumented)
98+
get root(): StorageReference;
99+
// (undocumented)
100+
get storage(): StorageService;
101+
// (undocumented)
102+
_throwIfRoot(name: string): void;
103+
// @override (undocumented)
104+
toString(): string;
105+
}
106+
107+
// @public
108+
export class StorageService implements _FirebaseService {
109+
constructor(app: FirebaseApp,
110+
_authProvider: Provider<FirebaseAuthInternalName>,
111+
_pool: XhrIoPool,
112+
_url?: string | undefined,
113+
_firebaseVersion?: string | undefined);
114+
// (undocumented)
115+
readonly app: FirebaseApp;
116+
// (undocumented)
117+
protected readonly _appId: string | null;
118+
// @internal (undocumented)
119+
readonly _authProvider: Provider<FirebaseAuthInternalName>;
120+
// @internal (undocumented)
121+
readonly _bucket: Location_2 | null;
122+
// @internal
123+
_delete(): Promise<void>;
124+
// @internal (undocumented)
125+
readonly _firebaseVersion?: string | undefined;
126+
// (undocumented)
127+
getAuthToken(): Promise<string | null>;
128+
// Warning: (ae-forgotten-export) The symbol "RequestInfo" needs to be exported by the entry point index.d.ts
129+
// Warning: (ae-forgotten-export) The symbol "Request" needs to be exported by the entry point index.d.ts
130+
//
131+
// @internal (undocumented)
132+
makeRequest<T>(requestInfo: RequestInfo_2<T>, authToken: string | null): Request_2<T>;
133+
makeStorageReference(loc: Location_2): StorageReference;
134+
// (undocumented)
135+
get maxOperationRetryTime(): number;
136+
set maxOperationRetryTime(time: number);
137+
// (undocumented)
138+
get maxUploadRetryTime(): number;
139+
set maxUploadRetryTime(time: number);
140+
// Warning: (ae-forgotten-export) The symbol "XhrIoPool" needs to be exported by the entry point index.d.ts
141+
//
142+
// @internal (undocumented)
143+
readonly _pool: XhrIoPool;
144+
// @internal (undocumented)
145+
readonly _url?: string | undefined;
146+
}
147+
148+
// @public
149+
export type StringFormat = string;
150+
151+
// @public
152+
export const StringFormat: {
153+
RAW: string;
154+
BASE64: string;
155+
BASE64URL: string;
156+
DATA_URL: string;
157+
};
158+
47159
// @public
48160
export function updateMetadata(ref: StorageReference, metadata: Record<string, unknown>): Promise<Metadata>;
49161

50-
// Warning: (ae-forgotten-export) The symbol "UploadTaskSnapshot" needs to be exported by the entry point index.d.ts
51-
//
52162
// @public
53-
export function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): Promise<UploadTaskSnapshot>;
163+
export function uploadBytes(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): Promise<UploadResult>;
54164

55-
// Warning: (ae-forgotten-export) The symbol "UploadTask" needs to be exported by the entry point index.d.ts
56-
//
57165
// @public
58166
export function uploadBytesResumable(ref: StorageReference, data: Blob | Uint8Array | ArrayBuffer, metadata?: Metadata): UploadTask;
59167

60-
// Warning: (ae-forgotten-export) The symbol "StringFormat" needs to be exported by the entry point index.d.ts
61-
//
62168
// @public
63-
export function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: Metadata): Promise<UploadTaskSnapshot>;
169+
export interface UploadResult {
170+
// (undocumented)
171+
readonly metadata: Metadata;
172+
// (undocumented)
173+
readonly ref: StorageReference;
174+
}
175+
176+
// @public
177+
export function uploadString(ref: StorageReference, value: string, format?: StringFormat, metadata?: Metadata): Promise<UploadResult>;
178+
179+
// @public
180+
export class UploadTask {
181+
constructor(ref: StorageReference, blob: FbsBlob, metadata?: Metadata | null);
182+
// Warning: (ae-forgotten-export) The symbol "FbsBlob" needs to be exported by the entry point index.d.ts
183+
//
184+
// @internal (undocumented)
185+
_blob: FbsBlob;
186+
cancel(): boolean;
187+
catch<T>(onRejected: (p1: FirebaseStorageError) => T | Promise<T>): Promise<T>;
188+
// @internal (undocumented)
189+
_metadata: Metadata | null;
190+
// Warning: (ae-forgotten-export) The symbol "TaskEvent" needs to be exported by the entry point index.d.ts
191+
// Warning: (ae-forgotten-export) The symbol "StorageObserver" needs to be exported by the entry point index.d.ts
192+
// Warning: (ae-forgotten-export) The symbol "ErrorFn" needs to be exported by the entry point index.d.ts
193+
// Warning: (ae-forgotten-export) The symbol "CompleteFn" needs to be exported by the entry point index.d.ts
194+
// Warning: (ae-forgotten-export) The symbol "Unsubscribe" needs to be exported by the entry point index.d.ts
195+
// Warning: (ae-forgotten-export) The symbol "Subscribe" needs to be exported by the entry point index.d.ts
196+
on(type: TaskEvent, nextOrObserver?: StorageObserver<UploadTaskSnapshot> | ((a: UploadTaskSnapshot) => unknown), error?: ErrorFn, completed?: CompleteFn): Unsubscribe | Subscribe<UploadTaskSnapshot>;
197+
pause(): boolean;
198+
resume(): boolean;
199+
// (undocumented)
200+
get snapshot(): UploadTaskSnapshot;
201+
// Warning: (ae-forgotten-export) The symbol "InternalTaskState" needs to be exported by the entry point index.d.ts
202+
//
203+
// @internal (undocumented)
204+
_state: InternalTaskState;
205+
// Warning: (ae-forgotten-export) The symbol "FirebaseStorageError" needs to be exported by the entry point index.d.ts
206+
then<U>(onFulfilled?: ((value: UploadTaskSnapshot) => U | Promise<U>) | null, onRejected?: ((error: FirebaseStorageError) => U | Promise<U>) | null): Promise<U>;
207+
// @internal (undocumented)
208+
_transferred: number;
209+
}
210+
211+
// @public
212+
export interface UploadTaskSnapshot {
213+
// (undocumented)
214+
readonly bytesTransferred: number;
215+
// (undocumented)
216+
readonly metadata: Metadata;
217+
// (undocumented)
218+
readonly ref: StorageReference;
219+
// Warning: (ae-forgotten-export) The symbol "TaskState" needs to be exported by the entry point index.d.ts
220+
//
221+
// (undocumented)
222+
readonly state: TaskState;
223+
// (undocumented)
224+
readonly task: UploadTask;
225+
// (undocumented)
226+
readonly totalBytes: number;
227+
}
64228

65229

66230
// (No @packageDocumentation comment for this package)

packages/storage/api-extractor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "../../config/api-extractor.json",
33
// Point it to your entry point d.ts file.
4-
"mainEntryPointFilePath": "<projectFolder>/exp/dist/packages/storage/exp/index.d.ts",
4+
"mainEntryPointFilePath": "<projectFolder>/exp/dist/exp/index.d.ts",
55
"dtsRollup": {
66
"enabled": true,
77
"untrimmedFilePath": "<projectFolder>/exp/dist/<unscopedPackageName>.d.ts",

packages/storage/compat/reference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class ReferenceCompat implements types.Reference {
118118
const data = dataFromString(format, value);
119119
const metadataClone = { ...metadata } as Metadata;
120120
if (metadataClone['contentType'] == null && data.contentType != null) {
121-
metadataClone['contentType'] = data.contentType!;
121+
metadataClone['contentType'] = data.contentType;
122122
}
123123
return new UploadTaskCompat(
124124
new UploadTask(

packages/storage/compat/task.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
Subscribe,
2727
Unsubscribe
2828
} from '../src/implementation/observer';
29-
import { UploadTaskResumableSnapshot } from '../src/tasksnapshot';
29+
import { UploadTaskSnapshot } from '../src/tasksnapshot';
3030
import { ReferenceCompat } from './reference';
3131
import { FirebaseStorageError } from '../src/implementation/error';
3232

@@ -75,19 +75,19 @@ export class UploadTaskCompat implements types.UploadTask {
7575
completed?: CompleteFn | null
7676
): Unsubscribe | Subscribe<UploadTaskSnapshotCompat> {
7777
let wrappedNextOrObserver:
78-
| StorageObserver<UploadTaskResumableSnapshot>
78+
| StorageObserver<UploadTaskSnapshot>
7979
| undefined
80-
| ((a: UploadTaskResumableSnapshot) => unknown) = undefined;
80+
| ((a: UploadTaskSnapshot) => unknown) = undefined;
8181
if (!!nextOrObserver) {
8282
if (typeof nextOrObserver === 'function') {
83-
wrappedNextOrObserver = (taskSnapshot: UploadTaskResumableSnapshot) =>
83+
wrappedNextOrObserver = (taskSnapshot: UploadTaskSnapshot) =>
8484
nextOrObserver(
8585
new UploadTaskSnapshotCompat(taskSnapshot, this, this._ref)
8686
);
8787
} else {
8888
wrappedNextOrObserver = {
8989
next: !!nextOrObserver.next
90-
? (taskSnapshot: UploadTaskResumableSnapshot) =>
90+
? (taskSnapshot: UploadTaskSnapshot) =>
9191
nextOrObserver.next!(
9292
new UploadTaskSnapshotCompat(taskSnapshot, this, this._ref)
9393
)

packages/storage/compat/tasksnapshot.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
import * as types from '@firebase/storage-types';
1919
import { ReferenceCompat } from './reference';
2020
import { UploadTaskCompat } from './task';
21-
import { UploadTaskResumableSnapshot } from '../src/tasksnapshot';
21+
import { UploadTaskSnapshot } from '../src/tasksnapshot';
2222
import { Metadata } from '../src/metadata';
2323

2424
export class UploadTaskSnapshotCompat implements types.UploadTaskSnapshot {
2525
constructor(
26-
readonly _delegate: UploadTaskResumableSnapshot,
26+
readonly _delegate: UploadTaskSnapshot,
2727
readonly task: UploadTaskCompat,
2828
readonly ref: ReferenceCompat
2929
) {}

packages/storage/exp/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
import { name, version } from '../package.json';
3636
import { FirebaseApp } from '@firebase/app-types-exp';
3737

38-
export { ref } from '../src/service';
38+
export { ref, StorageService } from '../src/service';
3939
export {
4040
uploadBytes,
4141
uploadBytesResumable,
@@ -45,8 +45,14 @@ export {
4545
list,
4646
listAll,
4747
getDownloadURL,
48-
deleteObject
48+
deleteObject,
49+
StorageReference
4950
} from '../src/reference';
51+
export { Metadata } from '../src/metadata';
52+
export { ListOptions, ListResult } from '../src/list';
53+
export { UploadTask } from '../src/task';
54+
export { UploadResult, UploadTaskSnapshot } from '../src/tasksnapshot';
55+
export { StringFormat } from '../src/implementation/string';
5056

5157
/**
5258
* Type constant for Firebase Storage.

packages/storage/src/implementation/requests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export function metadataForUpload_(
278278
}
279279

280280
/**
281-
* Prepare RequestInfo for resumable uploads as Content-Type: multipart.
281+
* Prepare RequestInfo for uploads as Content-Type: multipart.
282282
*/
283283
export function multipartUpload(
284284
service: StorageService,
@@ -453,7 +453,7 @@ export function getResumableUploadStatus(
453453
* Any uploads via the resumable upload API must transfer a number of bytes
454454
* that is a multiple of this number.
455455
*/
456-
export const resumableUploadChunkSize: number = 256 * 1024;
456+
export const RESUMABLE_UPLOAD_CHUNK_SIZE: number = 256 * 1024;
457457

458458
/**
459459
* @param url From a call to fbs.requests.createResumableUpload.

packages/storage/src/implementation/string.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ import { unknown, invalidFormat } from './error';
1919

2020
/**
2121
* An enumeration of the possible string formats for upload.
22+
* @public
2223
*/
2324
export type StringFormat = string;
25+
/**
26+
* An enumeration of the possible string formats for upload.
27+
* @public
28+
*/
2429
export const StringFormat = {
2530
RAW: 'raw',
2631
BASE64: 'base64',

packages/storage/src/list.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ import { StorageReference } from './reference';
2424

2525
/**
2626
* The options `list()` accepts.
27+
* @public
2728
*/
2829
export interface ListOptions extends types.ListOptions {}
2930

3031
/**
31-
* Result returned by list().
32+
* Result returned by `list()`.
33+
* @public
3234
*/
3335
export interface ListResult {
3436
prefixes: StorageReference[];

packages/storage/src/metadata.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { StorageReference } from './reference';
2424

2525
/**
2626
* The full set of object metadata, including read-only properties.
27+
* @public
2728
*/
2829
interface Metadata extends types.FullMetadata {
2930
type: string | undefined;

0 commit comments

Comments
 (0)