@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.
@@ -113,19 +113,53 @@ class StorageError extends FirebaseError {
113
113
  }
114
114
  }
115
115
  }
116
+ /**
117
+ * @public
118
+ * Error codes that can be attached to `StorageError`s.
119
+ */
120
+ var StorageErrorCode;
121
+ (function (StorageErrorCode) {
122
+ // Shared between all platforms
123
+ StorageErrorCode["UNKNOWN"] = "unknown";
124
+ StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found";
125
+ StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found";
126
+ StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found";
127
+ StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded";
128
+ StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated";
129
+ StorageErrorCode["UNAUTHORIZED"] = "unauthorized";
130
+ StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app";
131
+ StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded";
132
+ StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum";
133
+ StorageErrorCode["CANCELED"] = "canceled";
134
+ // JS specific
135
+ StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name";
136
+ StorageErrorCode["INVALID_URL"] = "invalid-url";
137
+ StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket";
138
+ StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket";
139
+ StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob";
140
+ StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size";
141
+ StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url";
142
+ StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument";
143
+ StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count";
144
+ StorageErrorCode["APP_DELETED"] = "app-deleted";
145
+ StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation";
146
+ StorageErrorCode["INVALID_FORMAT"] = "invalid-format";
147
+ StorageErrorCode["INTERNAL_ERROR"] = "internal-error";
148
+ StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment";
149
+ })(StorageErrorCode || (StorageErrorCode = {}));
116
150
  function prependCode(code) {
117
151
  return 'storage/' + code;
118
152
  }
119
153
  function unknown() {
120
154
  const message = 'An unknown error occurred, please check the error payload for ' +
121
155
  'server response.';
122
- return new StorageError("unknown" /* StorageErrorCode.UNKNOWN */, message);
156
+ return new StorageError(StorageErrorCode.UNKNOWN, message);
123
157
  }
