@techfinityedge/koolbase-react-native 1.6.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/README.md ADDED
@@ -0,0 +1,282 @@
1
+ # koolbase-react-native
2
+
3
+ [![npm](https://img.shields.io/npm/v/koolbase-react-native.svg)](https://www.npmjs.com/package/koolbase-react-native)
4
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ React Native SDK for [Koolbase](https://koolbase.com) — Backend as a Service built for mobile developers.
7
+
8
+ Auth, database, storage, realtime, functions, feature flags, remote config, version enforcement, code push, logic engine, analytics, and cloud messaging — one SDK, one `initialize()` call.
9
+
10
+ ---
11
+
12
+ ## Get started in 2 minutes
13
+
14
+ **1. Create a free account at [app.koolbase.com](https://app.koolbase.com)**
15
+
16
+ **2. Create a project and copy your public key from Environments**
17
+
18
+ **3. Add the SDK:**
19
+ ```bash
20
+ npm install koolbase-react-native
21
+ # or
22
+ yarn add koolbase-react-native
23
+ ```
24
+
25
+ **4. Initialize at app startup:**
26
+ ```typescript
27
+ import { Koolbase } from 'koolbase-react-native';
28
+
29
+ await Koolbase.initialize({
30
+ publicKey: 'pk_live_xxxx',
31
+ baseUrl: 'https://api.koolbase.com',
32
+ });
33
+ ```
34
+
35
+ That's it. Every feature below is now available via `Koolbase.*`.
36
+
37
+ ---
38
+
39
+ ## Authentication
40
+ ```typescript
41
+ // Register
42
+ await Koolbase.auth.register({ email: 'user@example.com', password: 'password' });
43
+
44
+ // Login
45
+ const session = await Koolbase.auth.login({ email: 'user@example.com', password: 'password' });
46
+
47
+ // Current user
48
+ const me = Koolbase.auth.currentUser;
49
+
50
+ // Logout
51
+ await Koolbase.auth.logout();
52
+
53
+ // Password reset
54
+ await Koolbase.auth.forgotPassword('user@example.com');
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Database
60
+ ```typescript
61
+ // Insert
62
+ await Koolbase.db.insert('posts', { title: 'Hello', published: true });
63
+
64
+ // Query
65
+ const { records } = await Koolbase.db.query('posts', {
66
+ filters: { published: true },
67
+ limit: 10,
68
+ orderBy: 'created_at',
69
+ orderDesc: true,
70
+ });
71
+
72
+ // Populate related records
73
+ const { records } = await Koolbase.db.query('posts', {
74
+ populate: ['author_id:users'],
75
+ });
76
+
77
+ // Update / Delete
78
+ await Koolbase.db.update('record-id', { title: 'Updated' });
79
+ await Koolbase.db.delete('record-id');
80
+ ```
81
+
82
+ ### Offline-first
83
+ ```typescript
84
+ const { records, isFromCache } = await Koolbase.db.query('posts', { limit: 20 });
85
+ if (isFromCache) console.log('Served from local cache');
86
+
87
+ await Koolbase.db.syncPendingWrites();
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Storage
93
+ ```typescript
94
+ const { url } = await Koolbase.storage.upload({
95
+ bucket: 'avatars',
96
+ path: `user-${userId}.jpg`,
97
+ file: { uri: imageUri, name: 'avatar.jpg', type: 'image/jpeg' },
98
+ });
99
+
100
+ const downloadUrl = await Koolbase.storage.getDownloadUrl('avatars', `user-${userId}.jpg`);
101
+ await Koolbase.storage.delete('avatars', `user-${userId}.jpg`);
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Realtime
107
+ ```typescript
108
+ const unsubscribe = Koolbase.realtime.subscribe('messages', (event) => {
109
+ if (event.type === 'created') setMessages(prev => [event.record, ...prev]);
110
+ });
111
+
112
+ // Cleanup
113
+ unsubscribe();
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Feature Flags & Remote Config
119
+ ```typescript
120
+ if (Koolbase.isEnabled('new_checkout')) { ... }
121
+
122
+ const timeout = Koolbase.configNumber('timeout_seconds', 30);
123
+ const apiUrl = Koolbase.configString('api_url', 'https://api.myapp.com');
124
+ const dark = Koolbase.configBool('force_dark_mode', false);
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Version Enforcement
130
+ ```typescript
131
+ const result = Koolbase.checkVersion('1.2.3');
132
+ if (result.status === 'force_update') {
133
+ // block and show update screen
134
+ }
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Code Push
140
+ ```typescript
141
+ await Koolbase.initialize({
142
+ publicKey: 'pk_live_xxxx',
143
+ baseUrl: 'https://api.koolbase.com',
144
+ codePushChannel: 'stable',
145
+ });
146
+
147
+ // Bundle values override Remote Config + Feature Flags transparently
148
+ const timeout = Koolbase.configNumber('api_timeout_ms', 3000);
149
+
150
+ // Directive handlers
151
+ Koolbase.codePush.onDirective('force_logout_all', (value) => {
152
+ if (value) Koolbase.auth.logout();
153
+ });
154
+ Koolbase.codePush.applyDirectives();
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Logic Engine
160
+ ```typescript
161
+ // Define flows in your bundle's flows.json
162
+ // Execute from anywhere in your app
163
+ const result = Koolbase.executeFlow('on_checkout_tap', { plan: user.plan });
164
+
165
+ if (result.hasEvent) {
166
+ switch (result.eventName) {
167
+ case 'show_upgrade': navigation.navigate('Upgrade'); break;
168
+ case 'go_checkout': navigation.navigate('Checkout'); break;
169
+ }
170
+ }
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Analytics
176
+ ```typescript
177
+ await Koolbase.initialize({
178
+ publicKey: 'pk_live_xxxx',
179
+ baseUrl: 'https://api.koolbase.com',
180
+ analyticsEnabled: true,
181
+ appVersion: '1.0.0',
182
+ });
183
+
184
+ // Custom events
185
+ Koolbase.analytics.track('purchase', { value: 1200, currency: 'GHS' });
186
+
187
+ // Screen views
188
+ Koolbase.analytics.screenView('checkout');
189
+
190
+ // User identity
191
+ Koolbase.analytics.identify(user.id);
192
+ Koolbase.analytics.setUserProperty('plan', 'pro');
193
+
194
+ // On logout
195
+ Koolbase.analytics.reset();
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Cloud Messaging
201
+ ```typescript
202
+ await Koolbase.initialize({
203
+ publicKey: 'pk_live_xxxx',
204
+ baseUrl: 'https://api.koolbase.com',
205
+ messagingEnabled: true,
206
+ });
207
+
208
+ // Register FCM token (after obtaining from @react-native-firebase/messaging)
209
+ const fcmToken = await messaging().getToken();
210
+ await Koolbase.messaging.registerToken({
211
+ token: fcmToken,
212
+ platform: 'android', // or 'ios'
213
+ });
214
+
215
+ // Send to a specific device
216
+ await Koolbase.messaging.send({
217
+ to: deviceToken,
218
+ title: 'Your order is ready',
219
+ body: 'Pick up at counter 3',
220
+ data: { order_id: '123' },
221
+ });
222
+ ```
223
+
224
+ ---
225
+
226
+ ## Logic Engine v2
227
+
228
+ ```typescript
229
+ const result = Koolbase.executeFlow('on_checkout_tap', {
230
+ plan: user.plan,
231
+ usage: user.usage,
232
+ });
233
+
234
+ if (result.hasEvent) {
235
+ switch (result.eventName) {
236
+ case 'show_upgrade': navigation.navigate('Upgrade'); break;
237
+ case 'go_checkout': navigation.navigate('Checkout'); break;
238
+ }
239
+ }
240
+ ```
241
+
242
+ **v2 operators:** `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains`, `starts_with`, `ends_with`, `in_list`, `not_in_list`, `between`, `is_true`, `is_false`, `exists`, `not_exists`, `and`, `or`
243
+
244
+ Full docs at [docs.koolbase.com/sdk/logic-engine](https://docs.koolbase.com/sdk/logic-engine).
245
+
246
+ ---
247
+
248
+ ## Sign in with Apple
249
+
250
+ ```typescript
251
+ import { KoolbaseAppleAuth } from 'koolbase-react-native';
252
+ import { appleAuth } from '@invertase/react-native-apple-authentication';
253
+
254
+ const session = await KoolbaseAppleAuth.signIn(async () => {
255
+ return await appleAuth.performRequest({
256
+ requestedOperation: appleAuth.Operation.LOGIN,
257
+ requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],
258
+ });
259
+ });
260
+ ```
261
+
262
+ Install `@invertase/react-native-apple-authentication` as a peer dependency. Full setup guide at [docs.koolbase.com/auth/oauth](https://docs.koolbase.com/auth/oauth).
263
+
264
+ ---
265
+
266
+ ## Documentation
267
+
268
+ Full documentation at [docs.koolbase.com](https://docs.koolbase.com)
269
+
270
+ ## Dashboard
271
+
272
+ Manage your projects at [app.koolbase.com](https://app.koolbase.com)
273
+
274
+ ## Support
275
+
276
+ - [GitHub Issues](https://github.com/kennedyowusu/koolbase-react-native/issues)
277
+ - [docs.koolbase.com](https://docs.koolbase.com)
278
+ - Email: hello@koolbase.com
279
+
280
+ ## License
281
+
282
+ MIT
@@ -0,0 +1,26 @@
1
+ import { KoolbaseConfig } from './types';
2
+ export declare class KoolbaseAnalytics {
3
+ private config;
4
+ private queue;
5
+ private deviceId;
6
+ private userId?;
7
+ private environmentId?;
8
+ private userProperties;
9
+ private sessionId;
10
+ private appVersion;
11
+ private flushTimer?;
12
+ private initialized;
13
+ constructor(config: KoolbaseConfig);
14
+ init(appVersion?: string): Promise<void>;
15
+ track(eventName: string, properties?: Record<string, unknown>): void;
16
+ screenView(screenName: string, properties?: Record<string, unknown>): void;
17
+ identify(userId: string): void;
18
+ setUserProperty(key: string, value: unknown): void;
19
+ setUserProperties(properties: Record<string, unknown>): void;
20
+ setEnvironment(environmentId: string): void;
21
+ reset(): void;
22
+ flush(): Promise<void>;
23
+ dispose(): Promise<void>;
24
+ private getOrCreateDeviceId;
25
+ private generateUUID;
26
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.KoolbaseAnalytics = void 0;
7
+ const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
8
+ const react_native_1 = require("react-native");
9
+ // ─── KoolbaseAnalytics ───────────────────────────────────────────────────────
10
+ const SDK_VERSION = '1.3.0';
11
+ const DEVICE_ID_KEY = 'koolbase:device_id';
12
+ const FLUSH_INTERVAL_MS = 30000;
13
+ const MAX_BATCH_SIZE = 20;
14
+ class KoolbaseAnalytics {
15
+ constructor(config) {
16
+ this.queue = [];
17
+ this.deviceId = '';
18
+ this.userProperties = {};
19
+ this.sessionId = '';
20
+ this.appVersion = '1.0.0';
21
+ this.initialized = false;
22
+ this.config = config;
23
+ }
24
+ // ─── Init ─────────────────────────────────────────────────────────────────
25
+ async init(appVersion) {
26
+ if (this.initialized)
27
+ return;
28
+ this.deviceId = await this.getOrCreateDeviceId();
29
+ this.sessionId = `${this.deviceId}-${Date.now()}`;
30
+ this.appVersion = appVersion ?? '1.0.0';
31
+ // Auto flush on app background
32
+ react_native_1.AppState.addEventListener('change', (state) => {
33
+ if (state === 'background' || state === 'inactive') {
34
+ this.flush();
35
+ }
36
+ });
37
+ // Periodic flush
38
+ this.flushTimer = setInterval(() => this.flush(), FLUSH_INTERVAL_MS);
39
+ // Auto track app_open
40
+ this.track('app_open');
41
+ this.initialized = true;
42
+ }
43
+ // ─── Public API ───────────────────────────────────────────────────────────
44
+ track(eventName, properties) {
45
+ const event = {
46
+ device_id: this.deviceId,
47
+ user_id: this.userId,
48
+ environment_id: this.environmentId,
49
+ event_name: eventName,
50
+ properties: properties ?? {},
51
+ user_properties: { ...this.userProperties },
52
+ platform: react_native_1.Platform.OS,
53
+ app_version: this.appVersion,
54
+ sdk_version: SDK_VERSION,
55
+ session_id: this.sessionId,
56
+ occurred_at: new Date().toISOString(),
57
+ };
58
+ this.queue.push(event);
59
+ if (this.queue.length >= MAX_BATCH_SIZE) {
60
+ this.flush();
61
+ }
62
+ }
63
+ screenView(screenName, properties) {
64
+ this.track('screen_view', {
65
+ screen_name: screenName,
66
+ ...properties,
67
+ });
68
+ }
69
+ identify(userId) {
70
+ this.userId = userId;
71
+ }
72
+ setUserProperty(key, value) {
73
+ this.userProperties[key] = value;
74
+ }
75
+ setUserProperties(properties) {
76
+ Object.assign(this.userProperties, properties);
77
+ }
78
+ setEnvironment(environmentId) {
79
+ this.environmentId = environmentId;
80
+ }
81
+ reset() {
82
+ this.userId = undefined;
83
+ this.userProperties = {};
84
+ }
85
+ // ─── Flush ────────────────────────────────────────────────────────────────
86
+ async flush() {
87
+ if (this.queue.length === 0)
88
+ return;
89
+ const batch = [...this.queue];
90
+ this.queue = [];
91
+ try {
92
+ const response = await fetch(`${this.config.baseUrl}/v1/analytics/events`, {
93
+ method: 'POST',
94
+ headers: {
95
+ 'Content-Type': 'application/json',
96
+ 'x-api-key': this.config.publicKey,
97
+ },
98
+ body: JSON.stringify({ events: batch }),
99
+ });
100
+ if (!response.ok) {
101
+ // Re-queue on failure
102
+ this.queue.unshift(...batch.slice(0, MAX_BATCH_SIZE - this.queue.length));
103
+ }
104
+ }
105
+ catch {
106
+ // Re-queue on network error
107
+ this.queue.unshift(...batch.slice(0, MAX_BATCH_SIZE - this.queue.length));
108
+ }
109
+ }
110
+ async dispose() {
111
+ if (this.flushTimer)
112
+ clearInterval(this.flushTimer);
113
+ this.track('session_end');
114
+ await this.flush();
115
+ }
116
+ // ─── Device ID ────────────────────────────────────────────────────────────
117
+ async getOrCreateDeviceId() {
118
+ try {
119
+ const existing = await async_storage_1.default.getItem(DEVICE_ID_KEY);
120
+ if (existing)
121
+ return existing;
122
+ const newId = this.generateUUID();
123
+ await async_storage_1.default.setItem(DEVICE_ID_KEY, newId);
124
+ return newId;
125
+ }
126
+ catch {
127
+ return this.generateUUID();
128
+ }
129
+ }
130
+ generateUUID() {
131
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
132
+ const r = (Math.random() * 16) | 0;
133
+ const v = c === 'x' ? r : (r & 0x3) | 0x8;
134
+ return v.toString(16);
135
+ });
136
+ }
137
+ }
138
+ exports.KoolbaseAnalytics = KoolbaseAnalytics;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * KoolbaseAppleAuth — Sign in with Apple for React Native
3
+ *
4
+ * Requires @invertase/react-native-apple-authentication
5
+ * Install: npm install @invertase/react-native-apple-authentication
6
+ *
7
+ * Usage:
8
+ * ```typescript
9
+ * import { KoolbaseAppleAuth } from 'koolbase-react-native';
10
+ * const session = await KoolbaseAppleAuth.signIn();
11
+ * ```
12
+ */
13
+ export declare class KoolbaseAppleAuth {
14
+ static signIn(getAppleCredential: () => Promise<{
15
+ identityToken: string | null;
16
+ email: string | null;
17
+ fullName?: {
18
+ givenName?: string | null;
19
+ familyName?: string | null;
20
+ } | null;
21
+ }>): Promise<Record<string, unknown> | null>;
22
+ }
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.KoolbaseAppleAuth = void 0;
37
+ /**
38
+ * KoolbaseAppleAuth — Sign in with Apple for React Native
39
+ *
40
+ * Requires @invertase/react-native-apple-authentication
41
+ * Install: npm install @invertase/react-native-apple-authentication
42
+ *
43
+ * Usage:
44
+ * ```typescript
45
+ * import { KoolbaseAppleAuth } from 'koolbase-react-native';
46
+ * const session = await KoolbaseAppleAuth.signIn();
47
+ * ```
48
+ */
49
+ class KoolbaseAppleAuth {
50
+ static async signIn(getAppleCredential) {
51
+ try {
52
+ const { Koolbase } = await Promise.resolve().then(() => __importStar(require('./index')));
53
+ const credential = await getAppleCredential();
54
+ if (!credential.identityToken) {
55
+ console.warn('[KoolbaseAppleAuth] No identity token returned');
56
+ return null;
57
+ }
58
+ const name = [credential.fullName?.givenName, credential.fullName?.familyName]
59
+ .filter(Boolean)
60
+ .join(' ');
61
+ return await Koolbase.auth.oauthLogin({
62
+ provider: 'apple',
63
+ token: credential.identityToken,
64
+ email: credential.email ?? '',
65
+ name,
66
+ });
67
+ }
68
+ catch (error) {
69
+ console.error('[KoolbaseAppleAuth] Sign in failed:', error);
70
+ return null;
71
+ }
72
+ }
73
+ }
74
+ exports.KoolbaseAppleAuth = KoolbaseAppleAuth;
package/dist/auth.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { KoolbaseConfig, KoolbaseSession, KoolbaseUser, LoginParams, RegisterParams } from './types';
2
+ export declare class KoolbaseAuth {
3
+ private config;
4
+ private session;
5
+ constructor(config: KoolbaseConfig);
6
+ private get headers();
7
+ private get authHeaders();
8
+ private request;
9
+ register(params: RegisterParams): Promise<KoolbaseUser>;
10
+ login(params: LoginParams): Promise<KoolbaseSession>;
11
+ logout(): Promise<void>;
12
+ forgotPassword(email: string): Promise<void>;
13
+ resetPassword(token: string, password: string): Promise<void>;
14
+ get currentUser(): KoolbaseUser | null;
15
+ get accessToken(): string | null;
16
+ setSession(session: KoolbaseSession | null): void;
17
+ oauthLogin({ provider, token, email, name, avatarUrl, }: {
18
+ provider: string;
19
+ token: string;
20
+ email?: string;
21
+ name?: string;
22
+ avatarUrl?: string;
23
+ }): Promise<Record<string, unknown> | null>;
24
+ }
package/dist/auth.js ADDED
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KoolbaseAuth = void 0;
4
+ class KoolbaseAuth {
5
+ constructor(config) {
6
+ this.session = null;
7
+ this.config = config;
8
+ }
9
+ get headers() {
10
+ return { 'Content-Type': 'application/json' };
11
+ }
12
+ get authHeaders() {
13
+ return {
14
+ 'Content-Type': 'application/json',
15
+ ...(this.session
16
+ ? { Authorization: `Bearer ${this.session.accessToken}` }
17
+ : {}),
18
+ };
19
+ }
20
+ async request(method, path, body, auth = false) {
21
+ const res = await fetch(`${this.config.baseUrl}${path}`, {
22
+ method,
23
+ headers: auth ? this.authHeaders : this.headers,
24
+ body: body ? JSON.stringify(body) : undefined,
25
+ });
26
+ const data = await res.json();
27
+ if (!res.ok) {
28
+ throw new Error(data.error ?? `Request failed: ${res.status}`);
29
+ }
30
+ return data;
31
+ }
32
+ async register(params) {
33
+ const data = await this.request('POST', '/v1/sdk/auth/register', params);
34
+ return data.user;
35
+ }
36
+ async login(params) {
37
+ const data = await this.request('POST', '/v1/sdk/auth/login', params);
38
+ this.session = data;
39
+ return data;
40
+ }
41
+ async logout() {
42
+ if (!this.session)
43
+ return;
44
+ try {
45
+ await this.request('POST', '/v1/sdk/auth/logout', {}, true);
46
+ }
47
+ finally {
48
+ this.session = null;
49
+ }
50
+ }
51
+ async forgotPassword(email) {
52
+ await this.request('POST', '/v1/sdk/auth/forgot-password', { email });
53
+ }
54
+ async resetPassword(token, password) {
55
+ await this.request('POST', '/v1/sdk/auth/reset-password', {
56
+ token,
57
+ password,
58
+ });
59
+ }
60
+ get currentUser() {
61
+ return this.session?.user ?? null;
62
+ }
63
+ get accessToken() {
64
+ return this.session?.accessToken ?? null;
65
+ }
66
+ setSession(session) {
67
+ this.session = session;
68
+ }
69
+ async oauthLogin({ provider, token, email = '', name = '', avatarUrl = '', }) {
70
+ try {
71
+ const response = await fetch(`${this.config.baseUrl}/v1/auth/oauth`, {
72
+ method: 'POST',
73
+ headers: { 'Content-Type': 'application/json' },
74
+ body: JSON.stringify({ provider, token, email, name, avatar_url: avatarUrl }),
75
+ });
76
+ if (response.ok)
77
+ return response.json();
78
+ return null;
79
+ }
80
+ catch {
81
+ return null;
82
+ }
83
+ }
84
+ }
85
+ exports.KoolbaseAuth = KoolbaseAuth;
@@ -0,0 +1,11 @@
1
+ import { KoolbaseRecord, PendingWrite, QueryResult } from './types';
2
+ export declare function hashQuery(collection: string, options: Record<string, unknown>): string;
3
+ export declare function getCached(userId: string, collection: string, queryHash: string): Promise<QueryResult | null>;
4
+ export declare function setCached(userId: string, collection: string, queryHash: string, result: QueryResult): Promise<void>;
5
+ export declare function invalidateCache(userId: string, collection: string): Promise<void>;
6
+ export declare function clearUserCache(userId: string): Promise<void>;
7
+ export declare function getWriteQueue(userId: string): Promise<PendingWrite[]>;
8
+ export declare function addToWriteQueue(userId: string, write: Omit<PendingWrite, 'retries' | 'createdAt'>): Promise<void>;
9
+ export declare function removeFromWriteQueue(userId: string, writeId: string): Promise<void>;
10
+ export declare function incrementWriteRetry(userId: string, writeId: string): Promise<void>;
11
+ export declare function optimisticallyInsert(userId: string, collection: string, record: KoolbaseRecord): Promise<void>;