@techfinityedge/koolbase-react-native 1.7.0 → 1.8.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.
- package/dist/functions.d.ts +2 -1
- package/dist/functions.js +11 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/functions.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { KoolbaseConfig, FunctionInvokeResult, DeployOptions, DeployResult } from './types';
|
|
2
2
|
export declare class KoolbaseFunctions {
|
|
3
3
|
private config;
|
|
4
|
-
|
|
4
|
+
private getUserAccessToken?;
|
|
5
|
+
constructor(config: KoolbaseConfig, getUserAccessToken?: () => string | null);
|
|
5
6
|
deploy(options: DeployOptions): Promise<DeployResult>;
|
|
6
7
|
invoke(name: string, body?: Record<string, unknown>): Promise<FunctionInvokeResult>;
|
|
7
8
|
}
|
package/dist/functions.js
CHANGED
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.KoolbaseFunctions = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
class KoolbaseFunctions {
|
|
6
|
-
constructor(config) {
|
|
6
|
+
constructor(config, getUserAccessToken) {
|
|
7
7
|
this.config = config;
|
|
8
|
+
this.getUserAccessToken = getUserAccessToken;
|
|
8
9
|
}
|
|
9
10
|
// ─── Deploy ────────────────────────────────────────────────────────────────
|
|
10
11
|
async deploy(options) {
|
|
@@ -40,12 +41,17 @@ class KoolbaseFunctions {
|
|
|
40
41
|
}
|
|
41
42
|
// ─── Invoke ────────────────────────────────────────────────────────────────
|
|
42
43
|
async invoke(name, body) {
|
|
44
|
+
const headers = {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
'x-api-key': this.config.publicKey,
|
|
47
|
+
};
|
|
48
|
+
const userToken = this.getUserAccessToken?.();
|
|
49
|
+
if (userToken) {
|
|
50
|
+
headers['Authorization'] = `Bearer ${userToken}`;
|
|
51
|
+
}
|
|
43
52
|
const res = await fetch(`${this.config.baseUrl}/v1/sdk/functions/${name}`, {
|
|
44
53
|
method: 'POST',
|
|
45
|
-
headers
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
'x-api-key': this.config.publicKey,
|
|
48
|
-
},
|
|
54
|
+
headers,
|
|
49
55
|
body: JSON.stringify({ body: body ?? {} }),
|
|
50
56
|
});
|
|
51
57
|
const data = await res.json().catch(() => null);
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ exports.Koolbase = {
|
|
|
69
69
|
_db = new database_1.KoolbaseDatabase(config, () => _auth?.currentUser?.id ?? null);
|
|
70
70
|
_storage = new storage_1.KoolbaseStorage(config, () => _auth?.accessToken ?? null);
|
|
71
71
|
_realtime = new realtime_1.KoolbaseRealtime(config);
|
|
72
|
-
_functions = new functions_1.KoolbaseFunctions(config);
|
|
72
|
+
_functions = new functions_1.KoolbaseFunctions(config, () => _auth?.accessToken ?? null);
|
|
73
73
|
_flags = new flags_1.KoolbaseFlags(config, 'rn-device');
|
|
74
74
|
_codePush = new code_push_1.KoolbaseCodePush(config, config.codePushChannel ?? 'stable');
|
|
75
75
|
// Initialize code push — loads cached bundle then checks in background
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techfinityedge/koolbase-react-native",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
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",
|