tevrocsdk 0.1.41 → 0.1.42
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 +516 -516
- package/package.json +20 -20
- package/tevroc-sdk.esm.js +8 -63
- package/tevroc-sdk.min.js +31 -31
- package/tevroc-sdk.umd.js +8 -63
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tevrocsdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "JavaScript SDK for the Tevroc API.",
|
|
5
|
-
"main": "./tevroc-sdk.umd.js",
|
|
6
|
-
"module": "./tevroc-sdk.esm.js",
|
|
7
|
-
|
|
8
|
-
"keywords": [
|
|
9
|
-
"tevroc",
|
|
10
|
-
"sdk",
|
|
11
|
-
"worker",
|
|
12
|
-
"api" ,
|
|
13
|
-
"tauri",
|
|
14
|
-
"capacitor",
|
|
15
|
-
"YOCO" ,
|
|
16
|
-
"google Auth",
|
|
17
|
-
"Google Drive",
|
|
18
|
-
"Firebase"
|
|
19
|
-
],
|
|
20
|
-
"license": "MIT"
|
|
1
|
+
{
|
|
2
|
+
"name": "tevrocsdk",
|
|
3
|
+
"version": "0.1.42",
|
|
4
|
+
"description": "JavaScript SDK for the Tevroc API.",
|
|
5
|
+
"main": "./tevroc-sdk.umd.js",
|
|
6
|
+
"module": "./tevroc-sdk.esm.js",
|
|
7
|
+
|
|
8
|
+
"keywords": [
|
|
9
|
+
"tevroc",
|
|
10
|
+
"sdk",
|
|
11
|
+
"worker",
|
|
12
|
+
"api" ,
|
|
13
|
+
"tauri",
|
|
14
|
+
"capacitor",
|
|
15
|
+
"YOCO" ,
|
|
16
|
+
"google Auth",
|
|
17
|
+
"Google Drive",
|
|
18
|
+
"Firebase"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT"
|
|
21
21
|
}
|
package/tevroc-sdk.esm.js
CHANGED
|
@@ -26282,7 +26282,7 @@ function subscribeGoogleLogin(cb) {
|
|
|
26282
26282
|
if (i4 !== -1) googleListeners.splice(i4, 1);
|
|
26283
26283
|
};
|
|
26284
26284
|
}
|
|
26285
|
-
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener,
|
|
26285
|
+
var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
|
|
26286
26286
|
var init_useGoogleAuth = __esm({
|
|
26287
26287
|
"src/services/useGoogleAuth.js"() {
|
|
26288
26288
|
init_esm3();
|
|
@@ -26294,8 +26294,6 @@ var init_useGoogleAuth = __esm({
|
|
|
26294
26294
|
authWindowRef = null;
|
|
26295
26295
|
authCleanupTimer = null;
|
|
26296
26296
|
authMessageListener = null;
|
|
26297
|
-
authTauriUnlisten = null;
|
|
26298
|
-
authHandled = false;
|
|
26299
26297
|
closeAllTauriWebviews = async () => {
|
|
26300
26298
|
if (!isTauri) return;
|
|
26301
26299
|
try {
|
|
@@ -26332,14 +26330,6 @@ var init_useGoogleAuth = __esm({
|
|
|
26332
26330
|
window.removeEventListener("message", authMessageListener);
|
|
26333
26331
|
authMessageListener = null;
|
|
26334
26332
|
}
|
|
26335
|
-
if (authTauriUnlisten) {
|
|
26336
|
-
try {
|
|
26337
|
-
await authTauriUnlisten();
|
|
26338
|
-
} catch (e2) {
|
|
26339
|
-
console.warn("Error removing Tauri auth listener:", e2);
|
|
26340
|
-
}
|
|
26341
|
-
authTauriUnlisten = null;
|
|
26342
|
-
}
|
|
26343
26333
|
if (authWindowRef) {
|
|
26344
26334
|
const currentAuthWindow = authWindowRef;
|
|
26345
26335
|
authWindowRef = null;
|
|
@@ -26373,8 +26363,6 @@ var init_useGoogleAuth = __esm({
|
|
|
26373
26363
|
};
|
|
26374
26364
|
handleCallback = async (url) => {
|
|
26375
26365
|
try {
|
|
26376
|
-
if (authHandled) return;
|
|
26377
|
-
authHandled = true;
|
|
26378
26366
|
await cleanupAuthWindow();
|
|
26379
26367
|
if (!url?.includes("token=")) return;
|
|
26380
26368
|
const params = new URLSearchParams(url.split("?")[1]);
|
|
@@ -26456,17 +26444,6 @@ var init_useGoogleAuth = __esm({
|
|
|
26456
26444
|
win.once("tauri://error", (e2) => {
|
|
26457
26445
|
console.error("Auth window error:", e2);
|
|
26458
26446
|
});
|
|
26459
|
-
try {
|
|
26460
|
-
const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
|
|
26461
|
-
authTauriUnlisten = await listen2("google-auth", async (event) => {
|
|
26462
|
-
const token = event?.payload?.token;
|
|
26463
|
-
if (!token) return;
|
|
26464
|
-
const callbackUrl = `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${encodeURIComponent(token)}`;
|
|
26465
|
-
await handleCallback(callbackUrl);
|
|
26466
|
-
});
|
|
26467
|
-
} catch (e2) {
|
|
26468
|
-
console.warn("Tauri google-auth listener install failed:", e2);
|
|
26469
|
-
}
|
|
26470
26447
|
return;
|
|
26471
26448
|
}
|
|
26472
26449
|
const isLocalhost = true;
|
|
@@ -26599,38 +26576,19 @@ var init_useYocoPayment = __esm({
|
|
|
26599
26576
|
externalCallback
|
|
26600
26577
|
);
|
|
26601
26578
|
});
|
|
26602
|
-
await listen2("payment-result", async (event) => {
|
|
26603
|
-
if (paymentWindowRef) {
|
|
26604
|
-
try {
|
|
26605
|
-
await paymentWindowRef.close();
|
|
26606
|
-
paymentWindowRef = null;
|
|
26607
|
-
} catch (e2) {
|
|
26608
|
-
console.warn("Error closing Tauri payment window:", e2);
|
|
26609
|
-
}
|
|
26610
|
-
}
|
|
26611
|
-
const payload = event?.payload || {};
|
|
26612
|
-
const params = new URLSearchParams();
|
|
26613
|
-
if (payload.status) params.set("status", payload.status);
|
|
26614
|
-
if (payload.mode) params.set("mode", payload.mode);
|
|
26615
|
-
if (payload.app) params.set("app", payload.app);
|
|
26616
|
-
if (payload.checkoutId) params.set("checkoutId", payload.checkoutId);
|
|
26617
|
-
const url = `?${params.toString()}`;
|
|
26618
|
-
handlePaymentCallback(url, externalCallback);
|
|
26619
|
-
});
|
|
26620
26579
|
}
|
|
26621
26580
|
};
|
|
26622
26581
|
createPayment = async (amountZAR, {
|
|
26623
26582
|
appId = "tevrocsoft",
|
|
26624
26583
|
serviceUrl = "https://tevrocsoftapi.netlify.app",
|
|
26625
26584
|
payAccount = "default",
|
|
26626
|
-
companyId,
|
|
26627
26585
|
externalCallback = () => {
|
|
26628
26586
|
}
|
|
26629
26587
|
} = {}) => {
|
|
26630
26588
|
await initializePayment(externalCallback);
|
|
26631
26589
|
const cents = Math.round(Number(amountZAR) * 100);
|
|
26632
26590
|
const basePaymentUrl = `${serviceUrl.replace(/\/$/, "")}/yoco-pay`;
|
|
26633
|
-
const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}
|
|
26591
|
+
const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}`;
|
|
26634
26592
|
console.log(basePaymentUrl, paymentUrl);
|
|
26635
26593
|
if (isCapacitor) {
|
|
26636
26594
|
await Browser2.open({
|
|
@@ -26639,7 +26597,7 @@ var init_useYocoPayment = __esm({
|
|
|
26639
26597
|
return;
|
|
26640
26598
|
}
|
|
26641
26599
|
if (isTauri) {
|
|
26642
|
-
const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}
|
|
26600
|
+
const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}`;
|
|
26643
26601
|
const win = new WebviewWindow("payment", {
|
|
26644
26602
|
url,
|
|
26645
26603
|
title: "Complete Payment",
|
|
@@ -26659,7 +26617,7 @@ var init_useYocoPayment = __esm({
|
|
|
26659
26617
|
}
|
|
26660
26618
|
const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
|
|
26661
26619
|
const mode = isLocalhost ? "localhost" : "netlify";
|
|
26662
|
-
const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}
|
|
26620
|
+
const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
|
|
26663
26621
|
try {
|
|
26664
26622
|
const popup = window.open(finalUrl, "yocoPayment", "width=500,height=650");
|
|
26665
26623
|
if (!popup) {
|
|
@@ -41321,7 +41279,6 @@ var TevrocClient = class {
|
|
|
41321
41279
|
this.baseUrl = normalizeBaseUrl(baseUrl);
|
|
41322
41280
|
this.serviceUrl = normalizeBaseUrl(serviceUrl);
|
|
41323
41281
|
this.appId = options.appId;
|
|
41324
|
-
this.userId = options.userId ?? options.user_id ?? "default";
|
|
41325
41282
|
this.appName = options.appName;
|
|
41326
41283
|
this.payAccount = options.payAccount ?? "default";
|
|
41327
41284
|
this.isNative = options.isNative ?? false;
|
|
@@ -41385,9 +41342,6 @@ var TevrocClient = class {
|
|
|
41385
41342
|
if (this.appId) {
|
|
41386
41343
|
headers.set("x-app-id", this.appId);
|
|
41387
41344
|
}
|
|
41388
|
-
if (this.userId) {
|
|
41389
|
-
headers.set("x-user-id", this.userId);
|
|
41390
|
-
}
|
|
41391
41345
|
let body = options.body;
|
|
41392
41346
|
if (body !== void 0 && body !== null && isJsonBody(body)) {
|
|
41393
41347
|
headers.set("content-type", "application/json");
|
|
@@ -41493,13 +41447,12 @@ function createPlatformApi(client) {
|
|
|
41493
41447
|
}
|
|
41494
41448
|
function createPaymentApi(client) {
|
|
41495
41449
|
return {
|
|
41496
|
-
create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default",
|
|
41450
|
+
create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default", externalCallback = void 0 } = {}) => {
|
|
41497
41451
|
return await createPayment(amountZAR, {
|
|
41498
41452
|
appId,
|
|
41499
41453
|
serviceUrl: client.serviceUrl,
|
|
41500
41454
|
mode,
|
|
41501
41455
|
payAccount: account,
|
|
41502
|
-
companyId,
|
|
41503
41456
|
externalCallback
|
|
41504
41457
|
});
|
|
41505
41458
|
},
|
|
@@ -41716,10 +41669,7 @@ function createFunctionRegistry(client) {
|
|
|
41716
41669
|
function createIntegrationApi(client) {
|
|
41717
41670
|
return {
|
|
41718
41671
|
Core: {
|
|
41719
|
-
InvokeLLM: (payload) => {
|
|
41720
|
-
const body = payload && typeof payload === "object" ? { ...payload, appId: payload.appId ?? client.appId, userId: payload.userId ?? client.userId ?? "default" } : { appId: client.appId, userId: client.userId ?? "default" };
|
|
41721
|
-
return client.request("/integrations/core/invoke-llm", { method: "POST", body });
|
|
41722
|
-
},
|
|
41672
|
+
InvokeLLM: (payload) => client.request("/integrations/core/invoke-llm", { method: "POST", body: payload }),
|
|
41723
41673
|
GenerateImage: (payload) => client.request("/integrations/core/generate-image", { method: "POST", body: payload }),
|
|
41724
41674
|
UploadFile: (file, options = {}) => upload(client, "/integrations/core/upload-file", file, options),
|
|
41725
41675
|
UploadPrivateFile: (file, options = {}) => upload(client, "/integrations/core/upload-private-file", file, options),
|
|
@@ -41742,17 +41692,12 @@ function createAgentRegistry(client) {
|
|
|
41742
41692
|
}
|
|
41743
41693
|
function createAgentApi(client, agentName) {
|
|
41744
41694
|
const base = `/agents/${encodeURIComponent(agentName)}/conversations`;
|
|
41745
|
-
const withContext = (payload = {}) => ({
|
|
41746
|
-
...payload,
|
|
41747
|
-
appId: payload.appId ?? client.appId,
|
|
41748
|
-
userId: payload.userId ?? client.userId ?? "default"
|
|
41749
|
-
});
|
|
41750
41695
|
return {
|
|
41751
|
-
createConversation: (input = {}) => client.request(base, { method: "POST", body:
|
|
41696
|
+
createConversation: (input = {}) => client.request(base, { method: "POST", body: input }),
|
|
41752
41697
|
listConversations: () => client.request(base),
|
|
41753
41698
|
getConversation: (conversationId) => client.request(`${base}/${encodeURIComponent(conversationId)}`),
|
|
41754
41699
|
deleteConversation: (conversationId) => client.request(`${base}/${encodeURIComponent(conversationId)}`, { method: "DELETE" }),
|
|
41755
|
-
addMessage: (conversationId, input) => client.request(`${base}/${encodeURIComponent(conversationId)}/messages`, { method: "POST", body:
|
|
41700
|
+
addMessage: (conversationId, input) => client.request(`${base}/${encodeURIComponent(conversationId)}/messages`, { method: "POST", body: input }),
|
|
41756
41701
|
listMessages: (conversationId) => client.request(`${base}/${encodeURIComponent(conversationId)}/messages`)
|
|
41757
41702
|
};
|
|
41758
41703
|
}
|