@base44-preview/sdk 0.8.20-pr.141.3b955f9 → 0.8.20-pr.141.70f5f91
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/client.js
CHANGED
|
@@ -118,15 +118,11 @@ export function createClient(config) {
|
|
|
118
118
|
auth: userAuthModule,
|
|
119
119
|
functions: createFunctionsModule(functionsAxiosClient, appId, {
|
|
120
120
|
getAuthHeaders: () => {
|
|
121
|
-
var _a, _b;
|
|
122
121
|
const headers = {};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
headers[key] = value;
|
|
128
|
-
}
|
|
129
|
-
});
|
|
122
|
+
// Get current token from storage or initial config
|
|
123
|
+
const currentToken = token || getAccessToken();
|
|
124
|
+
if (currentToken) {
|
|
125
|
+
headers["Authorization"] = `Bearer ${currentToken}`;
|
|
130
126
|
}
|
|
131
127
|
return headers;
|
|
132
128
|
},
|
|
@@ -165,15 +161,10 @@ export function createClient(config) {
|
|
|
165
161
|
connectors: createConnectorsModule(serviceRoleAxiosClient, appId),
|
|
166
162
|
functions: createFunctionsModule(serviceRoleFunctionsAxiosClient, appId, {
|
|
167
163
|
getAuthHeaders: () => {
|
|
168
|
-
var _a, _b;
|
|
169
164
|
const headers = {};
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
if (typeof value === 'string') {
|
|
174
|
-
headers[key] = value;
|
|
175
|
-
}
|
|
176
|
-
});
|
|
165
|
+
// Use service token for authorization
|
|
166
|
+
if (serviceToken) {
|
|
167
|
+
headers["Authorization"] = `Bearer ${serviceToken}`;
|
|
177
168
|
}
|
|
178
169
|
return headers;
|
|
179
170
|
},
|
|
@@ -63,10 +63,10 @@ export function createFunctionsModule(axios, appId, config) {
|
|
|
63
63
|
}
|
|
64
64
|
return axios.post(`/apps/${appId}/functions/${functionName}`, formData || data, { headers: { "Content-Type": contentType } });
|
|
65
65
|
},
|
|
66
|
-
// Fetch a backend function endpoint directly
|
|
66
|
+
// Fetch a backend function endpoint directly.
|
|
67
67
|
async fetch(path, init = {}) {
|
|
68
68
|
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
69
|
-
const primaryPath = `/
|
|
69
|
+
const primaryPath = `/functions${normalizedPath}`;
|
|
70
70
|
const headers = toHeaders(init.headers);
|
|
71
71
|
const requestInit = {
|
|
72
72
|
...init,
|
|
@@ -77,8 +77,13 @@ export interface FunctionsModule {
|
|
|
77
77
|
/**
|
|
78
78
|
* Performs a direct HTTP request to a backend function path and returns the native `Response`.
|
|
79
79
|
*
|
|
80
|
-
* Use this when you need
|
|
81
|
-
*
|
|
80
|
+
* Use this method when you need low-level control over the request/response that the higher-level
|
|
81
|
+
* `invoke()` abstraction doesn't provide, such as:
|
|
82
|
+
* - Streaming responses (SSE, chunked text, NDJSON)
|
|
83
|
+
* - Custom HTTP methods (PUT, PATCH, DELETE, etc.)
|
|
84
|
+
* - Custom headers or request configuration
|
|
85
|
+
* - Access to raw response metadata (status, headers)
|
|
86
|
+
* - Direct control over request/response bodies
|
|
82
87
|
*
|
|
83
88
|
* Requests are sent to `/api/functions/<path>`.
|
|
84
89
|
*
|