tevrocsdk 0.1.41 → 0.1.43

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/tevroc-sdk.umd.js CHANGED
@@ -26284,7 +26284,7 @@ var Tevroc = (() => {
26284
26284
  if (i4 !== -1) googleListeners.splice(i4, 1);
26285
26285
  };
26286
26286
  }
26287
- var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, authTauriUnlisten, authHandled, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
26287
+ var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, closeAllTauriWebviews, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
26288
26288
  var init_useGoogleAuth = __esm({
26289
26289
  "src/services/useGoogleAuth.js"() {
26290
26290
  init_esm3();
@@ -26296,8 +26296,6 @@ var Tevroc = (() => {
26296
26296
  authWindowRef = null;
26297
26297
  authCleanupTimer = null;
26298
26298
  authMessageListener = null;
26299
- authTauriUnlisten = null;
26300
- authHandled = false;
26301
26299
  closeAllTauriWebviews = async () => {
26302
26300
  if (!isTauri) return;
26303
26301
  try {
@@ -26334,14 +26332,6 @@ var Tevroc = (() => {
26334
26332
  window.removeEventListener("message", authMessageListener);
26335
26333
  authMessageListener = null;
26336
26334
  }
26337
- if (authTauriUnlisten) {
26338
- try {
26339
- await authTauriUnlisten();
26340
- } catch (e2) {
26341
- console.warn("Error removing Tauri auth listener:", e2);
26342
- }
26343
- authTauriUnlisten = null;
26344
- }
26345
26335
  if (authWindowRef) {
26346
26336
  const currentAuthWindow = authWindowRef;
26347
26337
  authWindowRef = null;
@@ -26375,8 +26365,6 @@ var Tevroc = (() => {
26375
26365
  };
26376
26366
  handleCallback = async (url) => {
26377
26367
  try {
26378
- if (authHandled) return;
26379
- authHandled = true;
26380
26368
  await cleanupAuthWindow();
26381
26369
  if (!url?.includes("token=")) return;
26382
26370
  const params = new URLSearchParams(url.split("?")[1]);
@@ -26458,17 +26446,6 @@ var Tevroc = (() => {
26458
26446
  win.once("tauri://error", (e2) => {
26459
26447
  console.error("Auth window error:", e2);
26460
26448
  });
26461
- try {
26462
- const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
26463
- authTauriUnlisten = await listen2("google-auth", async (event) => {
26464
- const token = event?.payload?.token;
26465
- if (!token) return;
26466
- const callbackUrl = `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${encodeURIComponent(token)}`;
26467
- await handleCallback(callbackUrl);
26468
- });
26469
- } catch (e2) {
26470
- console.warn("Tauri google-auth listener install failed:", e2);
26471
- }
26472
26449
  return;
26473
26450
  }
26474
26451
  const isLocalhost = true;
@@ -26601,38 +26578,19 @@ var Tevroc = (() => {
26601
26578
  externalCallback
26602
26579
  );
26603
26580
  });
26604
- await listen2("payment-result", async (event) => {
26605
- if (paymentWindowRef) {
26606
- try {
26607
- await paymentWindowRef.close();
26608
- paymentWindowRef = null;
26609
- } catch (e2) {
26610
- console.warn("Error closing Tauri payment window:", e2);
26611
- }
26612
- }
26613
- const payload = event?.payload || {};
26614
- const params = new URLSearchParams();
26615
- if (payload.status) params.set("status", payload.status);
26616
- if (payload.mode) params.set("mode", payload.mode);
26617
- if (payload.app) params.set("app", payload.app);
26618
- if (payload.checkoutId) params.set("checkoutId", payload.checkoutId);
26619
- const url = `?${params.toString()}`;
26620
- handlePaymentCallback(url, externalCallback);
26621
- });
26622
26581
  }
26623
26582
  };
26624
26583
  createPayment = async (amountZAR, {
26625
26584
  appId = "tevrocsoft",
26626
26585
  serviceUrl = "https://tevrocsoftapi.netlify.app",
26627
26586
  payAccount = "default",
26628
- companyId,
26629
26587
  externalCallback = () => {
26630
26588
  }
26631
26589
  } = {}) => {
26632
26590
  await initializePayment(externalCallback);
26633
26591
  const cents = Math.round(Number(amountZAR) * 100);
26634
26592
  const basePaymentUrl = `${serviceUrl.replace(/\/$/, "")}/yoco-pay`;
26635
- const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}${companyId ? `&companyId=${encodeURIComponent(companyId)}` : ""}`;
26593
+ const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}`;
26636
26594
  console.log(basePaymentUrl, paymentUrl);
26637
26595
  if (isCapacitor) {
26638
26596
  await Browser2.open({
@@ -26641,7 +26599,7 @@ var Tevroc = (() => {
26641
26599
  return;
26642
26600
  }
26643
26601
  if (isTauri) {
26644
- const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}${companyId ? `&companyId=${encodeURIComponent(companyId)}` : ""}`;
26602
+ const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}`;
26645
26603
  const win = new WebviewWindow("payment", {
26646
26604
  url,
26647
26605
  title: "Complete Payment",
@@ -26661,7 +26619,7 @@ var Tevroc = (() => {
26661
26619
  }
26662
26620
  const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
26663
26621
  const mode = isLocalhost ? "localhost" : "netlify";
26664
- const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}${companyId ? `&companyId=${encodeURIComponent(companyId)}` : ""}`;
26622
+ const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
26665
26623
  try {
26666
26624
  const popup = window.open(finalUrl, "yocoPayment", "width=500,height=650");
26667
26625
  if (!popup) {
@@ -41331,7 +41289,6 @@ var Tevroc = (() => {
41331
41289
  this.baseUrl = normalizeBaseUrl(baseUrl);
41332
41290
  this.serviceUrl = normalizeBaseUrl(serviceUrl);
41333
41291
  this.appId = options.appId;
41334
- this.userId = options.userId ?? options.user_id ?? "default";
41335
41292
  this.appName = options.appName;
41336
41293
  this.payAccount = options.payAccount ?? "default";
41337
41294
  this.isNative = options.isNative ?? false;
@@ -41395,9 +41352,6 @@ var Tevroc = (() => {
41395
41352
  if (this.appId) {
41396
41353
  headers.set("x-app-id", this.appId);
41397
41354
  }
41398
- if (this.userId) {
41399
- headers.set("x-user-id", this.userId);
41400
- }
41401
41355
  let body = options.body;
41402
41356
  if (body !== void 0 && body !== null && isJsonBody(body)) {
41403
41357
  headers.set("content-type", "application/json");
@@ -41443,25 +41397,33 @@ var Tevroc = (() => {
41443
41397
  }
41444
41398
  function createRealtimeApi(client) {
41445
41399
  const toWebSocketUrl = (baseUrl) => baseUrl.replace(/^http:/, "ws:").replace(/^https:/, "wss:");
41400
+ const connect = (room, handlers = {}) => {
41401
+ const url = `${toWebSocketUrl(client.baseUrl)}/realtime/${encodeURIComponent(room || "default")}`;
41402
+ const socket = new WebSocket(url);
41403
+ socket.addEventListener("open", (event) => handlers.open?.(event));
41404
+ socket.addEventListener("message", (event) => {
41405
+ let data = event.data;
41406
+ try {
41407
+ data = JSON.parse(event.data);
41408
+ } catch {
41409
+ }
41410
+ handlers.message?.(data, event);
41411
+ });
41412
+ socket.addEventListener("close", (event) => handlers.close?.(event));
41413
+ socket.addEventListener("error", (event) => handlers.error?.(event));
41414
+ return {
41415
+ socket,
41416
+ send: (payload) => socket.readyState === WebSocket.OPEN && socket.send(typeof payload === "string" ? payload : JSON.stringify(payload)),
41417
+ close: () => socket.close()
41418
+ };
41419
+ };
41446
41420
  return {
41447
- connect: (room, handlers = {}) => {
41448
- const url = `${toWebSocketUrl(client.baseUrl)}/realtime/${encodeURIComponent(room || "default")}`;
41449
- const socket = new WebSocket(url);
41450
- socket.addEventListener("open", (event) => handlers.open?.(event));
41451
- socket.addEventListener("message", (event) => {
41452
- let data = event.data;
41453
- try {
41454
- data = JSON.parse(event.data);
41455
- } catch {
41456
- }
41457
- handlers.message?.(data, event);
41458
- });
41459
- socket.addEventListener("close", (event) => handlers.close?.(event));
41460
- socket.addEventListener("error", (event) => handlers.error?.(event));
41421
+ connect,
41422
+ room: (room, handlers = {}) => {
41423
+ const connection = connect(room, handlers);
41461
41424
  return {
41462
- socket,
41463
- send: (payload) => socket.readyState === WebSocket.OPEN && socket.send(typeof payload === "string" ? payload : JSON.stringify(payload)),
41464
- close: () => socket.close()
41425
+ ...connection,
41426
+ publish: (payload) => connection.send(payload)
41465
41427
  };
41466
41428
  },
41467
41429
  iceServers: (config = {}) => {
@@ -41503,13 +41465,12 @@ var Tevroc = (() => {
41503
41465
  }
41504
41466
  function createPaymentApi(client) {
41505
41467
  return {
41506
- create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default", companyId, externalCallback = void 0 } = {}) => {
41468
+ create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default", externalCallback = void 0 } = {}) => {
41507
41469
  return await createPayment(amountZAR, {
41508
41470
  appId,
41509
41471
  serviceUrl: client.serviceUrl,
41510
41472
  mode,
41511
41473
  payAccount: account,
41512
- companyId,
41513
41474
  externalCallback
41514
41475
  });
41515
41476
  },
@@ -41726,10 +41687,7 @@ var Tevroc = (() => {
41726
41687
  function createIntegrationApi(client) {
41727
41688
  return {
41728
41689
  Core: {
41729
- InvokeLLM: (payload) => {
41730
- 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" };
41731
- return client.request("/integrations/core/invoke-llm", { method: "POST", body });
41732
- },
41690
+ InvokeLLM: (payload) => client.request("/integrations/core/invoke-llm", { method: "POST", body: payload }),
41733
41691
  GenerateImage: (payload) => client.request("/integrations/core/generate-image", { method: "POST", body: payload }),
41734
41692
  UploadFile: (file, options = {}) => upload(client, "/integrations/core/upload-file", file, options),
41735
41693
  UploadPrivateFile: (file, options = {}) => upload(client, "/integrations/core/upload-private-file", file, options),
@@ -41752,17 +41710,12 @@ var Tevroc = (() => {
41752
41710
  }
41753
41711
  function createAgentApi(client, agentName) {
41754
41712
  const base = `/agents/${encodeURIComponent(agentName)}/conversations`;
41755
- const withContext = (payload = {}) => ({
41756
- ...payload,
41757
- appId: payload.appId ?? client.appId,
41758
- userId: payload.userId ?? client.userId ?? "default"
41759
- });
41760
41713
  return {
41761
- createConversation: (input = {}) => client.request(base, { method: "POST", body: withContext(input) }),
41714
+ createConversation: (input = {}) => client.request(base, { method: "POST", body: input }),
41762
41715
  listConversations: () => client.request(base),
41763
41716
  getConversation: (conversationId) => client.request(`${base}/${encodeURIComponent(conversationId)}`),
41764
41717
  deleteConversation: (conversationId) => client.request(`${base}/${encodeURIComponent(conversationId)}`, { method: "DELETE" }),
41765
- addMessage: (conversationId, input) => client.request(`${base}/${encodeURIComponent(conversationId)}/messages`, { method: "POST", body: withContext(input) }),
41718
+ addMessage: (conversationId, input) => client.request(`${base}/${encodeURIComponent(conversationId)}/messages`, { method: "POST", body: input }),
41766
41719
  listMessages: (conversationId) => client.request(`${base}/${encodeURIComponent(conversationId)}/messages`)
41767
41720
  };
41768
41721
  }