@techfinityedge/koolbase-react-native 5.1.0 → 5.1.1
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/dist/storage-errors.d.ts +6 -6
- package/dist/storage-errors.js +14 -14
- package/package.json +1 -1
package/dist/storage-errors.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class KoolbaseStorageError extends Error {
|
|
|
10
10
|
/**
|
|
11
11
|
* Thrown when an upload is rejected because an object already exists at
|
|
12
12
|
* the requested path — the server responds with 409 Conflict and code
|
|
13
|
-
* `
|
|
13
|
+
* `path_conflict`. Catch it to give the user an "overwrite this file?"
|
|
14
14
|
* prompt, then retry the upload with `overwrite: true`.
|
|
15
15
|
*
|
|
16
16
|
* `path` is the colliding path the server rejected, surfaced from the
|
|
@@ -67,7 +67,7 @@ export declare class KoolbaseStoragePermissionError extends KoolbaseStorageError
|
|
|
67
67
|
/**
|
|
68
68
|
* Thrown when an upload would push the bucket past its configured
|
|
69
69
|
* `max_size_bytes` quota — the server responds with 409 Conflict and code
|
|
70
|
-
* `
|
|
70
|
+
* `quota_exceeded`. The server cleans up the underlying R2 object before
|
|
71
71
|
* returning; nothing leaks. Catch this to surface a "bucket is full"
|
|
72
72
|
* message or prompt the caller to delete older files. The per-bucket
|
|
73
73
|
* quota is set at bucket creation time and is currently immutable.
|
|
@@ -82,7 +82,7 @@ export declare class KoolbaseStorageQuotaError extends KoolbaseStorageError {
|
|
|
82
82
|
/**
|
|
83
83
|
* Thrown when a single file exceeds the bucket's configured
|
|
84
84
|
* `max_file_size_bytes` — the server responds with 413 Payload Too Large
|
|
85
|
-
* and code `
|
|
85
|
+
* and code `file_too_large`. The server cleans up the underlying R2
|
|
86
86
|
* object before returning. The configured per-file limit lives on the
|
|
87
87
|
* bucket record; check `Bucket.maxFileSizeBytes` to surface a clear
|
|
88
88
|
* "files must be under X MB" message at the call site.
|
|
@@ -93,7 +93,7 @@ export declare class KoolbaseStorageFileTooLargeError extends KoolbaseStorageErr
|
|
|
93
93
|
/**
|
|
94
94
|
* Thrown when an upload's content-type isn't in the bucket's configured
|
|
95
95
|
* `allowed_mime_types` allowlist — the server responds with 415
|
|
96
|
-
* Unsupported Media Type and code `
|
|
96
|
+
* Unsupported Media Type and code `mime_not_allowed`. The check runs at
|
|
97
97
|
* presign time, so no bytes are transferred before rejection.
|
|
98
98
|
*
|
|
99
99
|
* Allowlists support `type/*` wildcards (e.g. `image/*` matches every
|
|
@@ -109,8 +109,8 @@ export declare class KoolbaseStorageMimeTypeError extends KoolbaseStorageError {
|
|
|
109
109
|
* falling back to the HTTP status for older or uncoded responses. Always
|
|
110
110
|
* returns an error to throw.
|
|
111
111
|
*
|
|
112
|
-
* Status-fallback note: HTTP 409 covers both
|
|
113
|
-
*
|
|
112
|
+
* Status-fallback note: HTTP 409 covers both path_conflict and
|
|
113
|
+
* quota_exceeded. Without a `code` field, the mapper defaults 409 to
|
|
114
114
|
* {@link KoolbaseStorageConflictError} since path collisions are the more
|
|
115
115
|
* common case. Modern Koolbase servers always emit `code`, so this only
|
|
116
116
|
* matters for very old API responses or non-Koolbase 409s.
|
package/dist/storage-errors.js
CHANGED
|
@@ -20,7 +20,7 @@ exports.KoolbaseStorageError = KoolbaseStorageError;
|
|
|
20
20
|
/**
|
|
21
21
|
* Thrown when an upload is rejected because an object already exists at
|
|
22
22
|
* the requested path — the server responds with 409 Conflict and code
|
|
23
|
-
* `
|
|
23
|
+
* `path_conflict`. Catch it to give the user an "overwrite this file?"
|
|
24
24
|
* prompt, then retry the upload with `overwrite: true`.
|
|
25
25
|
*
|
|
26
26
|
* `path` is the colliding path the server rejected, surfaced from the
|
|
@@ -49,7 +49,7 @@ exports.KoolbaseStorageError = KoolbaseStorageError;
|
|
|
49
49
|
*/
|
|
50
50
|
class KoolbaseStorageConflictError extends KoolbaseStorageError {
|
|
51
51
|
constructor(message, path) {
|
|
52
|
-
super(message ?? 'An object already exists at this path', '
|
|
52
|
+
super(message ?? 'An object already exists at this path', 'path_conflict');
|
|
53
53
|
this.path = path;
|
|
54
54
|
this.name = 'KoolbaseStorageConflictError';
|
|
55
55
|
Object.setPrototypeOf(this, KoolbaseStorageConflictError.prototype);
|
|
@@ -97,7 +97,7 @@ exports.KoolbaseStoragePermissionError = KoolbaseStoragePermissionError;
|
|
|
97
97
|
/**
|
|
98
98
|
* Thrown when an upload would push the bucket past its configured
|
|
99
99
|
* `max_size_bytes` quota — the server responds with 409 Conflict and code
|
|
100
|
-
* `
|
|
100
|
+
* `quota_exceeded`. The server cleans up the underlying R2 object before
|
|
101
101
|
* returning; nothing leaks. Catch this to surface a "bucket is full"
|
|
102
102
|
* message or prompt the caller to delete older files. The per-bucket
|
|
103
103
|
* quota is set at bucket creation time and is currently immutable.
|
|
@@ -108,7 +108,7 @@ exports.KoolbaseStoragePermissionError = KoolbaseStoragePermissionError;
|
|
|
108
108
|
*/
|
|
109
109
|
class KoolbaseStorageQuotaError extends KoolbaseStorageError {
|
|
110
110
|
constructor(message) {
|
|
111
|
-
super(message ?? 'Bucket quota exceeded', '
|
|
111
|
+
super(message ?? 'Bucket quota exceeded', 'quota_exceeded');
|
|
112
112
|
this.name = 'KoolbaseStorageQuotaError';
|
|
113
113
|
Object.setPrototypeOf(this, KoolbaseStorageQuotaError.prototype);
|
|
114
114
|
}
|
|
@@ -117,14 +117,14 @@ exports.KoolbaseStorageQuotaError = KoolbaseStorageQuotaError;
|
|
|
117
117
|
/**
|
|
118
118
|
* Thrown when a single file exceeds the bucket's configured
|
|
119
119
|
* `max_file_size_bytes` — the server responds with 413 Payload Too Large
|
|
120
|
-
* and code `
|
|
120
|
+
* and code `file_too_large`. The server cleans up the underlying R2
|
|
121
121
|
* object before returning. The configured per-file limit lives on the
|
|
122
122
|
* bucket record; check `Bucket.maxFileSizeBytes` to surface a clear
|
|
123
123
|
* "files must be under X MB" message at the call site.
|
|
124
124
|
*/
|
|
125
125
|
class KoolbaseStorageFileTooLargeError extends KoolbaseStorageError {
|
|
126
126
|
constructor(message) {
|
|
127
|
-
super(message ?? 'File exceeds the bucket maximum file size', '
|
|
127
|
+
super(message ?? 'File exceeds the bucket maximum file size', 'file_too_large');
|
|
128
128
|
this.name = 'KoolbaseStorageFileTooLargeError';
|
|
129
129
|
Object.setPrototypeOf(this, KoolbaseStorageFileTooLargeError.prototype);
|
|
130
130
|
}
|
|
@@ -133,7 +133,7 @@ exports.KoolbaseStorageFileTooLargeError = KoolbaseStorageFileTooLargeError;
|
|
|
133
133
|
/**
|
|
134
134
|
* Thrown when an upload's content-type isn't in the bucket's configured
|
|
135
135
|
* `allowed_mime_types` allowlist — the server responds with 415
|
|
136
|
-
* Unsupported Media Type and code `
|
|
136
|
+
* Unsupported Media Type and code `mime_not_allowed`. The check runs at
|
|
137
137
|
* presign time, so no bytes are transferred before rejection.
|
|
138
138
|
*
|
|
139
139
|
* Allowlists support `type/*` wildcards (e.g. `image/*` matches every
|
|
@@ -142,7 +142,7 @@ exports.KoolbaseStorageFileTooLargeError = KoolbaseStorageFileTooLargeError;
|
|
|
142
142
|
*/
|
|
143
143
|
class KoolbaseStorageMimeTypeError extends KoolbaseStorageError {
|
|
144
144
|
constructor(message) {
|
|
145
|
-
super(message ?? 'Content-type not allowed for this bucket', '
|
|
145
|
+
super(message ?? 'Content-type not allowed for this bucket', 'mime_not_allowed');
|
|
146
146
|
this.name = 'KoolbaseStorageMimeTypeError';
|
|
147
147
|
Object.setPrototypeOf(this, KoolbaseStorageMimeTypeError.prototype);
|
|
148
148
|
}
|
|
@@ -154,8 +154,8 @@ exports.KoolbaseStorageMimeTypeError = KoolbaseStorageMimeTypeError;
|
|
|
154
154
|
* falling back to the HTTP status for older or uncoded responses. Always
|
|
155
155
|
* returns an error to throw.
|
|
156
156
|
*
|
|
157
|
-
* Status-fallback note: HTTP 409 covers both
|
|
158
|
-
*
|
|
157
|
+
* Status-fallback note: HTTP 409 covers both path_conflict and
|
|
158
|
+
* quota_exceeded. Without a `code` field, the mapper defaults 409 to
|
|
159
159
|
* {@link KoolbaseStorageConflictError} since path collisions are the more
|
|
160
160
|
* common case. Modern Koolbase servers always emit `code`, so this only
|
|
161
161
|
* matters for very old API responses or non-Koolbase 409s.
|
|
@@ -165,13 +165,13 @@ function koolbaseStorageError(status, body, fallbackMessage = 'Storage request f
|
|
|
165
165
|
const message = body?.error ?? fallbackMessage;
|
|
166
166
|
// ─── code-first ───
|
|
167
167
|
switch (code) {
|
|
168
|
-
case '
|
|
168
|
+
case 'path_conflict':
|
|
169
169
|
return new KoolbaseStorageConflictError(message, body?.path);
|
|
170
|
-
case '
|
|
170
|
+
case 'quota_exceeded':
|
|
171
171
|
return new KoolbaseStorageQuotaError(message);
|
|
172
|
-
case '
|
|
172
|
+
case 'file_too_large':
|
|
173
173
|
return new KoolbaseStorageFileTooLargeError(message);
|
|
174
|
-
case '
|
|
174
|
+
case 'mime_not_allowed':
|
|
175
175
|
return new KoolbaseStorageMimeTypeError(message);
|
|
176
176
|
}
|
|
177
177
|
// ─── status fallback (pre-code servers or uncoded paths) ───
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techfinityedge/koolbase-react-native",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "React Native SDK for Koolbase — auth, database, storage, realtime, feature flags, and functions in one package.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|