@firebase/storage 0.10.0 → 0.10.1-canary.0bab0b7a7
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 +62 -27
- package/dist/index.browser.cjs.js.map +1 -1
- package/dist/index.cjs.js +3688 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm2017.js +62 -28
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +62 -28
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +61 -26
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +61 -27
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api.d.ts +1 -0
- package/dist/node-esm/src/implementation/error.d.ts +1 -1
- package/dist/node-esm/src/public-types.d.ts +2 -11
- package/dist/node-esm/test/unit/testshared.d.ts +1 -1
- package/dist/src/api.d.ts +1 -0
- package/dist/src/implementation/error.d.ts +1 -1
- package/dist/src/public-types.d.ts +2 -11
- package/dist/storage-public.d.ts +51 -3
- package/dist/storage.d.ts +9 -20
- package/dist/test/unit/testshared.d.ts +1 -1
- package/package.json +11 -7
|
@@ -115,19 +115,53 @@ class StorageError extends FirebaseError {
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* @public
|
|
120
|
+
* Error codes that can be attached to `StorageError`s.
|
|
121
|
+
*/
|
|
122
|
+
var StorageErrorCode;
|
|
123
|
+
(function (StorageErrorCode) {
|
|
124
|
+
// Shared between all platforms
|
|
125
|
+
StorageErrorCode["UNKNOWN"] = "unknown";
|
|
126
|
+
StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found";
|
|
127
|
+
StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found";
|
|
128
|
+
StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found";
|
|
129
|
+
StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded";
|
|
130
|
+
StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated";
|
|
131
|
+
StorageErrorCode["UNAUTHORIZED"] = "unauthorized";
|
|
132
|
+
StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app";
|
|
133
|
+
StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded";
|
|
134
|
+
StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum";
|
|
135
|
+
StorageErrorCode["CANCELED"] = "canceled";
|
|
136
|
+
// JS specific
|
|
137
|
+
StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name";
|
|
138
|
+
StorageErrorCode["INVALID_URL"] = "invalid-url";
|
|
139
|
+
StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket";
|
|
140
|
+
StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket";
|
|
141
|
+
StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob";
|
|
142
|
+
StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size";
|
|
143
|
+
StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url";
|
|
144
|
+
StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument";
|
|
145
|
+
StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count";
|
|
146
|
+
StorageErrorCode["APP_DELETED"] = "app-deleted";
|
|
147
|
+
StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation";
|
|
148
|
+
StorageErrorCode["INVALID_FORMAT"] = "invalid-format";
|
|
149
|
+
StorageErrorCode["INTERNAL_ERROR"] = "internal-error";
|
|
150
|
+
StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment";
|
|
151
|
+
})(StorageErrorCode || (StorageErrorCode = {}));
|
|
118
152
|
function prependCode(code) {
|
|
119
153
|
return 'storage/' + code;
|
|
120
154
|
}
|
|
121
155
|
function unknown() {
|
|
122
156
|
const message = 'An unknown error occurred, please check the error payload for ' +
|
|
123
157
|
'server response.';
|
|
124
|
-
return new StorageError(
|
|
158
|
+
return new StorageError(StorageErrorCode.UNKNOWN, message);
|
|
125
159
|
}
|
|
126
160
|
function objectNotFound(path) {
|
|
127
|
-
return new StorageError(
|
|
161
|
+
return new StorageError(StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist.");
|
|
128
162
|
}
|
|
129
163
|
function quotaExceeded(bucket) {
|
|
130
|
-
return new StorageError(
|
|
164
|
+
return new StorageError(StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" +
|
|
131
165
|
bucket +
|
|
132
166
|
"' exceeded, please view quota on " +
|
|
133
167
|
'https://firebase.google.com/pricing/.');
|
|
@@ -135,49 +169,49 @@ function quotaExceeded(bucket) {
|
|
|
135
169
|
function unauthenticated() {
|
|
136
170
|
const message = 'User is not authenticated, please authenticate using Firebase ' +
|
|
137
171
|
'Authentication and try again.';
|
|
138
|
-
return new StorageError(
|
|
172
|
+
return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);
|
|
139
173
|
}
|
|
140
174
|
function unauthorizedApp() {
|
|
141
|
-
return new StorageError(
|
|
175
|
+
return new StorageError(StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.');
|
|
142
176
|
}
|
|
143
177
|
function unauthorized(path) {
|
|
144
|
-
return new StorageError(
|
|
178
|
+
return new StorageError(StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'.");
|
|
145
179
|
}
|
|
146
180
|
function retryLimitExceeded() {
|
|
147
|
-
return new StorageError(
|
|
181
|
+
return new StorageError(StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.');
|
|
148
182
|
}
|
|
149
183
|
function canceled() {
|
|
150
|
-
return new StorageError(
|
|
184
|
+
return new StorageError(StorageErrorCode.CANCELED, 'User canceled the upload/download.');
|
|
151
185
|
}
|
|
152
186
|
function invalidUrl(url) {
|
|
153
|
-
return new StorageError(
|
|
187
|
+
return new StorageError(StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'.");
|
|
154
188
|
}
|
|
155
189
|
function invalidDefaultBucket(bucket) {
|
|
156
|
-
return new StorageError(
|
|
190
|
+
return new StorageError(StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'.");
|
|
157
191
|
}
|
|
158
192
|
function noDefaultBucket() {
|
|
159
|
-
return new StorageError(
|
|
193
|
+
return new StorageError(StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' +
|
|
160
194
|
"found. Did you set the '" +
|
|
161
195
|
CONFIG_STORAGE_BUCKET_KEY +
|
|
162
196
|
"' property when initializing the app?");
|
|
163
197
|
}
|
|
164
198
|
function cannotSliceBlob() {
|
|
165
|
-
return new StorageError(
|
|
199
|
+
return new StorageError(StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.');
|
|
166
200
|
}
|
|
167
201
|
function serverFileWrongSize() {
|
|
168
|
-
return new StorageError(
|
|
202
|
+
return new StorageError(StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.');
|
|
169
203
|
}
|
|
170
204
|
function noDownloadURL() {
|
|
171
|
-
return new StorageError(
|
|
205
|
+
return new StorageError(StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.');
|
|
172
206
|
}
|
|
173
207
|
/**
|
|
174
208
|
* @internal
|
|
175
209
|
*/
|
|
176
210
|
function invalidArgument(message) {
|
|
177
|
-
return new StorageError(
|
|
211
|
+
return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);
|
|
178
212
|
}
|
|
179
213
|
function appDeleted() {
|
|
180
|
-
return new StorageError(
|
|
214
|
+
return new StorageError(StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.');
|
|
181
215
|
}
|
|
182
216
|
/**
|
|
183
217
|
* @param name - The name of the operation that was invalid.
|
|
@@ -185,7 +219,7 @@ function appDeleted() {
|
|
|
185
219
|
* @internal
|
|
186
220
|
*/
|
|
187
221
|
function invalidRootOperation(name) {
|
|
188
|
-
return new StorageError(
|
|
222
|
+
return new StorageError(StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" +
|
|
189
223
|
name +
|
|
190
224
|
"' cannot be performed on a root reference, create a non-root " +
|
|
191
225
|
"reference using child, such as .child('file.png').");
|
|
@@ -195,13 +229,13 @@ function invalidRootOperation(name) {
|
|
|
195
229
|
* @param message - A message describing the format violation.
|
|
196
230
|
*/
|
|
197
231
|
function invalidFormat(format, message) {
|
|
198
|
-
return new StorageError(
|
|
232
|
+
return new StorageError(StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message);
|
|
199
233
|
}
|
|
200
234
|
/**
|
|
201
235
|
* @param message - A message describing the internal error.
|
|
202
236
|
*/
|
|
203
237
|
function internalError(message) {
|
|
204
|
-
throw new StorageError(
|
|
238
|
+
throw new StorageError(StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message);
|
|
205
239
|
}
|
|
206
240
|
|
|
207
241
|
/**
|
|
@@ -695,9 +729,9 @@ class NetworkRequest {
|
|
|
695
729
|
this.pendingConnection_ = null;
|
|
696
730
|
const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
|
|
697
731
|
const status = connection.getStatus();
|
|
698
|
-
if (
|
|
699
|
-
isRetryStatusCode(status, this.additionalRetryCodes_)
|
|
700
|
-
|
|
732
|
+
if (!hitServer ||
|
|
733
|
+
(isRetryStatusCode(status, this.additionalRetryCodes_) &&
|
|
734
|
+
this.retry)) {
|
|
701
735
|
const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
|
|
702
736
|
backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
|
|
703
737
|
return;
|
|
@@ -862,7 +896,7 @@ function getBlob$1(...args) {
|
|
|
862
896
|
return new Blob(args);
|
|
863
897
|
}
|
|
864
898
|
else {
|
|
865
|
-
throw new StorageError(
|
|
899
|
+
throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs");
|
|
866
900
|
}
|
|
867
901
|
}
|
|
868
902
|
}
|
|
@@ -2299,7 +2333,7 @@ class UploadTask {
|
|
|
2299
2333
|
this._errorHandler = error => {
|
|
2300
2334
|
this._request = undefined;
|
|
2301
2335
|
this._chunkMultiplier = 1;
|
|
2302
|
-
if (error._codeEquals(
|
|
2336
|
+
if (error._codeEquals(StorageErrorCode.CANCELED)) {
|
|
2303
2337
|
this._needToFetchStatus = true;
|
|
2304
2338
|
this.completeTransitions_();
|
|
2305
2339
|
}
|
|
@@ -2322,7 +2356,7 @@ class UploadTask {
|
|
|
2322
2356
|
};
|
|
2323
2357
|
this._metadataErrorHandler = error => {
|
|
2324
2358
|
this._request = undefined;
|
|
2325
|
-
if (error._codeEquals(
|
|
2359
|
+
if (error._codeEquals(StorageErrorCode.CANCELED)) {
|
|
2326
2360
|
this.completeTransitions_();
|
|
2327
2361
|
}
|
|
2328
2362
|
else {
|
|
@@ -3345,7 +3379,7 @@ class FirebaseStorageImpl {
|
|
|
3345
3379
|
}
|
|
3346
3380
|
|
|
3347
3381
|
const name = "@firebase/storage";
|
|
3348
|
-
const version = "0.10.
|
|
3382
|
+
const version = "0.10.1-canary.0bab0b7a7";
|
|
3349
3383
|
|
|
3350
3384
|
/**
|
|
3351
3385
|
* @license
|
|
@@ -3650,5 +3684,5 @@ function registerStorage() {
|
|
|
3650
3684
|
}
|
|
3651
3685
|
registerStorage();
|
|
3652
3686
|
|
|
3653
|
-
export { StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
|
|
3687
|
+
export { StorageError, StorageErrorCode, StringFormat, FbsBlob as _FbsBlob, Location as _Location, TaskEvent as _TaskEvent, TaskState as _TaskState, UploadTask as _UploadTask, dataFromString as _dataFromString, _getChild, invalidArgument as _invalidArgument, invalidRootOperation as _invalidRootOperation, connectStorageEmulator, deleteObject, getBlob, getBytes, getDownloadURL, getMetadata, getStorage, getStream, list, listAll, ref, updateMetadata, uploadBytes, uploadBytesResumable, uploadString };
|
|
3654
3688
|
//# sourceMappingURL=index.node.esm.js.map
|