tevrocsdk 0.1.82 → 0.1.83
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/package.json +6 -2
- package/tevroc-sdk.cjs.js +163 -50
- package/tevroc-sdk.cjs.js.map +2 -2
- package/tevroc-sdk.esm.js +163 -50
- package/tevroc-sdk.esm.js.map +2 -2
package/tevroc-sdk.esm.js
CHANGED
|
@@ -42147,15 +42147,15 @@ async function downloadUrlToBase64(url) {
|
|
|
42147
42147
|
if (!url) return null;
|
|
42148
42148
|
if (!isNative) return null;
|
|
42149
42149
|
try {
|
|
42150
|
-
|
|
42150
|
+
debugLog(`[tevrocsdk][fileoffline] downloadUrlToBase64 fetching`, url);
|
|
42151
42151
|
const res = await fetch(url, { cache: "no-store" });
|
|
42152
42152
|
if (!res.ok) return null;
|
|
42153
42153
|
const b2 = await res.blob();
|
|
42154
42154
|
const base64 = await blobToBase642(b2).catch(() => null);
|
|
42155
|
-
|
|
42155
|
+
debugLog(`[tevrocsdk][fileoffline] downloadUrlToBase64 fetched -> base64 length`, base64 ? base64.length : 0);
|
|
42156
42156
|
return base64;
|
|
42157
42157
|
} catch (e2) {
|
|
42158
|
-
|
|
42158
|
+
debugWarn(`[tevrocsdk][fileoffline] downloadUrlToBase64 failed`, e2);
|
|
42159
42159
|
return null;
|
|
42160
42160
|
}
|
|
42161
42161
|
}
|
|
@@ -42173,34 +42173,34 @@ function deriveKeyFromUrl(url) {
|
|
|
42173
42173
|
async function persistFileToNative(client, key, base64, contentType) {
|
|
42174
42174
|
try {
|
|
42175
42175
|
if (!isNative) return false;
|
|
42176
|
-
|
|
42176
|
+
debugLog("[tevrocsdk][fileoffline] persistFileToNative", { key, contentType, hasBase64: !!base64 });
|
|
42177
42177
|
if (!client?.native?.store || !base64) {
|
|
42178
|
-
|
|
42178
|
+
debugWarn("[tevrocsdk][fileoffline] persistFileToNative skipped - missing native.store or base64");
|
|
42179
42179
|
return false;
|
|
42180
42180
|
}
|
|
42181
42181
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
42182
42182
|
await client.native.store.set(`downloaded_files/${key}`, { data: base64, contentType: contentType || "application/octet-stream", key, updatedAt: now });
|
|
42183
|
-
|
|
42183
|
+
debugLog("[tevrocsdk][fileoffline] persistFileToNative stored", { key, updatedAt: now });
|
|
42184
42184
|
return true;
|
|
42185
42185
|
} catch (e2) {
|
|
42186
|
-
|
|
42186
|
+
debugWarn("[tevrocsdk][fileoffline] persistFileToNative error", e2);
|
|
42187
42187
|
return false;
|
|
42188
42188
|
}
|
|
42189
42189
|
}
|
|
42190
42190
|
async function walkAndPersistFiles(client, obj) {
|
|
42191
42191
|
if (!obj || typeof obj !== "object") return;
|
|
42192
42192
|
if (!isNative || !client?.native?.store) return;
|
|
42193
|
-
|
|
42193
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles start");
|
|
42194
42194
|
for (const k2 of Object.keys(obj)) {
|
|
42195
42195
|
const v3 = obj[k2];
|
|
42196
42196
|
if (typeof v3 === "string") {
|
|
42197
42197
|
if (isDataUrl(v3)) {
|
|
42198
|
-
|
|
42198
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles found data URL at key", k2);
|
|
42199
42199
|
const base64 = extractBase64FromDataUrl(v3);
|
|
42200
42200
|
const key = deriveKeyFromUrl(k2) || `inline_${Date.now()}`;
|
|
42201
42201
|
await persistFileToNative(client, key, base64, (v3.match(/^data:([^;]+);/) || [])[1] || "application/octet-stream");
|
|
42202
42202
|
} else if (/^https?:\/\//.test(v3) || v3.startsWith("filebase://")) {
|
|
42203
|
-
|
|
42203
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles found URL at key", k2, v3);
|
|
42204
42204
|
const url = v3.startsWith("filebase://") ? v3.replace(/^filebase:\/\//, "") : v3;
|
|
42205
42205
|
const base64 = await downloadUrlToBase64(v3).catch(() => null);
|
|
42206
42206
|
if (base64) {
|
|
@@ -42208,16 +42208,16 @@ async function walkAndPersistFiles(client, obj) {
|
|
|
42208
42208
|
await persistFileToNative(client, key, base64, "application/octet-stream");
|
|
42209
42209
|
}
|
|
42210
42210
|
} else if (isLikelyBase64(v3)) {
|
|
42211
|
-
|
|
42211
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles found inline base64 at key", k2);
|
|
42212
42212
|
const key = deriveKeyFromUrl(k2) || `inline_${Date.now()}`;
|
|
42213
42213
|
await persistFileToNative(client, key, v3, "application/octet-stream");
|
|
42214
42214
|
}
|
|
42215
42215
|
} else if (v3 && typeof v3 === "object") {
|
|
42216
|
-
|
|
42216
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles recursing into", k2);
|
|
42217
42217
|
await walkAndPersistFiles(client, v3);
|
|
42218
42218
|
}
|
|
42219
42219
|
}
|
|
42220
|
-
|
|
42220
|
+
debugLog("[tevrocsdk][fileoffline] walkAndPersistFiles end");
|
|
42221
42221
|
}
|
|
42222
42222
|
function createOfflineManager(client) {
|
|
42223
42223
|
const store = createNativeStore(client.appId);
|
|
@@ -42729,6 +42729,7 @@ var TevrocClient = class {
|
|
|
42729
42729
|
this.baseUrl = normalizeBaseUrl(baseUrl);
|
|
42730
42730
|
this.serviceUrl = normalizeBaseUrl(serviceUrl);
|
|
42731
42731
|
this.vpsUrl = normalizeBaseUrl(vpsUrl);
|
|
42732
|
+
this.vpsConfig = { ...options.vpsConfig || options.config || {} };
|
|
42732
42733
|
this.appId = options.appId;
|
|
42733
42734
|
this.appName = options.appName;
|
|
42734
42735
|
this.payAccount = options.payAccount ?? "default";
|
|
@@ -42737,11 +42738,14 @@ var TevrocClient = class {
|
|
|
42737
42738
|
throw new TypeError("No fetch implementation available");
|
|
42738
42739
|
}
|
|
42739
42740
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
42741
|
+
this.axios = options.axios;
|
|
42740
42742
|
this.defaultHeaders = normalizeHeaders(options.headers);
|
|
42741
42743
|
this.token = options.token ?? null;
|
|
42742
42744
|
this.debug = options.debug ?? false;
|
|
42743
42745
|
setSdkDebug(this.debug);
|
|
42744
42746
|
this.auth = createAuthApi(this);
|
|
42747
|
+
this.vps = createVpsApi(this);
|
|
42748
|
+
this.database = this.vps.database;
|
|
42745
42749
|
this.entities = createEntityRegistry(this);
|
|
42746
42750
|
this.functions = createFunctionRegistry(this);
|
|
42747
42751
|
this.integrations = createIntegrationApi(this);
|
|
@@ -42798,7 +42802,15 @@ var TevrocClient = class {
|
|
|
42798
42802
|
}
|
|
42799
42803
|
clearToken() {
|
|
42800
42804
|
this.token = null;
|
|
42801
|
-
safeLocalStorage()
|
|
42805
|
+
const storage = safeLocalStorage();
|
|
42806
|
+
[
|
|
42807
|
+
"tevroc_access_token",
|
|
42808
|
+
"base44_access_token",
|
|
42809
|
+
"native_access_token",
|
|
42810
|
+
"token",
|
|
42811
|
+
"idToken",
|
|
42812
|
+
"user"
|
|
42813
|
+
].forEach((key) => storage?.removeItem(key));
|
|
42802
42814
|
return this;
|
|
42803
42815
|
}
|
|
42804
42816
|
setDebug(enabled) {
|
|
@@ -42810,7 +42822,8 @@ var TevrocClient = class {
|
|
|
42810
42822
|
const method = (options.method ?? "GET").toUpperCase();
|
|
42811
42823
|
const headers = new Headers(this.defaultHeaders);
|
|
42812
42824
|
const query = options.query ? toSearchParams(options.query) : "";
|
|
42813
|
-
const
|
|
42825
|
+
const requestBaseUrl = options.baseUrl ?? this.baseUrl;
|
|
42826
|
+
const url = `${requestBaseUrl}${path.startsWith("/") ? path : `/${path}`}${query}`;
|
|
42814
42827
|
const controller = new AbortController();
|
|
42815
42828
|
const timeoutMsActual = options.timeoutMs || this.timeoutMs || 2500;
|
|
42816
42829
|
let timeout = null;
|
|
@@ -42851,13 +42864,23 @@ var TevrocClient = class {
|
|
|
42851
42864
|
debugWarn2(this, "[tevrocsdk] pending sync failed", err2);
|
|
42852
42865
|
}
|
|
42853
42866
|
}
|
|
42854
|
-
let
|
|
42855
|
-
|
|
42856
|
-
|
|
42857
|
-
|
|
42858
|
-
|
|
42859
|
-
|
|
42860
|
-
|
|
42867
|
+
let requestPromise;
|
|
42868
|
+
if (this.axios?.request) {
|
|
42869
|
+
requestPromise = this.axios.request({
|
|
42870
|
+
url,
|
|
42871
|
+
method,
|
|
42872
|
+
headers: Object.fromEntries(headers.entries()),
|
|
42873
|
+
data: body,
|
|
42874
|
+
signal: options.signal ?? controller.signal
|
|
42875
|
+
}).then((response) => parseAxiosResponse(response, options.parseAs));
|
|
42876
|
+
} else {
|
|
42877
|
+
requestPromise = this.fetch(url, {
|
|
42878
|
+
method,
|
|
42879
|
+
headers,
|
|
42880
|
+
body,
|
|
42881
|
+
signal: options.signal ?? controller.signal
|
|
42882
|
+
}).then((response) => parseResponse(response, options.parseAs));
|
|
42883
|
+
}
|
|
42861
42884
|
const timeoutPromise = new Promise((_3, reject) => {
|
|
42862
42885
|
timeout = setTimeout(() => {
|
|
42863
42886
|
try {
|
|
@@ -42867,8 +42890,7 @@ var TevrocClient = class {
|
|
|
42867
42890
|
reject(new TevrocError("Request timed out", { code: "timeout" }));
|
|
42868
42891
|
}, timeoutMsActual);
|
|
42869
42892
|
});
|
|
42870
|
-
|
|
42871
|
-
let ret = await parseResponse(response, options.parseAs);
|
|
42893
|
+
let ret = await Promise.race([requestPromise, timeoutPromise]);
|
|
42872
42894
|
debugLog2(this, "Response from request:", ret);
|
|
42873
42895
|
return ret;
|
|
42874
42896
|
} catch (error) {
|
|
@@ -42881,6 +42903,67 @@ var TevrocClient = class {
|
|
|
42881
42903
|
}
|
|
42882
42904
|
}
|
|
42883
42905
|
};
|
|
42906
|
+
function createVpsApi(client) {
|
|
42907
|
+
const request = (path, options = {}) => client.request(path, { ...options, baseUrl: client.vpsUrl });
|
|
42908
|
+
const withSession = (session, query = {}) => ({
|
|
42909
|
+
...query,
|
|
42910
|
+
session: session ?? client.vpsConfig.session
|
|
42911
|
+
});
|
|
42912
|
+
const encodeSql = (sql) => {
|
|
42913
|
+
if (typeof sql !== "string" || !sql.trim()) throw new TypeError("sql must be a non-empty string");
|
|
42914
|
+
if (typeof btoa === "function") return btoa(unescape(encodeURIComponent(sql)));
|
|
42915
|
+
return Buffer.from(sql, "utf8").toString("base64");
|
|
42916
|
+
};
|
|
42917
|
+
const database = {
|
|
42918
|
+
dialect: () => request("/database/sql", { auth: false }),
|
|
42919
|
+
tables: (options = {}) => request("/database/tables", { query: withSession(options.session, options), auth: false }),
|
|
42920
|
+
table: (table, options = {}) => request("/database/table", {
|
|
42921
|
+
query: withSession(options.session, { ...options, table }),
|
|
42922
|
+
auth: false
|
|
42923
|
+
}),
|
|
42924
|
+
exec: (sql, options = {}) => request("/database/query/exec", {
|
|
42925
|
+
query: withSession(options.session, { ...options, query: encodeSql(sql) }),
|
|
42926
|
+
auth: false
|
|
42927
|
+
}),
|
|
42928
|
+
query: (sql, options = {}) => database.exec(sql, options)
|
|
42929
|
+
};
|
|
42930
|
+
const auth = {
|
|
42931
|
+
login: async (email, password, options = {}) => {
|
|
42932
|
+
const result = await request("/login", { query: { ...options, email, password }, auth: false });
|
|
42933
|
+
if (result?.session) client.setToken(result.session);
|
|
42934
|
+
return result;
|
|
42935
|
+
},
|
|
42936
|
+
verifyOtp: async (email, otp, options = {}) => {
|
|
42937
|
+
const result = await request("/auth-otp", { query: { ...options, email, otp }, auth: false });
|
|
42938
|
+
if (result?.session) client.setToken(result.session);
|
|
42939
|
+
return result;
|
|
42940
|
+
},
|
|
42941
|
+
register: (input, options = {}) => request(options.path || "/auth/register", { method: "POST", body: input, auth: false }),
|
|
42942
|
+
resetPassword: (input, options = {}) => request(options.path || "/auth/reset-password", { method: "POST", body: input, auth: false }),
|
|
42943
|
+
changePassword: (input, options = {}) => request(options.path || "/auth/change-password", { method: "POST", body: input }),
|
|
42944
|
+
session: (session = client.token, options = {}) => request("/session", { query: withSession(session, options), auth: false }),
|
|
42945
|
+
userType: (session = client.token, options = {}) => request("/get-usertype", { query: withSession(session, options), auth: false }),
|
|
42946
|
+
user: (session = client.token, options = {}) => request("/get-user", { query: withSession(session, options), auth: false }),
|
|
42947
|
+
hasOnboarded: (session = client.token, options = {}) => request("/has-onboarded", { query: withSession(session, options), auth: false }),
|
|
42948
|
+
hasVerified: (session = client.token, options = {}) => request("/has-verified", { query: withSession(session, options), auth: false }),
|
|
42949
|
+
updateProfile: (session, data, options = {}) => request("/update-profile", { query: withSession(session, { ...options, jsonObject: JSON.stringify(data) }), auth: false }),
|
|
42950
|
+
updateOnboarding: (session, data, options = {}) => request("/update-onboarding", { query: withSession(session, { ...options, jsonObject: JSON.stringify(data) }), auth: false }),
|
|
42951
|
+
logout: () => {
|
|
42952
|
+
client.clearToken();
|
|
42953
|
+
return Promise.resolve({ ok: true });
|
|
42954
|
+
}
|
|
42955
|
+
};
|
|
42956
|
+
return {
|
|
42957
|
+
request,
|
|
42958
|
+
auth,
|
|
42959
|
+
database,
|
|
42960
|
+
environment: () => request("/api/environment", { auth: false }),
|
|
42961
|
+
platform: () => request("/platform", { auth: false }),
|
|
42962
|
+
notifications: (options = {}) => request("/api/notifications", { query: options, auth: false }),
|
|
42963
|
+
accountContext: (session = client.token, options = {}) => request("/api/mobile/account-context", { query: withSession(session, options), auth: false }),
|
|
42964
|
+
avatarUrl: (options = {}) => `${client.vpsUrl}/api/avatar${toSearchParams(options)}`
|
|
42965
|
+
};
|
|
42966
|
+
}
|
|
42884
42967
|
function createShiplogicApi(client) {
|
|
42885
42968
|
return {
|
|
42886
42969
|
getRates: (payload = {}) => client.request("/shiplogic/rates", { method: "POST", body: payload }),
|
|
@@ -43075,7 +43158,7 @@ function createAuthApi(client) {
|
|
|
43075
43158
|
// base44
|
|
43076
43159
|
loginWithProvider: async (provider, redirectTo, setToken = async () => {
|
|
43077
43160
|
}) => {
|
|
43078
|
-
|
|
43161
|
+
debugLog2(client, "loginWithProvider called", { provider, redirectTo });
|
|
43079
43162
|
if (provider === "google") {
|
|
43080
43163
|
const { createGoogleLogin: createGoogleLogin2, subscribeGoogleLogin: subscribeGoogleLogin2 } = await getGoogleModule();
|
|
43081
43164
|
debugLog2(client, {
|
|
@@ -43083,11 +43166,6 @@ function createAuthApi(client) {
|
|
|
43083
43166
|
appId: client.appId,
|
|
43084
43167
|
appName: client.appName
|
|
43085
43168
|
});
|
|
43086
|
-
await createGoogleLogin2({
|
|
43087
|
-
serviceUrl: client.serviceUrl,
|
|
43088
|
-
appId: client.appId,
|
|
43089
|
-
appName: client.appName
|
|
43090
|
-
});
|
|
43091
43169
|
if (redirectTo) {
|
|
43092
43170
|
const unsub = subscribeGoogleLogin2(async (user, err2) => {
|
|
43093
43171
|
debugLog2(client, "Google callback:", user, err2);
|
|
@@ -43103,6 +43181,22 @@ function createAuthApi(client) {
|
|
|
43103
43181
|
debugLog2(client, "Redirecting to:", redirectTo);
|
|
43104
43182
|
window.location.href = redirectTo;
|
|
43105
43183
|
});
|
|
43184
|
+
try {
|
|
43185
|
+
await createGoogleLogin2({
|
|
43186
|
+
serviceUrl: client.serviceUrl,
|
|
43187
|
+
appId: client.appId,
|
|
43188
|
+
appName: client.appName
|
|
43189
|
+
});
|
|
43190
|
+
} catch (error) {
|
|
43191
|
+
unsub();
|
|
43192
|
+
throw error;
|
|
43193
|
+
}
|
|
43194
|
+
} else {
|
|
43195
|
+
await createGoogleLogin2({
|
|
43196
|
+
serviceUrl: client.serviceUrl,
|
|
43197
|
+
appId: client.appId,
|
|
43198
|
+
appName: client.appName
|
|
43199
|
+
});
|
|
43106
43200
|
}
|
|
43107
43201
|
}
|
|
43108
43202
|
if (provider === "facebook") {
|
|
@@ -43234,9 +43328,11 @@ function createAuthApi(client) {
|
|
|
43234
43328
|
return result;
|
|
43235
43329
|
},
|
|
43236
43330
|
async logout() {
|
|
43237
|
-
|
|
43238
|
-
|
|
43239
|
-
|
|
43331
|
+
try {
|
|
43332
|
+
return await client.request("/auth/logout", { method: "POST", body: buildAuthPayload({}, client) });
|
|
43333
|
+
} finally {
|
|
43334
|
+
client.clearToken();
|
|
43335
|
+
}
|
|
43240
43336
|
},
|
|
43241
43337
|
inviteUser: (input) => client.request("/users/invite", { method: "POST", body: buildAuthPayload(input, client) }),
|
|
43242
43338
|
acceptInvite: (input) => client.request("/auth/accept-invite", { method: "POST", body: buildAuthPayload(input, client), auth: false }),
|
|
@@ -43772,10 +43868,10 @@ async function blobToBase643(blob) {
|
|
|
43772
43868
|
async function readCachedFileResponse(client, key) {
|
|
43773
43869
|
if (!client.native?.store || !isNative) return null;
|
|
43774
43870
|
const cached = (await client.native.store.get(`downloaded_files/${key}`)).val();
|
|
43775
|
-
|
|
43871
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileResponse", { key, hasCached: !!cached?.data });
|
|
43776
43872
|
if (!cached?.data) return null;
|
|
43777
43873
|
const blob = base64ToBlob(cached.data, cached.contentType || "application/octet-stream");
|
|
43778
|
-
|
|
43874
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileResponse built blob", { key, size: blob && blob.size });
|
|
43779
43875
|
return new Response(blob, {
|
|
43780
43876
|
headers: { "content-type": cached.contentType || "application/octet-stream" }
|
|
43781
43877
|
});
|
|
@@ -43783,14 +43879,14 @@ async function readCachedFileResponse(client, key) {
|
|
|
43783
43879
|
async function storeCachedFileResponse(client, key, response, fallbackContentType = "application/octet-stream") {
|
|
43784
43880
|
if (!client.native?.store || !isNative || !key) return;
|
|
43785
43881
|
try {
|
|
43786
|
-
|
|
43882
|
+
debugLog2(client, "[tevrocsdk][files] storeCachedFileResponse", { key });
|
|
43787
43883
|
const clone2 = response instanceof Response ? response.clone() : null;
|
|
43788
43884
|
const blob = clone2 ? await clone2.blob() : null;
|
|
43789
43885
|
const contentType = clone2 && clone2.headers.get("content-type") || fallbackContentType;
|
|
43790
43886
|
const data = blob ? await blobToBase643(blob) : "";
|
|
43791
|
-
|
|
43887
|
+
debugLog2(client, "[tevrocsdk][files] storeCachedFileResponse data length", { key, length: data ? data.length : 0, contentType });
|
|
43792
43888
|
if (!data) {
|
|
43793
|
-
|
|
43889
|
+
debugWarn2(client, "[tevrocsdk][files] storeCachedFileResponse no data to store", { key });
|
|
43794
43890
|
return;
|
|
43795
43891
|
}
|
|
43796
43892
|
await client.native.store.set(`downloaded_files/${key}`, {
|
|
@@ -43799,18 +43895,18 @@ async function storeCachedFileResponse(client, key, response, fallbackContentTyp
|
|
|
43799
43895
|
key,
|
|
43800
43896
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
43801
43897
|
});
|
|
43802
|
-
|
|
43898
|
+
debugLog2(client, "[tevrocsdk][files] storeCachedFileResponse stored", { key });
|
|
43803
43899
|
} catch (error) {
|
|
43804
43900
|
debugWarn2(client, "Failed to cache downloaded file", error);
|
|
43805
|
-
|
|
43901
|
+
debugWarn2(client, "[tevrocsdk][files] storeCachedFileResponse error", error);
|
|
43806
43902
|
}
|
|
43807
43903
|
}
|
|
43808
43904
|
async function readCachedFileDataUrl(client, key) {
|
|
43809
43905
|
if (!client.native?.store || !isNative || !key) return null;
|
|
43810
43906
|
const cached = (await client.native.store.get(`downloaded_files/${key}`)).val();
|
|
43811
|
-
|
|
43907
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileDataUrl", { key, hasCached: !!cached?.data });
|
|
43812
43908
|
if (!cached?.data) return null;
|
|
43813
|
-
|
|
43909
|
+
debugLog2(client, "[tevrocsdk][files] readCachedFileDataUrl returning data url", { key, length: cached.data.length });
|
|
43814
43910
|
return `data:${cached.contentType || "application/octet-stream"};base64,${cached.data}`;
|
|
43815
43911
|
}
|
|
43816
43912
|
function base64ToBlob(base64, contentType = "application/octet-stream") {
|
|
@@ -43842,7 +43938,7 @@ function createFileApi(client) {
|
|
|
43842
43938
|
}
|
|
43843
43939
|
rounds += 1;
|
|
43844
43940
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43845
|
-
if (rounds > 0)
|
|
43941
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed", { original: key, rawKey, rounds });
|
|
43846
43942
|
} catch (e2) {
|
|
43847
43943
|
}
|
|
43848
43944
|
debugLog2(client, "[tevrocsdk][files:url]", { key, rawKey, online, offline, isNative });
|
|
@@ -43872,7 +43968,7 @@ function createFileApi(client) {
|
|
|
43872
43968
|
}
|
|
43873
43969
|
rounds += 1;
|
|
43874
43970
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43875
|
-
if (rounds > 0)
|
|
43971
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed (privateUrl)", { original: key, rawKey, rounds });
|
|
43876
43972
|
} catch (e2) {
|
|
43877
43973
|
}
|
|
43878
43974
|
debugLog2(client, "[tevrocsdk][files:privateUrl]", { key, rawKey, online, offline, isNative });
|
|
@@ -43912,7 +44008,7 @@ function createFileApi(client) {
|
|
|
43912
44008
|
}
|
|
43913
44009
|
rounds += 1;
|
|
43914
44010
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43915
|
-
if (rounds > 0)
|
|
44011
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed (get)", { original: key, rawKey, rounds });
|
|
43916
44012
|
} catch (e2) {
|
|
43917
44013
|
}
|
|
43918
44014
|
debugLog2(client, "[tevrocsdk][files] get", { key, rawKey, isNative, online, offline });
|
|
@@ -43942,7 +44038,7 @@ function createFileApi(client) {
|
|
|
43942
44038
|
}
|
|
43943
44039
|
rounds += 1;
|
|
43944
44040
|
} while (rawKey !== prev && rawKey.includes("%25") && rounds < 5);
|
|
43945
|
-
if (rounds > 0)
|
|
44041
|
+
if (rounds > 0) debugLog2(client, "[tevrocsdk][files] iterative decode performed (getPrivate)", { original: key, rawKey, rounds });
|
|
43946
44042
|
} catch (e2) {
|
|
43947
44043
|
}
|
|
43948
44044
|
debugLog2(client, "[tevrocsdk][files] getPrivate", { key, rawKey, isNative, online, offline });
|
|
@@ -43980,7 +44076,7 @@ async function detectElectronEnvironment(client) {
|
|
|
43980
44076
|
}
|
|
43981
44077
|
}
|
|
43982
44078
|
} catch (error) {
|
|
43983
|
-
|
|
44079
|
+
debugLog2(client, "[tevrocsdk][env] /api/environment fallback", error);
|
|
43984
44080
|
}
|
|
43985
44081
|
if (typeof navigator !== "undefined") {
|
|
43986
44082
|
const userAgent = navigator.userAgent || "";
|
|
@@ -44128,6 +44224,23 @@ async function uploadViaGoogleStorage(client, file, options = {}) {
|
|
|
44128
44224
|
}
|
|
44129
44225
|
return { ...result, runtime: "gcs" };
|
|
44130
44226
|
}
|
|
44227
|
+
async function parseAxiosResponse(response, parseAs) {
|
|
44228
|
+
if (parseAs === "response") return response;
|
|
44229
|
+
const headers = response.headers ?? {};
|
|
44230
|
+
const contentType = typeof headers.get === "function" ? headers.get("content-type") ?? "" : String(headers["content-type"] ?? headers["Content-Type"] ?? "");
|
|
44231
|
+
const isJson = contentType.includes("application/json");
|
|
44232
|
+
const data = response.data;
|
|
44233
|
+
if (response.status < 200 || response.status >= 300) {
|
|
44234
|
+
const error = isJson && data?.error ? data.error : {};
|
|
44235
|
+
throw new TevrocError(error.message ?? response.statusText ?? "Request failed", {
|
|
44236
|
+
status: response.status,
|
|
44237
|
+
code: error.code ?? "api_error",
|
|
44238
|
+
details: error.details ?? data,
|
|
44239
|
+
response
|
|
44240
|
+
});
|
|
44241
|
+
}
|
|
44242
|
+
return data;
|
|
44243
|
+
}
|
|
44131
44244
|
async function parseResponse(response, parseAs) {
|
|
44132
44245
|
if (parseAs === "response") return response;
|
|
44133
44246
|
const contentType = response.headers.get("content-type") ?? "";
|
|
@@ -44164,13 +44277,13 @@ function normalizeHeaders(headers = {}) {
|
|
|
44164
44277
|
return Object.fromEntries(new Headers(headers).entries());
|
|
44165
44278
|
}
|
|
44166
44279
|
function debugLog2(client, ...args) {
|
|
44167
|
-
|
|
44280
|
+
debugLog(...args);
|
|
44168
44281
|
}
|
|
44169
44282
|
function debugWarn2(client, ...args) {
|
|
44170
|
-
|
|
44283
|
+
debugWarn(...args);
|
|
44171
44284
|
}
|
|
44172
44285
|
function debugError2(client, ...args) {
|
|
44173
|
-
|
|
44286
|
+
debugError(...args);
|
|
44174
44287
|
}
|
|
44175
44288
|
function safeLocalStorage() {
|
|
44176
44289
|
return typeof globalThis !== "undefined" ? globalThis.localStorage : void 0;
|