@firebase/storage 0.10.0 → 0.10.1-canary.27b5e7d70

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.
@@ -123,19 +123,53 @@ class StorageError extends util.FirebaseError {
123
123
  }
124
124
  }
125
125
  }
126
+ /**
127
+ * @public
128
+ * Error codes that can be attached to `StorageError`s.
129
+ */
130
+ exports.StorageErrorCode = void 0;
131
+ (function (StorageErrorCode) {
132
+ // Shared between all platforms
133
+ StorageErrorCode["UNKNOWN"] = "unknown";
134
+ StorageErrorCode["OBJECT_NOT_FOUND"] = "object-not-found";
135
+ StorageErrorCode["BUCKET_NOT_FOUND"] = "bucket-not-found";
136
+ StorageErrorCode["PROJECT_NOT_FOUND"] = "project-not-found";
137
+ StorageErrorCode["QUOTA_EXCEEDED"] = "quota-exceeded";
138
+ StorageErrorCode["UNAUTHENTICATED"] = "unauthenticated";
139
+ StorageErrorCode["UNAUTHORIZED"] = "unauthorized";
140
+ StorageErrorCode["UNAUTHORIZED_APP"] = "unauthorized-app";
141
+ StorageErrorCode["RETRY_LIMIT_EXCEEDED"] = "retry-limit-exceeded";
142
+ StorageErrorCode["INVALID_CHECKSUM"] = "invalid-checksum";
143
+ StorageErrorCode["CANCELED"] = "canceled";
144
+ // JS specific
145
+ StorageErrorCode["INVALID_EVENT_NAME"] = "invalid-event-name";
146
+ StorageErrorCode["INVALID_URL"] = "invalid-url";
147
+ StorageErrorCode["INVALID_DEFAULT_BUCKET"] = "invalid-default-bucket";
148
+ StorageErrorCode["NO_DEFAULT_BUCKET"] = "no-default-bucket";
149
+ StorageErrorCode["CANNOT_SLICE_BLOB"] = "cannot-slice-blob";
150
+ StorageErrorCode["SERVER_FILE_WRONG_SIZE"] = "server-file-wrong-size";
151
+ StorageErrorCode["NO_DOWNLOAD_URL"] = "no-download-url";
152
+ StorageErrorCode["INVALID_ARGUMENT"] = "invalid-argument";
153
+ StorageErrorCode["INVALID_ARGUMENT_COUNT"] = "invalid-argument-count";
154
+ StorageErrorCode["APP_DELETED"] = "app-deleted";
155
+ StorageErrorCode["INVALID_ROOT_OPERATION"] = "invalid-root-operation";
156
+ StorageErrorCode["INVALID_FORMAT"] = "invalid-format";
157
+ StorageErrorCode["INTERNAL_ERROR"] = "internal-error";
158
+ StorageErrorCode["UNSUPPORTED_ENVIRONMENT"] = "unsupported-environment";
159
+ })(exports.StorageErrorCode || (exports.StorageErrorCode = {}));
126
160
  function prependCode(code) {
127
161
  return 'storage/' + code;
128
162
  }
129
163
  function unknown() {
130
164
  const message = 'An unknown error occurred, please check the error payload for ' +
131
165
  'server response.';
132
- return new StorageError("unknown" /* StorageErrorCode.UNKNOWN */, message);
166
+ return new StorageError(exports.StorageErrorCode.UNKNOWN, message);
133
167
  }
134
168
  function objectNotFound(path) {
135
- return new StorageError("object-not-found" /* StorageErrorCode.OBJECT_NOT_FOUND */, "Object '" + path + "' does not exist.");
169
+ return new StorageError(exports.StorageErrorCode.OBJECT_NOT_FOUND, "Object '" + path + "' does not exist.");
136
170
  }
