Skip to content

Commit e3e9a9c

Browse files
committed
Address comments and clean up docs
1 parent ca2257d commit e3e9a9c

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

common/api-review/storage.api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ export class _FirebaseStorageImpl implements FirebaseStorage {
7575
_getAppCheckToken(): Promise<string | null>;
7676
// (undocumented)
7777
_getAuthToken(): Promise<string | null>;
78-
// (undocumented)
7978
get host(): string;
8079
set host(host: string);
8180
// Warning: (ae-forgotten-export) The symbol "RequestInfo" needs to be exported by the entry point index.d.ts
@@ -97,7 +96,7 @@ export class _FirebaseStorageImpl implements FirebaseStorage {
9796
// (undocumented)
9897
readonly _pool: ConnectionPool;
9998
// (undocumented)
100-
protocol: string;
99+
_protocol: string;
101100
// (undocumented)
102101
readonly _url?: string | undefined;
103102
}

packages/storage/src/api.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export {
7979
* Uploads data to this object's location.
8080
* The upload is not resumable.
8181
* @public
82-
* @param ref - StorageReference where data should be uploaded.
82+
* @param ref - {@link StorageReference} where data should be uploaded.
8383
* @param data - The data to upload.
8484
* @param metadata - Metadata for the data to upload.
8585
* @returns A Promise containing an UploadResult
@@ -101,7 +101,7 @@ export function uploadBytes(
101101
* Uploads a string to this object's location.
102102
* The upload is not resumable.
103103
* @public
104-
* @param ref - StorageReference where string should be uploaded.
104+
* @param ref - {@link StorageReference} where string should be uploaded.
105105
* @param value - The string to upload.
106106
* @param format - The format of the string to upload.
107107
* @param metadata - Metadata for the string to upload.
@@ -126,7 +126,7 @@ export function uploadString(
126126
* Uploads data to this object's location.
127127
* The upload can be paused and resumed, and exposes progress updates.
128128
* @public
129-
* @param ref - StorageReference where data should be uploaded.
129+
* @param ref - {@link StorageReference} where data should be uploaded.
130130
* @param data - The data to upload.
131131
* @param metadata - Metadata for the data to upload.
132132
* @returns An UploadTask
@@ -318,7 +318,8 @@ export function getStorage(
318318
* @param storage - The {@link FirebaseStorage} instance
319319
* @param host - The emulator host (ex: localhost)
320320
* @param port - The emulator port (ex: 5001)
321-
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules.
321+
* @param options - Emulator options. `options.mockUserToken` is the mock auth
322+
* token to use for unit testing Security Rules.
322323
* @public
323324
*/
324325
export function connectStorageEmulator(

packages/storage/src/implementation/requests.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function downloadUrlHandler(
9191
metadata as Metadata,
9292
text,
9393
service.host,
94-
service.protocol
94+
service._protocol
9595
);
9696
}
9797
return handler;
@@ -151,7 +151,7 @@ export function getMetadata(
151151
mappings: Mappings
152152
): RequestInfo<Metadata> {
153153
const urlPart = location.fullServerUrl();
154-
const url = makeUrl(urlPart, service.host, service.protocol);
154+
const url = makeUrl(urlPart, service.host, service._protocol);
155155
const method = 'GET';
156156
const timeout = service.maxOperationRetryTime;
157157
const requestInfo = new RequestInfo(
@@ -187,7 +187,7 @@ export function list(
187187
urlParams['maxResults'] = maxResults;
188188
}
189189
const urlPart = location.bucketOnlyServerUrl();
190-
const url = makeUrl(urlPart, service.host, service.protocol);
190+
const url = makeUrl(urlPart, service.host, service._protocol);
191191
const method = 'GET';
192192
const timeout = service.maxOperationRetryTime;
193193
const requestInfo = new RequestInfo(
@@ -207,7 +207,7 @@ export function getDownloadUrl(
207207
mappings: Mappings
208208
): RequestInfo<string | null> {
209209
const urlPart = location.fullServerUrl();
210-
const url = makeUrl(urlPart, service.host, service.protocol);
210+
const url = makeUrl(urlPart, service.host, service._protocol);
211211
const method = 'GET';
212212
const timeout = service.maxOperationRetryTime;
213213
const requestInfo = new RequestInfo(
@@ -227,7 +227,7 @@ export function updateMetadata(
227227
mappings: Mappings
228228
): RequestInfo<Metadata> {
229229
const urlPart = location.fullServerUrl();
230-
const url = makeUrl(urlPart, service.host, service.protocol);
230+
const url = makeUrl(urlPart, service.host, service._protocol);
231231
const method = 'PATCH';
232232
const body = toResourceString(metadata, mappings);
233233
const headers = { 'Content-Type': 'application/json; charset=utf-8' };
@@ -249,7 +249,7 @@ export function deleteObject(
249249
location: Location
250250
): RequestInfo<void> {
251251
const urlPart = location.fullServerUrl();
252-
const url = makeUrl(urlPart, service.host, service.protocol);
252+
const url = makeUrl(urlPart, service.host, service._protocol);
253253
const method = 'DELETE';
254254
const timeout = service.maxOperationRetryTime;
255255

@@ -329,7 +329,7 @@ export function multipartUpload(
329329
throw cannotSliceBlob();
330330
}
331331
const urlParams: UrlParams = { name: metadata_['fullPath']! };
332-
const url = makeUrl(urlPart, service.host, service.protocol);
332+
const url = makeUrl(urlPart, service.host, service._protocol);
333333
const method = 'POST';
334334
const timeout = service.maxUploadRetryTime;
335335
const requestInfo = new RequestInfo(
@@ -392,7 +392,7 @@ export function createResumableUpload(
392392
const urlPart = location.bucketOnlyServerUrl();
393393
const metadataForUpload = metadataForUpload_(location, blob, metadata);
394394
const urlParams: UrlParams = { name: metadataForUpload['fullPath']! };
395-
const url = makeUrl(urlPart, service.host, service.protocol);
395+
const url = makeUrl(urlPart, service.host, service._protocol);
396396
const method = 'POST';
397397
const headers = {
398398
'X-Goog-Upload-Protocol': 'resumable',

packages/storage/src/service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export function connectStorageEmulator(
137137
} = {}
138138
): void {
139139
storage.host = `${host}:${port}`;
140-
storage.protocol = 'http';
140+
storage._protocol = 'http';
141141
const { mockUserToken } = options;
142142
if (mockUserToken) {
143143
storage._overrideAuthToken =
@@ -161,7 +161,7 @@ export class FirebaseStorageImpl implements FirebaseStorage {
161161
* - host:port
162162
*/
163163
private _host: string = DEFAULT_HOST;
164-
protocol: string = 'https';
164+
_protocol: string = 'https';
165165
protected readonly _appId: string | null = null;
166166
private readonly _requests: Set<Request<unknown>>;
167167
private _deleted: boolean = false;
@@ -196,14 +196,14 @@ export class FirebaseStorageImpl implements FirebaseStorage {
196196
}
197197
}
198198

199+
/**
200+
* The host string for this service, in the form of `host` or
201+
* `host:port`.
202+
*/
199203
get host(): string {
200204
return this._host;
201205
}
202206

203-
/**
204-
* Set host string for this service.
205-
* @param host - host string in the form of host or host:port
206-
*/
207207
set host(host: string) {
208208
this._host = host;
209209
if (this._url != null) {

packages/storage/test/unit/requests.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ describe('Firebase Storage > Requests', () => {
202202
const requestInfo = getMetadata(storageService, location, mappings);
203203
assertObjectIncludes(
204204
{
205-
url: makeUrl(url, storageService.host, storageService.protocol),
205+
url: makeUrl(url, storageService.host, storageService._protocol),
206206
method: 'GET',
207207
body: null,
208208
headers: {},
@@ -225,7 +225,7 @@ describe('Firebase Storage > Requests', () => {
225225
url: makeUrl(
226226
locationNormalNoObjUrl,
227227
storageService.host,
228-
storageService.protocol
228+
storageService._protocol
229229
),
230230
method: 'GET',
231231
body: null,
@@ -259,7 +259,7 @@ describe('Firebase Storage > Requests', () => {
259259
url: makeUrl(
260260
locationNoObjectUrl,
261261
storageService.host,
262-
storageService.protocol
262+
storageService._protocol
263263
),
264264
method: 'GET',
265265
body: null,
@@ -327,7 +327,7 @@ describe('Firebase Storage > Requests', () => {
327327
const requestInfo = getDownloadUrl(storageService, location, mappings);
328328
assertObjectIncludes(
329329
{
330-
url: makeUrl(url, storageService.host, storageService.protocol),
330+
url: makeUrl(url, storageService.host, storageService._protocol),
331331
method: 'GET',
332332
body: null,
333333
headers: {},
@@ -362,7 +362,7 @@ describe('Firebase Storage > Requests', () => {
362362
);
363363
assertObjectIncludes(
364364
{
365-
url: makeUrl(url, storageService.host, storageService.protocol),
365+
url: makeUrl(url, storageService.host, storageService._protocol),
366366
method: 'PATCH',
367367
body: metadataString,
368368
headers: { 'Content-Type': metadataContentType },
@@ -393,7 +393,7 @@ describe('Firebase Storage > Requests', () => {
393393
const requestInfo = deleteObject(storageService, location);
394394
assertObjectIncludes(
395395
{
396-
url: makeUrl(url, storageService.host, storageService.protocol),
396+
url: makeUrl(url, storageService.host, storageService._protocol),
397397
method: 'DELETE',
398398
body: null,
399399
headers: {},
@@ -459,7 +459,7 @@ describe('Firebase Storage > Requests', () => {
459459

460460
assertObjectIncludes(
461461
{
462-
url: makeUrl(url, storageService.host, storageService.protocol),
462+
url: makeUrl(url, storageService.host, storageService._protocol),
463463
method: 'POST',
464464
urlParams: { name: location.path },
465465
headers: {
@@ -504,7 +504,7 @@ describe('Firebase Storage > Requests', () => {
504504
);
505505
assertObjectIncludes(
506506
{
507-
url: makeUrl(url, storageService.host, storageService.protocol),
507+
url: makeUrl(url, storageService.host, storageService._protocol),
508508
method: 'POST',
509509
urlParams: { name: location.path },
510510
headers: {

packages/storage/test/unit/service.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ GOOG4-RSA-SHA256`
258258
);
259259
connectStorageEmulator(service, 'test.host.org', 1234);
260260
expect(service.host).to.equal('test.host.org:1234');
261-
expect(service.protocol).to.equal('http');
261+
expect(service._protocol).to.equal('http');
262262
void getDownloadURL(ref(service, 'test.png'));
263263
});
264264
it('sets mock user token string if specified', done => {
@@ -285,7 +285,7 @@ GOOG4-RSA-SHA256`
285285
);
286286
connectStorageEmulator(service, 'test.host.org', 1234, { mockUserToken });
287287
expect(service.host).to.equal('test.host.org:1234');
288-
expect(service.protocol).to.equal('http');
288+
expect(service._protocol).to.equal('http');
289289
expect(service._overrideAuthToken).to.equal(mockUserToken);
290290
void getDownloadURL(ref(service, 'test.png'));
291291
});
@@ -316,7 +316,7 @@ GOOG4-RSA-SHA256`
316316
mockUserToken: { sub: 'alice' }
317317
});
318318
expect(service.host).to.equal('test.host.org:1234');
319-
expect(service.protocol).to.equal('http');
319+
expect(service._protocol).to.equal('http');
320320
token = service._overrideAuthToken;
321321
// Token should be an unsigned JWT with header { "alg": "none", "type": "JWT" } (base64url):
322322
expect(token).to.match(/^eyJhbGciOiJub25lIiwidHlwZSI6IkpXVCJ9\./);

0 commit comments

Comments
 (0)