@koolbase/core 11.2.0 → 11.3.0

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.
@@ -1,4 +1,4 @@
1
- import { KoolbaseError, KoolbaseUnauthenticatedError } from './errors.js';
1
+ import { KoolbaseError, KoolbasePlanLimitError, KoolbaseUnauthenticatedError } from './errors.js';
2
2
  /**
3
3
  * Base error type for all Koolbase storage errors. Catchable via
4
4
  * `instanceof KoolbaseStorageError` to handle any storage-related failure
@@ -104,6 +104,20 @@ export class KoolbaseStoragePermissionError extends KoolbaseStorageError {
104
104
  * failure: presign again and send the same bytes. Worth catching rather than
105
105
  * showing "upload failed" to someone whose file was fine.
106
106
  */
107
+ /**
108
+ * Minting a presigned upload URL failed. The message carries the underlying
109
+ * reason — a misconfigured bucket, or the object store refusing.
110
+ *
111
+ * Not the user's doing, and not a retry they can fix: distinct from
112
+ * KoolbaseUploadExpiredError, which is a retry that will work.
113
+ */
114
+ export class KoolbaseUploadURLFailedError extends KoolbaseStorageError {
115
+ constructor(message) {
116
+ super(message ?? 'Could not create an upload URL', 'upload_url_failed');
117
+ this.name = 'KoolbaseUploadURLFailedError';
118
+ Object.setPrototypeOf(this, KoolbaseUploadURLFailedError.prototype);
119
+ }
120
+ }
107
121
  export class KoolbaseUploadExpiredError extends KoolbaseStorageError {
108
122
  constructor(message) {
109
123
  super(message ?? 'This upload is past the confirmation window — please re-upload', 'upload_expired');
@@ -219,6 +233,10 @@ export function koolbaseStorageError(status, body, fallbackMessage = 'Storage re
219
233
  switch (code) {
220
234
  case 'path_conflict':
221
235
  return new KoolbaseStorageConflictError(message, body?.path);
236
+ case 'plan_limit_reached': {
237
+ const d = (body?.details ?? {});
238
+ return new KoolbasePlanLimitError(message, d.resource, d.limit, d.plan);
239
+ }
222
240
  case 'quota_exceeded':
223
241
  return new KoolbaseStorageQuotaError(message);
224
242
  case 'upload_expired':
@@ -231,6 +249,8 @@ export function koolbaseStorageError(status, body, fallbackMessage = 'Storage re
231
249
  return new KoolbaseStorageMimeTypeError(message);
232
250
  case 'metadata_invalid':
233
251
  return new KoolbaseStorageMetadataInvalidError(message, body?.detail);
252
+ case 'upload_url_failed':
253
+ return new KoolbaseUploadURLFailedError(message);
234
254
  }
235
255
  // ─── status fallback (pre-code servers or uncoded paths) ───
236
256
  switch (status) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koolbase/core",
3
- "version": "11.2.0",
3
+ "version": "11.3.0",
4
4
  "description": "Koolbase SDK core \u2014 shared behaviour behind @koolbase/react-native and @koolbase/js. Install one of those, not this.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/esm/index.d.ts",