137
171
  function quotaExceeded(bucket) {
138
- return new StorageError("quota-exceeded" /* StorageErrorCode.QUOTA_EXCEEDED */, "Quota for bucket '" +
172
+ return new StorageError(exports.StorageErrorCode.QUOTA_EXCEEDED, "Quota for bucket '" +
139
173
  bucket +
140
174
  "' exceeded, please view quota on " +
141
175
  'https://firebase.google.com/pricing/.');
@@ -143,49 +177,49 @@ function quotaExceeded(bucket) {
143
177
  function unauthenticated() {
144
178
  const message = 'User is not authenticated, please authenticate using Firebase ' +
145
179
  'Authentication and try again.';
146
- return new StorageError("unauthenticated" /* StorageErrorCode.UNAUTHENTICATED */, message);
180
+ return new StorageError(exports.StorageErrorCode.UNAUTHENTICATED, message);
147
181
  }
148
182
  function unauthorizedApp() {
149
- return new StorageError("unauthorized-app" /* StorageErrorCode.UNAUTHORIZED_APP */, 'This app does not have permission to access Firebase Storage on this project.');
183
+ return new StorageError(exports.StorageErrorCode.UNAUTHORIZED_APP, 'This app does not have permission to access Firebase Storage on this project.');
150
184
  }
151
185
  function unauthorized(path) {
152
- return new StorageError("unauthorized" /* StorageErrorCode.UNAUTHORIZED */, "User does not have permission to access '" + path + "'.");
186
+ return new StorageError(exports.StorageErrorCode.UNAUTHORIZED, "User does not have permission to access '" + path + "'.");
153
187
  }
154
188
  function retryLimitExceeded() {
155
- return new StorageError("retry-limit-exceeded" /* StorageErrorCode.RETRY_LIMIT_EXCEEDED */, 'Max retry time for operation exceeded, please try again.');
189
+ return new StorageError(exports.StorageErrorCode.RETRY_LIMIT_EXCEEDED, 'Max retry time for operation exceeded, please try again.');
156
190
  }
157
191
  function canceled() {
158
- return new StorageError("canceled" /* StorageErrorCode.CANCELED */, 'User canceled the upload/download.');
192
+ return new StorageError(exports.StorageErrorCode.CANCELED, 'User canceled the upload/download.');
159
193
  }
160
194
  function invalidUrl(url) {
161
- return new StorageError("invalid-url" /* StorageErrorCode.INVALID_URL */, "Invalid URL '" + url + "'.");
195
+ return new StorageError(exports.StorageErrorCode.INVALID_URL, "Invalid URL '" + url + "'.");
162
196
  }
163
197
  function invalidDefaultBucket(bucket) {
164
- return new StorageError("invalid-default-bucket" /* StorageErrorCode.INVALID_DEFAULT_BUCKET */, "Invalid default bucket '" + bucket + "'.");
198
+ return new StorageError(exports.StorageErrorCode.INVALID_DEFAULT_BUCKET, "Invalid default bucket '" + bucket + "'.");
165
199
  }
166
200
  function noDefaultBucket() {
167
- return new StorageError("no-default-bucket" /* StorageErrorCode.NO_DEFAULT_BUCKET */, 'No default bucket ' +
201
+ return new StorageError(exports.StorageErrorCode.NO_DEFAULT_BUCKET, 'No default bucket ' +
168
202
  "found. Did you set the '" +
169
203
  CONFIG_STORAGE_BUCKET_KEY +
170
204
  "' property when initializing the app?");
171
205
  }
172
206
  function cannotSliceBlob() {
173
- return new StorageError("cannot-slice-blob" /* StorageErrorCode.CANNOT_SLICE_BLOB */, 'Cannot slice blob for upload. Please retry the upload.');
207
+ return new StorageError(exports.StorageErrorCode.CANNOT_SLICE_BLOB, 'Cannot slice blob for upload. Please retry the upload.');
174
208
  }
175
209
  function serverFileWrongSize() {
176
- return new StorageError("server-file-wrong-size" /* StorageErrorCode.SERVER_FILE_WRONG_SIZE */, 'Server recorded incorrect upload file size, please retry the upload.');
210
+ return new StorageError(exports.StorageErrorCode.SERVER_FILE_WRONG_SIZE, 'Server recorded incorrect upload file size, please retry the upload.');
177
211
  }
178
212
  function noDownloadURL() {
179
- return new StorageError("no-download-url" /* StorageErrorCode.NO_DOWNLOAD_URL */, 'The given file does not have any download URLs.');
213
+ return new StorageError(exports.StorageErrorCode.NO_DOWNLOAD_URL, 'The given file does not have any download URLs.');
180
214
  }
181
215
  /**
182
216
  * @internal
183
217
  */
184
218
  function invalidArgument(message) {
185
- return new StorageError("invalid-argument" /* StorageErrorCode.INVALID_ARGUMENT */, message);
219
+ return new StorageError(exports.StorageErrorCode.INVALID_ARGUMENT, message);
186
220
  }
187
221
  function appDeleted() {
188
- return new StorageError("app-deleted" /* StorageErrorCode.APP_DELETED */, 'The Firebase app was deleted.');
222
+ return new StorageError(exports.StorageErrorCode.APP_DELETED, 'The Firebase app was deleted.');
189
223
  }
190
224
  /**
191
225
  * @param name - The name of the operation that was invalid.
@@ -193,7 +227,7 @@ function appDeleted() {
193
227
  * @internal
194
228
  */
195
229
  function invalidRootOperation(name) {
196
- return new StorageError("invalid-root-operation" /* StorageErrorCode.INVALID_ROOT_OPERATION */, "The operation '" +
230
+ return new StorageError(exports.StorageErrorCode.INVALID_ROOT_OPERATION, "The operation '" +
197
231
  name +
198
232
  "' cannot be performed on a root reference, create a non-root " +
199
233
  "reference using child, such as .child('file.png').");
@@ -203,13 +237,13 @@ function invalidRootOperation(name) {
203
237
  * @param message - A message describing the format violation.
204
238
  */
205
239
  function invalidFormat(format, message) {
206
- return new StorageError("invalid-format" /* StorageErrorCode.INVALID_FORMAT */, "String does not match format '" + format + "': " + message);
240
+ return new StorageError(exports.StorageErrorCode.INVALID_FORMAT, "String does not match format '" + format + "': " + message);
207
241
  }
208
242
  /**
209
243
  * @param message - A message describing the internal error.
210
244
  */
211
245
  function internalError(message) {
212
- throw new StorageError("internal-error" /* StorageErrorCode.INTERNAL_ERROR */, 'Internal error: ' + message);
246
+ throw new StorageError(exports.StorageErrorCode.INTERNAL_ERROR, 'Internal error: ' + message);
213
247
  }
214
248
 
215
249
  /**
@@ -703,9 +737,9 @@ class NetworkRequest {
703
737
  this.pendingConnection_ = null;
704
738
  const hitServer = connection.getErrorCode() === ErrorCode.NO_ERROR;
705
739
  const status = connection.getStatus();
706
- if ((!hitServer ||
707
- isRetryStatusCode(status, this.additionalRetryCodes_)) &&
708
- this.retry) {
740
+ if (!hitServer ||
741
+ (isRetryStatusCode(status, this.additionalRetryCodes_) &&
742
+ this.retry)) {
709
743
  const wasCanceled = connection.getErrorCode() === ErrorCode.ABORT;
710
744
  backoffCallback(false, new RequestEndStatus(false, null, wasCanceled));
711
745
  return;
@@ -870,7 +904,7 @@ function getBlob$1(...args) {
870
904
  return new Blob(args);
871
905
  }
872
906
  else {
873
- throw new StorageError("unsupported-environment" /* StorageErrorCode.UNSUPPORTED_ENVIRONMENT */, "This browser doesn't seem to support creating Blobs");
907
+ throw new StorageError(exports.StorageErrorCode.UNSUPPORTED_ENVIRONMENT, "This browser doesn't seem to support creating Blobs");
874
908
  }
875
909
  }
876
910
  }
@@ -2307,7 +2341,7 @@ class UploadTask {
2307
2341
  this._errorHandler = error => {
2308
2342
  this._request = undefined;
2309
2343
  this._chunkMultiplier = 1;
2310
- if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2344
+ if (error._codeEquals(exports.StorageErrorCode.CANCELED)) {
2311
2345
  this._needToFetchStatus = true;
2312
2346
  this.completeTransitions_();
2313
2347
  }
@@ -2330,7 +2364,7 @@ class UploadTask {
2330
2364
  };
2331
2365
  this._metadataErrorHandler = error => {
2332
2366
  this._request = undefined;
2333
- if (error._codeEquals("canceled" /* StorageErrorCode.CANCELED */)) {
2367
+ if (error._codeEquals(exports.StorageErrorCode.CANCELED)) {
2334
2368
  this.completeTransitions_();
2335
2369
  }
2336
2370
  else {
@@ -3353,7 +3387,7 @@ class FirebaseStorageImpl {
3353
3387
  }
3354
3388
 
3355
3389
  const name = "@firebase/storage";
3356
- const version = "0.10.0";
3390
+ const version = "0.10.1-canary.27b5e7d70";
3357
3391
 
3358
3392
  /**
3359
3393
  * @license
@@ -3658,6 +3692,7 @@ function registerStorage() {
3658
3692
  }
3659
3693
  registerStorage();
3660
3694
 
3695
+ exports.StorageError = StorageError;
3661
3696
  exports.StringFormat = StringFormat;
3662
3697
  exports._FbsBlob = FbsBlob;
3663
3698
  exports._Location = Location;