124
158
  function objectNotFound(path) {
125
- return new StorageError("object-not-found" /* StorageErrorCode.OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
159
+ return new StorageError(StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist.");
126
160
  }
127
161
  function quotaExceeded(bucket) {
128
- return new StorageError("quota-exceeded" /* StorageErrorCode.QUOTA_EXCEEDED */, "Quota for bucket '" +
162
+ return new StorageError(StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" +
129
163
  bucket +
130
164
  "' exceeded, please view quota on " +
131
165
  'https://firebase.google.com/pricing/.');
@@ -133,52 +167,52 @@ function quotaExceeded(bucket) {
133
167
  function unauthenticated() {
134
168
  const message = 'User is not authenticated, please authenticate using Firebase ' +
135
169
  'Authentication and try again.';
136
- return new StorageError("unauthenticated" /* StorageErrorCode.UNAUTHENTICATED */, message);
170
+ return new StorageError(StorageErrorCode.UNAUTHENTICATED, message);
137
171
  }
138
172
  function unauthorizedApp() {
139
- return new StorageError("unauthorized-app" /* StorageErrorCode.UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
173
+ return new StorageError(StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.');
140
174
  }
141
175
  function unauthorized(path) {
142
- return new StorageError("unauthorized" /* StorageErrorCode.UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
176
+ return new StorageError(StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'.");
143
177
  }
144
178
  function retryLimitExceeded() {
145
- return new StorageError("retry-limit-exceeded" /* StorageErrorCode.RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
179
+ return new StorageError(StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.');
146
180
  }
147
181
  function canceled() {
148
- return new StorageError("canceled" /* StorageErrorCode.CANCELED */, 'User canceled the upload/download.');
182
+ return new StorageError(StorageErrorCode.CANCELED, 'User canceled the upload/download.');
149
183
  }
150
184
  function invalidUrl(url) {
151
- return new StorageError("invalid-url" /* StorageErrorCode.INVALID_URL */, "Invalid URL '" + url + "'.");
185
+ return new StorageError(StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'.");
152
186
  }
153
187
  function invalidDefaultBucket(bucket) {
154
- return new StorageError("invalid-default-bucket" /* StorageErrorCode.INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
188
+ return new StorageError(StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'.");
155
189
  }
156
190
  function noDefaultBucket() {
157
- return new StorageError("no-default-bucket" /* StorageErrorCode.NO_DEFAULT_BUCKET */, 'No default bucket ' +
191
+ return new StorageError(StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' +
158
192
  "found. Did you set the '" +
159
193
  CONFIG_STORAGE_BUCKET_KEY +
160
194
  "' property when initializing the app?");
161
195
  }
162
196
  function cannotSliceBlob() {
163
- return new StorageError("cannot-slice-blob" /* StorageErrorCode.CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
197
+ return new StorageError(StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.');
164
198
  }
165
199
  function serverFileWrongSize() {
166
- return new StorageError("server-file-wrong-size" /* StorageErrorCode.SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
200
+ return new StorageError(StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.');
167
201
  }
168
202
  function noDownloadURL() {
169
- return new StorageError("no-download-url" /* StorageErrorCode.NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
203
+ return new StorageError(StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.');
170
204
  }
171
205
  function missingPolyFill(polyFill) {
172
- return new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);
206
+ return new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, `${polyFill} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`);
173
207
  }
174
208
  /**
175
209
  * @internal
176
210
  */
177
211
  function invalidArgument(message) {
178
- return new StorageError("invalid-argument" /* StorageErrorCode.INVALID_ARGUMENT */, message);
212
+ return new StorageError(StorageErrorCode.INVALID_ARGUMENT, message);
179
213
  }
180
214
  function appDeleted() {
181
- return new StorageError("app-deleted" /* StorageErrorCode.APP_DELETED */, 'The Firebase app was deleted.');
215
+ return new StorageError(StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.');
182
216
  }
183
217
  /**
184
218
  * @param name - The name of the operation that was invalid.
@@ -186,7 +220,7 @@ function appDeleted() {
186
220
  * @internal
187
221
  */
188
222
  function invalidRootOperation(name) {
189
- return new StorageError("invalid-root-operation" /* StorageErrorCode.INVALID_ROOT_OPERATION */, "The operation '" +
223
+ return new StorageError(StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" +
190
224
  name +
191
225
  "' cannot be performed on a root reference, create a non-root " +
192
226
  "reference using child, such as .child('file.png').");
@@ -196,13 +230,13 @@ function invalidRootOperation(name) {
196
230
  * @param message - A message describing the format violation.
197
231
  */
198
232
  function invalidFormat(format, message) {
199
- return new StorageError("invalid-format" /* StorageErrorCode.INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
233
+ return new StorageError(StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message);
200
234
  }
201
235
  /**
202
236
  * @param message - A message describing the internal error.
203
237
  */
204
238
  function internalError(message) {
205
- throw new StorageError("internal-error" /* StorageErrorCode.INTERNAL_ERROR */, 'Internal error: ' + message);
239
+ throw new StorageError(StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message);
206
240
  }
207
241
 
208
242
  /**
@@ -696,9 +730,9 @@ class NetworkRequest {
696
730
  this.pendingConnection_ = null;
697
731
  const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
698
732
  const status = connection.getStatus();
699
- if ((!hitServer ||
700
- isRetryStatusCode(status, this.additionalRetryCodes_)) &&
701
- this.retry) {
733
+ if (!hitServer ||
734
+ (isRetryStatusCode(status, this.additionalRetryCodes_) &&
735
+ this.retry)) {
702
736
  const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
703
737
  backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
704
738
  return;
@@ -863,7 +897,7 @@ function getBlob$1(...args) {
863
897
  return new Blob(args);
864
898
  }
865
899
  else {
866
- throw new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
900
+ throw new StorageError(StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs");
867
901
  }
868
902
  }
869
903
  }
@@ -2285,7 +2319,7 @@ class UploadTask {
2285
2319
  this._errorHandler = error => {
2286
2320
  this._request = undefined;
2287
2321
  this._chunkMultiplier = 1;
2288
- if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2322
+ if (error._codeEquals(StorageErrorCode.CANCELED)) {
2289
2323
  this._needToFetchStatus = true;
2290
2324
  this.completeTransitions_();
2291
2325
  }
@@ -2308,7 +2342,7 @@ class UploadTask {
2308
2342
  };
2309
2343
  this._metadataErrorHandler = error => {
2310
2344
  this._request = undefined;
2311
- if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2345
+ if (error._codeEquals(StorageErrorCode.CANCELED)) {
2312
2346
  this.completeTransitions_();
2313
2347
  }
2314
2348
  else {
@@ -3314,7 +3348,7 @@ class FirebaseStorageImpl {
3314
3348
  }
3315
3349
 
3316
3350
  const name = "@firebase/storage";
3317
- const version = "0.10.0";
3351
+ const version = "0.10.1-canary.0bab0b7a7";
3318
3352
 
3319
3353
  /**
3320
3354
  * @license
@@ -3621,5 +3655,5 @@ function registerStorage() {
3621
3655
  }
3622
3656
  registerStorage();
3623
3657
 
3624
- 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 };
3658
+ 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 };
3625
3659
  //# sourceMappingURL=index.esm2017.js.map