@koolbase/react-native 9.1.0 → 10.0.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +1342 -0
  2. package/README.md +462 -511
  3. package/dist/{auth-storage.d.ts → cjs/auth-storage.d.ts} +1 -1
  4. package/dist/cjs/index.d.ts +19 -0
  5. package/dist/cjs/index.js +125 -0
  6. package/dist/cjs/package.json +3 -0
  7. package/dist/cjs/platform.d.ts +2 -0
  8. package/dist/cjs/platform.js +43 -0
  9. package/dist/esm/auth-storage.d.ts +26 -0
  10. package/dist/esm/auth-storage.js +100 -0
  11. package/dist/esm/index.d.ts +19 -0
  12. package/dist/esm/index.js +106 -0
  13. package/dist/esm/package.json +3 -0
  14. package/dist/esm/platform.d.ts +2 -0
  15. package/dist/esm/platform.js +37 -0
  16. package/package.json +30 -24
  17. package/dist/analytics.d.ts +0 -24
  18. package/dist/analytics.js +0 -114
  19. package/dist/apple-auth.d.ts +0 -22
  20. package/dist/apple-auth.js +0 -74
  21. package/dist/auth-errors.d.ts +0 -117
  22. package/dist/auth-errors.js +0 -250
  23. package/dist/auth.d.ts +0 -199
  24. package/dist/auth.js +0 -794
  25. package/dist/cache-store.d.ts +0 -11
  26. package/dist/cache-store.js +0 -136
  27. package/dist/code-push.d.ts +0 -59
  28. package/dist/code-push.js +0 -255
  29. package/dist/database-errors.d.ts +0 -95
  30. package/dist/database-errors.js +0 -173
  31. package/dist/database.d.ts +0 -208
  32. package/dist/database.js +0 -508
  33. package/dist/device-id.d.ts +0 -1
  34. package/dist/device-id.js +0 -60
  35. package/dist/device-metadata.d.ts +0 -36
  36. package/dist/device-metadata.js +0 -102
  37. package/dist/flags.d.ts +0 -15
  38. package/dist/flags.js +0 -76
  39. package/dist/functions.d.ts +0 -8
  40. package/dist/functions.js +0 -70
  41. package/dist/index.d.ts +0 -45
  42. package/dist/index.js +0 -193
  43. package/dist/logic-engine.d.ts +0 -17
  44. package/dist/logic-engine.js +0 -193
  45. package/dist/messaging.d.ts +0 -13
  46. package/dist/messaging.js +0 -36
  47. package/dist/realtime.d.ts +0 -19
  48. package/dist/realtime.js +0 -148
  49. package/dist/record.d.ts +0 -2
  50. package/dist/record.js +0 -20
  51. package/dist/storage-errors.d.ts +0 -163
  52. package/dist/storage-errors.js +0 -249
  53. package/dist/storage.d.ts +0 -184
  54. package/dist/storage.js +0 -438
  55. package/dist/sync-engine.d.ts +0 -16
  56. package/dist/sync-engine.js +0 -86
  57. package/dist/types.d.ts +0 -470
  58. package/dist/types.js +0 -40
  59. /package/dist/{auth-storage.js → cjs/auth-storage.js} +0 -0
@@ -1,193 +0,0 @@
1
- "use strict";
2
- // ─── Logic Engine ────────────────────────────────────────────────────────
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.KoolbaseLogicEngine = void 0;
5
- class KoolbaseLogicEngine {
6
- // ─── Public API ───────────────────────────────────────────────────────────
7
- execute(flowId, flows, context, config, flags) {
8
- try {
9
- const flowJson = flows[flowId];
10
- if (!flowJson) {
11
- return { hasEvent: false, args: {}, completed: true };
12
- }
13
- const ctx = {
14
- context: { ...context },
15
- config,
16
- flags,
17
- };
18
- return this.evalNode(flowJson, ctx);
19
- }
20
- catch (e) {
21
- return {
22
- hasEvent: false,
23
- args: {},
24
- completed: false,
25
- error: String(e),
26
- };
27
- }
28
- }
29
- // ─── Node evaluation ──────────────────────────────────────────────────────
30
- evalNode(node, ctx) {
31
- switch (node.type) {
32
- case 'if':
33
- return this.evalIf(node, ctx);
34
- case 'sequence':
35
- return this.evalSequence(node, ctx);
36
- case 'event':
37
- return { hasEvent: true, eventName: node.name, args: node.args ?? {}, completed: true };
38
- case 'set':
39
- this.setNested(ctx.context, node.key, node.value);
40
- return { hasEvent: false, args: {}, completed: true };
41
- default:
42
- return { hasEvent: false, args: {}, completed: true };
43
- }
44
- }
45
- evalIf(node, ctx) {
46
- const result = this.evalCondition(node.condition, ctx);
47
- if (result)
48
- return this.evalNode(node.then, ctx);
49
- if (node.else)
50
- return this.evalNode(node.else, ctx);
51
- return { hasEvent: false, args: {}, completed: true };
52
- }
53
- evalSequence(node, ctx) {
54
- for (const step of node.steps) {
55
- const result = this.evalNode(step, ctx);
56
- if (result.hasEvent)
57
- return result;
58
- }
59
- return { hasEvent: false, args: {}, completed: true };
60
- }
61
- // ─── Condition evaluation ─────────────────────────────────────────────────
62
- evalCondition(condition, ctx) {
63
- switch (condition.op) {
64
- case 'eq': {
65
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
66
- return String(left) === String(condition.right);
67
- }
68
- case 'neq': {
69
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
70
- return String(left) !== String(condition.right);
71
- }
72
- case 'gt': {
73
- const left = Number(condition.left ? this.resolve(condition.left.from, ctx) : undefined);
74
- const right = Number(condition.right);
75
- return !isNaN(left) && !isNaN(right) && left > right;
76
- }
77
- case 'lt': {
78
- const left = Number(condition.left ? this.resolve(condition.left.from, ctx) : undefined);
79
- const right = Number(condition.right);
80
- return !isNaN(left) && !isNaN(right) && left < right;
81
- }
82
- case 'and':
83
- return (condition.conditions ?? []).every((c) => this.evalCondition(c, ctx));
84
- case 'or':
85
- return (condition.conditions ?? []).some((c) => this.evalCondition(c, ctx));
86
- case 'exists': {
87
- const val = condition.value ? this.resolve(condition.value.from, ctx) : undefined;
88
- return val !== null && val !== undefined;
89
- }
90
- case 'not_exists': {
91
- const val = condition.value ? this.resolve(condition.value.from, ctx) : undefined;
92
- return val === null || val === undefined;
93
- }
94
- case 'gte': {
95
- const left = Number(condition.left ? this.resolve(condition.left.from, ctx) : undefined);
96
- const right = Number(condition.right);
97
- return !isNaN(left) && !isNaN(right) && left >= right;
98
- }
99
- case 'lte': {
100
- const left = Number(condition.left ? this.resolve(condition.left.from, ctx) : undefined);
101
- const right = Number(condition.right);
102
- return !isNaN(left) && !isNaN(right) && left <= right;
103
- }
104
- case 'contains': {
105
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
106
- const right = condition.right;
107
- if (typeof left === 'string' && typeof right === 'string')
108
- return left.includes(right);
109
- if (Array.isArray(left))
110
- return left.includes(right);
111
- return false;
112
- }
113
- case 'starts_with': {
114
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
115
- const right = String(condition.right ?? '');
116
- return typeof left === 'string' && left.startsWith(right);
117
- }
118
- case 'ends_with': {
119
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
120
- const right = String(condition.right ?? '');
121
- return typeof left === 'string' && left.endsWith(right);
122
- }
123
- case 'in_list': {
124
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
125
- const list = condition.right;
126
- if (!Array.isArray(list))
127
- return false;
128
- return list.some((item) => String(item) === String(left));
129
- }
130
- case 'not_in_list': {
131
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
132
- const list = condition.right;
133
- if (!Array.isArray(list))
134
- return true;
135
- return !list.some((item) => String(item) === String(left));
136
- }
137
- case 'between': {
138
- const left = Number(condition.left ? this.resolve(condition.left.from, ctx) : undefined);
139
- const range = condition.right;
140
- if (!Array.isArray(range) || range.length < 2)
141
- return false;
142
- const min = Number(range[0]);
143
- const max = Number(range[1]);
144
- return !isNaN(left) && !isNaN(min) && !isNaN(max) && left >= min && left <= max;
145
- }
146
- case 'is_true': {
147
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
148
- return left === true || left === 'true';
149
- }
150
- case 'is_false': {
151
- const left = condition.left ? this.resolve(condition.left.from, ctx) : undefined;
152
- return left === false || left === 'false';
153
- }
154
- default:
155
- return false;
156
- }
157
- }
158
- // ─── Data resolution ──────────────────────────────────────────────────────
159
- resolve(from, ctx) {
160
- const dotIdx = from.indexOf('.');
161
- if (dotIdx === -1)
162
- return undefined;
163
- const source = from.substring(0, dotIdx);
164
- const key = from.substring(dotIdx + 1);
165
- switch (source) {
166
- case 'context': return this.getNested(ctx.context, key);
167
- case 'config': return this.getNested(ctx.config, key);
168
- case 'flags': return ctx.flags[key];
169
- default: return undefined;
170
- }
171
- }
172
- getNested(obj, key) {
173
- const parts = key.split('.');
174
- let current = obj;
175
- for (const part of parts) {
176
- if (current == null || typeof current !== 'object')
177
- return undefined;
178
- current = current[part];
179
- }
180
- return current;
181
- }
182
- setNested(obj, key, value) {
183
- const parts = key.split('.');
184
- let current = obj;
185
- for (let i = 0; i < parts.length - 1; i++) {
186
- if (!(parts[i] in current))
187
- current[parts[i]] = {};
188
- current = current[parts[i]];
189
- }
190
- current[parts[parts.length - 1]] = value;
191
- }
192
- }
193
- exports.KoolbaseLogicEngine = KoolbaseLogicEngine;
@@ -1,13 +0,0 @@
1
- import { KoolbaseConfig } from './types';
2
- export interface RegisterTokenOptions {
3
- token: string;
4
- platform: 'android' | 'ios';
5
- userId?: string;
6
- }
7
- export declare class KoolbaseMessaging {
8
- private config;
9
- private deviceId;
10
- constructor(config: KoolbaseConfig);
11
- setDeviceId(deviceId: string): void;
12
- registerToken(options: RegisterTokenOptions): Promise<boolean>;
13
- }
package/dist/messaging.js DELETED
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KoolbaseMessaging = void 0;
4
- // ─── KoolbaseMessaging ────────────────────────────────────────────────────────
5
- class KoolbaseMessaging {
6
- constructor(config) {
7
- this.deviceId = '';
8
- this.config = config;
9
- }
10
- setDeviceId(deviceId) {
11
- this.deviceId = deviceId;
12
- }
13
- // ─── Register token ───────────────────────────────────────────────────────
14
- async registerToken(options) {
15
- try {
16
- const response = await fetch(`${this.config.baseUrl}/v1/messaging/register`, {
17
- method: 'POST',
18
- headers: {
19
- 'Content-Type': 'application/json',
20
- 'x-api-key': this.config.publicKey,
21
- },
22
- body: JSON.stringify({
23
- device_id: this.deviceId,
24
- token: options.token,
25
- platform: options.platform,
26
- ...(options.userId && { user_id: options.userId }),
27
- }),
28
- });
29
- return response.ok;
30
- }
31
- catch {
32
- return false;
33
- }
34
- }
35
- }
36
- exports.KoolbaseMessaging = KoolbaseMessaging;
@@ -1,19 +0,0 @@
1
- import { KoolbaseConfig, RealtimeCallback } from './types';
2
- type TokenProvider = () => Promise<string | null>;
3
- export declare class KoolbaseRealtime {
4
- private config;
5
- private getToken;
6
- private ws;
7
- private projectId;
8
- private listeners;
9
- private reconnectTimer;
10
- private connecting;
11
- constructor(config: KoolbaseConfig, getToken: TokenProvider);
12
- subscribe(collection: string, callback: RealtimeCallback): () => void;
13
- private connect;
14
- private sendSubscribe;
15
- private sendUnsubscribe;
16
- private scheduleReconnect;
17
- disconnect(): void;
18
- }
19
- export {};
package/dist/realtime.js DELETED
@@ -1,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KoolbaseRealtime = void 0;
4
- const record_1 = require("./record");
5
- const EVENT_TYPE_MAP = {
6
- 'db.record.created': 'created',
7
- 'db.record.updated': 'updated',
8
- 'db.record.deleted': 'deleted',
9
- };
10
- function projectIdFromToken(token) {
11
- try {
12
- const part = token.split('.')[1];
13
- if (!part)
14
- return null;
15
- const b64 = part.replace(/-/g, '+').replace(/_/g, '/');
16
- const g = globalThis;
17
- let json;
18
- if (typeof g.atob === 'function') {
19
- const bin = g.atob(b64);
20
- json = decodeURIComponent(bin.split('').map((c) => '%' + c.charCodeAt(0).toString(16).padStart(2, '0')).join(''));
21
- }
22
- else if (g.Buffer) {
23
- json = g.Buffer.from(b64, 'base64').toString('utf8');
24
- }
25
- else {
26
- return null;
27
- }
28
- return JSON.parse(json).project_id ?? null;
29
- }
30
- catch {
31
- return null;
32
- }
33
- }
34
- class KoolbaseRealtime {
35
- constructor(config, getToken) {
36
- this.ws = null;
37
- this.projectId = null;
38
- this.listeners = new Map();
39
- this.reconnectTimer = null;
40
- this.connecting = false;
41
- this.config = config;
42
- this.getToken = getToken;
43
- }
44
- subscribe(collection, callback) {
45
- if (!this.listeners.has(collection))
46
- this.listeners.set(collection, []);
47
- this.listeners.get(collection).push(callback);
48
- if (this.ws && this.ws.readyState === WebSocket.OPEN) {
49
- this.sendSubscribe(collection);
50
- }
51
- else {
52
- void this.connect();
53
- }
54
- return () => {
55
- const callbacks = this.listeners.get(collection) ?? [];
56
- const i = callbacks.indexOf(callback);
57
- if (i > -1)
58
- callbacks.splice(i, 1);
59
- if (callbacks.length === 0) {
60
- this.listeners.delete(collection);
61
- this.sendUnsubscribe(collection);
62
- }
63
- };
64
- }
65
- async connect() {
66
- if (this.connecting)
67
- return;
68
- if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING))
69
- return;
70
- const token = await this.getToken();
71
- if (!token) {
72
- this.scheduleReconnect(); // sign-in may be in flight
73
- return;
74
- }
75
- this.projectId = projectIdFromToken(token);
76
- this.connecting = true;
77
- const wsUrl = this.config.baseUrl.replace('https://', 'wss://').replace('http://', 'ws://');
78
- const ws = new WebSocket(`${wsUrl}/v1/realtime/ws?token=${encodeURIComponent(token)}`);
79
- this.ws = ws;
80
- ws.onopen = () => {
81
- this.connecting = false;
82
- for (const collection of this.listeners.keys())
83
- this.sendSubscribe(collection); // (re)subscribe all
84
- };
85
- ws.onmessage = (event) => {
86
- let raw;
87
- try {
88
- raw = JSON.parse(event.data);
89
- }
90
- catch {
91
- return;
92
- }
93
- const mapped = EVENT_TYPE_MAP[raw?.type];
94
- if (!mapped)
95
- return; // ignore subscribed / unsubscribed / error / unknown
96
- const payload = raw.payload;
97
- if (!payload || !payload.collection)
98
- return;
99
- let msg;
100
- if (mapped === 'deleted') {
101
- msg = { type: 'deleted', collection: payload.collection, recordId: payload.record_id };
102
- }
103
- else if (payload.record) {
104
- msg = { type: mapped, collection: payload.collection, record: (0, record_1.recordFromWire)(payload.record) };
105
- }
106
- else {
107
- return;
108
- }
109
- (this.listeners.get(payload.collection) ?? []).forEach((cb) => cb(msg));
110
- };
111
- ws.onclose = () => {
112
- this.connecting = false;
113
- if (this.ws === ws)
114
- this.ws = null;
115
- this.scheduleReconnect();
116
- };
117
- ws.onerror = () => { };
118
- }
119
- sendSubscribe(collection) {
120
- if (!this.projectId || !this.ws || this.ws.readyState !== WebSocket.OPEN)
121
- return;
122
- this.ws.send(JSON.stringify({ action: 'subscribe', project_id: this.projectId, collection }));
123
- }
124
- sendUnsubscribe(collection) {
125
- if (!this.projectId || !this.ws || this.ws.readyState !== WebSocket.OPEN)
126
- return;
127
- this.ws.send(JSON.stringify({ action: 'unsubscribe', project_id: this.projectId, collection }));
128
- }
129
- scheduleReconnect() {
130
- if (this.listeners.size === 0 || this.reconnectTimer)
131
- return;
132
- this.reconnectTimer = setTimeout(() => {
133
- this.reconnectTimer = null;
134
- void this.connect();
135
- }, 3000);
136
- }
137
- disconnect() {
138
- if (this.reconnectTimer) {
139
- clearTimeout(this.reconnectTimer);
140
- this.reconnectTimer = null;
141
- }
142
- this.ws?.close();
143
- this.ws = null;
144
- this.projectId = null;
145
- this.listeners.clear();
146
- }
147
- }
148
- exports.KoolbaseRealtime = KoolbaseRealtime;
package/dist/record.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { KoolbaseRecord } from './types';
2
- export declare function recordFromWire(raw: Record<string, unknown>): KoolbaseRecord;
package/dist/record.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recordFromWire = recordFromWire;
4
- // Converts the flat public wire shape into a KoolbaseRecord.
5
- // Server sends: { $id, $createdAt, $updatedAt, $collection, $createdBy?, ...fields }
6
- function recordFromWire(raw) {
7
- const data = {};
8
- for (const key of Object.keys(raw)) {
9
- if (!key.startsWith('$'))
10
- data[key] = raw[key];
11
- }
12
- return {
13
- id: raw['$id'],
14
- collection: raw['$collection'],
15
- createdBy: raw['$createdBy'],
16
- data,
17
- createdAt: raw['$createdAt'],
18
- updatedAt: raw['$updatedAt'],
19
- };
20
- }
@@ -1,163 +0,0 @@
1
- /**
2
- * Base error type for all Koolbase storage errors. Catchable via
3
- * `instanceof KoolbaseStorageError` to handle any storage-related failure
4
- * generically; subclasses let you handle specific cases.
5
- */
6
- export declare class KoolbaseStorageError extends Error {
7
- code?: string;
8
- constructor(message: string, code?: string);
9
- }
10
- /**
11
- * Thrown when an upload is rejected because an object already exists at
12
- * the requested path — the server responds with 409 Conflict and code
13
- * `path_conflict`. Catch it to give the user an "overwrite this file?"
14
- * prompt, then retry the upload with `overwrite: true`.
15
- *
16
- * `path` is the colliding path the server rejected, surfaced from the
17
- * response body for diagnostics and UI.
18
- *
19
- * @example
20
- * try {
21
- * await Koolbase.storage.upload({
22
- * bucket: 'avatars',
23
- * path: 'me.png',
24
- * file: { uri, name, type: 'image/png' },
25
- * });
26
- * } catch (e) {
27
- * if (e instanceof KoolbaseStorageConflictError) {
28
- * const ok = await confirm(`${e.path} already exists. Overwrite?`);
29
- * if (ok) {
30
- * await Koolbase.storage.upload({
31
- * bucket: 'avatars',
32
- * path: 'me.png',
33
- * file: { uri, name, type: 'image/png' },
34
- * overwrite: true,
35
- * });
36
- * }
37
- * }
38
- * }
39
- */
40
- export declare class KoolbaseStorageConflictError extends KoolbaseStorageError {
41
- path?: string;
42
- constructor(message?: string, path?: string);
43
- }
44
- /**
45
- * Thrown when the requested bucket or object does not exist — the server
46
- * responds with 404. Also surfaced for cross-tenant access attempts
47
- * (Koolbase's 404-over-403 convention prevents enumeration in
48
- * multi-tenant contexts).
49
- */
50
- export declare class KoolbaseStorageNotFoundError extends KoolbaseStorageError {
51
- constructor(message?: string);
52
- }
53
- /**
54
- * Thrown when the request is rejected as invalid — the server responds
55
- * with 400 (e.g. a malformed path, missing field, invalid bucket name).
56
- */
57
- export declare class KoolbaseStorageValidationError extends KoolbaseStorageError {
58
- constructor(message?: string);
59
- }
60
- /**
61
- * Thrown when the caller is authenticated but not allowed to perform the
62
- * storage operation — the server responds with 403.
63
- */
64
- export declare class KoolbaseStoragePermissionError extends KoolbaseStorageError {
65
- constructor(message?: string);
66
- }
67
- /**
68
- * Thrown when an upload would push the bucket past its configured
69
- * `max_size_bytes` quota — the server responds with 409 Conflict and code
70
- * `quota_exceeded`. The server cleans up the underlying R2 object before
71
- * returning; nothing leaks. Catch this to surface a "bucket is full"
72
- * message or prompt the caller to delete older files. The per-bucket
73
- * quota is set at bucket creation time and is currently immutable.
74
- *
75
- * Distinct from {@link KoolbaseStorageConflictError} (which also uses
76
- * 409 but means "path collides"); branch on the error type via
77
- * `instanceof`, not on status.
78
- */
79
- export declare class KoolbaseStorageQuotaError extends KoolbaseStorageError {
80
- constructor(message?: string);
81
- }
82
- /**
83
- * Thrown when a single file exceeds the bucket's configured
84
- * `max_file_size_bytes` — the server responds with 413 Payload Too Large
85
- * and code `file_too_large`. The server cleans up the underlying R2
86
- * object before returning. The configured per-file limit lives on the
87
- * bucket record; check `Bucket.maxFileSizeBytes` to surface a clear
88
- * "files must be under X MB" message at the call site.
89
- */
90
- export declare class KoolbaseStorageFileTooLargeError extends KoolbaseStorageError {
91
- constructor(message?: string);
92
- }
93
- /**
94
- * Thrown when an upload's content-type isn't in the bucket's configured
95
- * `allowed_mime_types` allowlist — the server responds with 415
96
- * Unsupported Media Type and code `mime_not_allowed`. The check runs at
97
- * presign time, so no bytes are transferred before rejection.
98
- *
99
- * Allowlists support `type/*` wildcards (e.g. `image/*` matches every
100
- * image content-type). A bucket with no allowlist configured accepts
101
- * every type.
102
- */
103
- export declare class KoolbaseStorageMimeTypeError extends KoolbaseStorageError {
104
- constructor(message?: string);
105
- }
106
- /**
107
- * Thrown when an object metadata payload (either at upload-confirm time
108
- * or via `updateMetadata`) fails server-side validation — the server
109
- * responds with 400 and code `metadata_invalid`.
110
- *
111
- * The `detail` field carries the specific reason from the server — e.g.
112
- * `'key "foo bar": must match [a-z0-9_]+'`, `'exceeds 50 keys (got 53)'`,
113
- * or `'exceeds 8192 bytes total (sum of all key + value lengths)'`. The
114
- * detail names the failing key and rule so callers can fix the offending
115
- * entry without guessing what shape rule was violated.
116
- *
117
- * Validation rules (enforced server-side):
118
- * - At most 50 keys per object.
119
- * - At most 8KB total (sum of byte lengths across all keys + values).
120
- * - Keys: 1–64 chars, must match `[a-z0-9_]+`.
121
- * - Keys with a leading underscore are reserved for system use.
122
- * - Values: at most 1024 chars each.
123
- *
124
- * @example
125
- * try {
126
- * await Koolbase.storage.updateMetadata('photos', 'sunset.jpg', {
127
- * tag: 'sunset',
128
- * 'BAD KEY': 'oops',
129
- * });
130
- * } catch (e) {
131
- * if (e instanceof KoolbaseStorageMetadataInvalidError) {
132
- * console.warn('Metadata rejected:', e.detail);
133
- * // -> 'Metadata rejected: key "BAD KEY": must match [a-z0-9_]+'
134
- * }
135
- * }
136
- */
137
- export declare class KoolbaseStorageMetadataInvalidError extends KoolbaseStorageError {
138
- /**
139
- * The specific validation failure reported by the server. Names the
140
- * failing key (when applicable) and the rule that was violated.
141
- * Surface this directly to developer logs or user-facing UI.
142
- */
143
- detail?: string;
144
- constructor(message?: string, detail?: string);
145
- }
146
- /**
147
- * Maps a non-2xx storage-layer response to a typed
148
- * {@link KoolbaseStorageError}, preferring the server's stable `code` and
149
- * falling back to the HTTP status for older or uncoded responses. Always
150
- * returns an error to throw.
151
- *
152
- * Status-fallback note: HTTP 409 covers both path_conflict and
153
- * quota_exceeded. Without a `code` field, the mapper defaults 409 to
154
- * {@link KoolbaseStorageConflictError} since path collisions are the more
155
- * common case. Modern Koolbase servers always emit `code`, so this only
156
- * matters for very old API responses or non-Koolbase 409s.
157
- */
158
- export declare function koolbaseStorageError(status: number, body: any, fallbackMessage?: string): KoolbaseStorageError;
159
- /**
160
- * Convenience wrapper over {@link koolbaseStorageError} that decodes the
161
- * response body for you. Use at call sites that have the raw `Response`.
162
- */
163
- export declare function koolbaseStorageErrorFromResponse(res: Response, fallbackMessage?: string): Promise<KoolbaseStorageError>;