@greatapps/greatagents-ui 0.3.7 → 0.3.8

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/index.js CHANGED
@@ -3047,8 +3047,8 @@ function InfoStep({ integration, meta }) {
3047
3047
  }
3048
3048
 
3049
3049
  // src/components/capabilities/wizard-steps/credentials-step.tsx
3050
- import { CheckCircle2, Loader2 as Loader25, AlertCircle, Shield, Info as Info2 } from "lucide-react";
3051
- import { Button as Button9, Input as Input6, Label as Label4, Tooltip as Tooltip3, TooltipTrigger as TooltipTrigger3, TooltipContent as TooltipContent3 } from "@greatapps/greatauth-ui/ui";
3050
+ import { CheckCircle2, Loader2 as Loader25, AlertCircle, Shield } from "lucide-react";
3051
+ import { Button as Button9, Input as Input6, Label as Label4 } from "@greatapps/greatauth-ui/ui";
3052
3052
  import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
3053
3053
  function CredentialsStep({
3054
3054
  integration,
@@ -3058,8 +3058,7 @@ function CredentialsStep({
3058
3058
  apiKey,
3059
3059
  onApiKeyChange,
3060
3060
  onStartOAuth,
3061
- isReconnect = false,
3062
- oauthConfigured = false
3061
+ isReconnect = false
3063
3062
  }) {
3064
3063
  if (integration.authType === "oauth2") {
3065
3064
  return /* @__PURE__ */ jsx14(
@@ -3070,8 +3069,7 @@ function CredentialsStep({
3070
3069
  oauthStatus,
3071
3070
  oauthResult,
3072
3071
  onStartOAuth,
3073
- isReconnect,
3074
- oauthConfigured
3072
+ isReconnect
3075
3073
  }
3076
3074
  );
3077
3075
  }
@@ -3083,8 +3081,7 @@ function OAuthCredentials({
3083
3081
  oauthStatus,
3084
3082
  oauthResult,
3085
3083
  onStartOAuth,
3086
- isReconnect,
3087
- oauthConfigured
3084
+ isReconnect
3088
3085
  }) {
3089
3086
  const providerLabel = meta.providerLabel || integration.name;
3090
3087
  return /* @__PURE__ */ jsxs12("div", { className: "space-y-6", children: [
@@ -3092,40 +3089,19 @@ function OAuthCredentials({
3092
3089
  /* @__PURE__ */ jsx14("h3", { className: "text-lg font-semibold", children: "Autentica\xE7\xE3o" }),
3093
3090
  /* @__PURE__ */ jsx14("p", { className: "text-sm text-muted-foreground", children: isReconnect ? `Reconecte sua conta ${providerLabel} para renovar a autoriza\xE7\xE3o.` : `Conecte sua conta ${providerLabel} para permitir o acesso.` })
3094
3091
  ] }),
3095
- !oauthConfigured && oauthStatus === "idle" && /* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 p-4 dark:border-amber-900 dark:bg-amber-950/30", children: [
3096
- /* @__PURE__ */ jsx14(
3097
- Info2,
3092
+ /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-4 rounded-lg border p-6", children: [
3093
+ oauthStatus === "idle" && /* @__PURE__ */ jsxs12(
3094
+ Button9,
3098
3095
  {
3099
- "aria-hidden": "true",
3100
- className: "mt-0.5 h-5 w-5 shrink-0 text-amber-600 dark:text-amber-400"
3096
+ onClick: onStartOAuth,
3097
+ size: "lg",
3098
+ className: "gap-2",
3099
+ children: [
3100
+ meta.icon,
3101
+ isReconnect ? `Reconectar com ${providerLabel}` : `Conectar com ${providerLabel}`
3102
+ ]
3101
3103
  }
3102
3104
  ),
3103
- /* @__PURE__ */ jsxs12("div", { className: "space-y-1", children: [
3104
- /* @__PURE__ */ jsx14("p", { className: "text-sm font-medium text-amber-800 dark:text-amber-200", children: "Configura\xE7\xE3o necess\xE1ria" }),
3105
- /* @__PURE__ */ jsxs12("p", { className: "text-xs text-amber-700 dark:text-amber-300", children: [
3106
- "A integra\xE7\xE3o com ",
3107
- providerLabel,
3108
- " requer configura\xE7\xE3o pelo administrador do sistema. Entre em contato com o suporte para ativar esta funcionalidade."
3109
- ] })
3110
- ] })
3111
- ] }),
3112
- /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-4 rounded-lg border p-6", children: [
3113
- oauthStatus === "idle" && /* @__PURE__ */ jsxs12(Tooltip3, { children: [
3114
- /* @__PURE__ */ jsx14(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx14("span", { tabIndex: !oauthConfigured ? 0 : void 0, children: /* @__PURE__ */ jsxs12(
3115
- Button9,
3116
- {
3117
- onClick: onStartOAuth,
3118
- size: "lg",
3119
- className: "gap-2",
3120
- disabled: !oauthConfigured,
3121
- children: [
3122
- meta.icon,
3123
- isReconnect ? `Reconectar com ${providerLabel}` : `Conectar com ${providerLabel}`
3124
- ]
3125
- }
3126
- ) }) }),
3127
- !oauthConfigured && /* @__PURE__ */ jsx14(TooltipContent3, { children: "Integra\xE7\xE3o OAuth ainda n\xE3o configurada no servidor" })
3128
- ] }),
3129
3105
  oauthStatus === "waiting" && /* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-center gap-3 text-center", children: [
3130
3106
  /* @__PURE__ */ jsx14(
3131
3107
  Loader25,
@@ -3490,38 +3466,54 @@ function IntegrationWizard({
3490
3466
  window.addEventListener("message", handleOAuthMessage);
3491
3467
  return () => window.removeEventListener("message", handleOAuthMessage);
3492
3468
  }, [open, handleOAuthMessage]);
3493
- function startOAuth() {
3494
- const { language = "pt-br", idWl = 1, accountId } = config;
3495
- const redirectUri = `${window.location.origin}/oauth/callback`;
3496
- const url = new URL(
3497
- `${gagentsApiUrl}/v1/${language}/${idWl}/accounts/${accountId}/oauth/authorize/${integration.slug}`
3498
- );
3499
- url.searchParams.set("redirect_uri", redirectUri);
3469
+ async function startOAuth() {
3470
+ const { language = "pt-br", idWl = 1, accountId, token } = config;
3500
3471
  setOauthStatus("waiting");
3501
- const popup = window.open(
3502
- url.toString(),
3503
- "oauth-popup",
3504
- "width=500,height=600,scrollbars=yes,resizable=yes"
3505
- );
3506
- popupRef.current = popup;
3507
- if (popup) {
3508
- if (popupPollRef.current) {
3509
- clearInterval(popupPollRef.current);
3472
+ try {
3473
+ const response = await fetch(
3474
+ `${gagentsApiUrl}/v1/${language}/${idWl}/accounts/${accountId}/oauth/authorize/${integration.slug}`,
3475
+ { headers: { Authorization: `Bearer ${token}` } }
3476
+ );
3477
+ const result = await response.json();
3478
+ if (result.status !== 1 || !result.data?.auth_url) {
3479
+ setOauthStatus("error");
3480
+ setOauthResult({
3481
+ success: false,
3482
+ error: result.message || "Erro ao obter URL de autoriza\xE7\xE3o"
3483
+ });
3484
+ return;
3510
3485
  }
3511
- popupPollRef.current = setInterval(() => {
3512
- if (popup.closed) {
3513
- if (popupPollRef.current) {
3514
- clearInterval(popupPollRef.current);
3515
- popupPollRef.current = null;
3516
- }
3517
- setOauthStatus(
3518
- (prev) => prev === "waiting" ? "error" : prev
3519
- );
3520
- setOauthResult(
3521
- (prev) => prev === null ? { success: false, error: "Janela fechada antes de concluir" } : prev
3522
- );
3486
+ const popup = window.open(
3487
+ result.data.auth_url,
3488
+ "oauth-popup",
3489
+ "width=500,height=600,scrollbars=yes,resizable=yes"
3490
+ );
3491
+ popupRef.current = popup;
3492
+ if (popup) {
3493
+ if (popupPollRef.current) {
3494
+ clearInterval(popupPollRef.current);
3523
3495
  }
3524
- }, 500);
3496
+ popupPollRef.current = setInterval(() => {
3497
+ if (popup.closed) {
3498
+ if (popupPollRef.current) {
3499
+ clearInterval(popupPollRef.current);
3500
+ popupPollRef.current = null;
3501
+ }
3502
+ setOauthStatus(
3503
+ (prev) => prev === "waiting" ? "error" : prev
3504
+ );
3505
+ setOauthResult(
3506
+ (prev) => prev === null ? { success: false, error: "Janela fechada antes de concluir" } : prev
3507
+ );
3508
+ }
3509
+ }, 500);
3510
+ }
3511
+ } catch (err) {
3512
+ setOauthStatus("error");
3513
+ setOauthResult({
3514
+ success: false,
3515
+ error: "Erro de rede ao obter URL de autoriza\xE7\xE3o"
3516
+ });
3525
3517
  }
3526
3518
  }
3527
3519
  function canAdvance() {
@@ -3742,9 +3734,9 @@ import { DataTable as DataTable2 } from "@greatapps/greatauth-ui";
3742
3734
  import {
3743
3735
  Input as Input7,
3744
3736
  Badge as Badge7,
3745
- Tooltip as Tooltip4,
3746
- TooltipTrigger as TooltipTrigger4,
3747
- TooltipContent as TooltipContent4,
3737
+ Tooltip as Tooltip3,
3738
+ TooltipTrigger as TooltipTrigger3,
3739
+ TooltipContent as TooltipContent3,
3748
3740
  AlertDialog as AlertDialog3,
3749
3741
  AlertDialogAction as AlertDialogAction3,
3750
3742
  AlertDialogCancel as AlertDialogCancel3,
@@ -3799,8 +3791,8 @@ function useColumns2(onEdit, onDelete) {
3799
3791
  size: 80,
3800
3792
  enableSorting: false,
3801
3793
  cell: ({ row }) => /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-1", children: [
3802
- /* @__PURE__ */ jsxs16(Tooltip4, { children: [
3803
- /* @__PURE__ */ jsx18(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx18(
3794
+ /* @__PURE__ */ jsxs16(Tooltip3, { children: [
3795
+ /* @__PURE__ */ jsx18(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx18(
3804
3796
  Button11,
3805
3797
  {
3806
3798
  variant: "ghost",
@@ -3811,10 +3803,10 @@ function useColumns2(onEdit, onDelete) {
3811
3803
  children: /* @__PURE__ */ jsx18(Pencil3, { className: "h-4 w-4" })
3812
3804
  }
3813
3805
  ) }),
3814
- /* @__PURE__ */ jsx18(TooltipContent4, { children: "Editar" })
3806
+ /* @__PURE__ */ jsx18(TooltipContent3, { children: "Editar" })
3815
3807
  ] }),
3816
- /* @__PURE__ */ jsxs16(Tooltip4, { children: [
3817
- /* @__PURE__ */ jsx18(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx18(
3808
+ /* @__PURE__ */ jsxs16(Tooltip3, { children: [
3809
+ /* @__PURE__ */ jsx18(TooltipTrigger3, { asChild: true, children: /* @__PURE__ */ jsx18(
3818
3810
  Button11,
3819
3811
  {
3820
3812
  variant: "ghost",
@@ -3825,7 +3817,7 @@ function useColumns2(onEdit, onDelete) {
3825
3817
  children: /* @__PURE__ */ jsx18(Trash23, { className: "h-4 w-4" })
3826
3818
  }
3827
3819
  ) }),
3828
- /* @__PURE__ */ jsx18(TooltipContent4, { children: "Excluir" })
3820
+ /* @__PURE__ */ jsx18(TooltipContent3, { children: "Excluir" })
3829
3821
  ] })
3830
3822
  ] })
3831
3823
  }
@@ -3933,9 +3925,9 @@ import {
3933
3925
  Input as Input8,
3934
3926
  Button as Button12,
3935
3927
  Badge as Badge8,
3936
- Tooltip as Tooltip5,
3937
- TooltipTrigger as TooltipTrigger5,
3938
- TooltipContent as TooltipContent5,
3928
+ Tooltip as Tooltip4,
3929
+ TooltipTrigger as TooltipTrigger4,
3930
+ TooltipContent as TooltipContent4,
3939
3931
  Dialog as Dialog5,
3940
3932
  DialogContent as DialogContent5,
3941
3933
  DialogHeader as DialogHeader5,
@@ -4013,8 +4005,8 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
4013
4005
  size: 100,
4014
4006
  enableSorting: false,
4015
4007
  cell: ({ row }) => /* @__PURE__ */ jsxs17("div", { className: "flex items-center gap-1", children: [
4016
- getToolType(row.original.id_tool) === "oauth2" && /* @__PURE__ */ jsxs17(Tooltip5, { children: [
4017
- /* @__PURE__ */ jsx19(TooltipTrigger5, { asChild: true, children: /* @__PURE__ */ jsx19(
4008
+ getToolType(row.original.id_tool) === "oauth2" && /* @__PURE__ */ jsxs17(Tooltip4, { children: [
4009
+ /* @__PURE__ */ jsx19(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx19(
4018
4010
  Button12,
4019
4011
  {
4020
4012
  variant: "ghost",
@@ -4025,10 +4017,10 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
4025
4017
  children: /* @__PURE__ */ jsx19(Link, { className: "h-4 w-4" })
4026
4018
  }
4027
4019
  ) }),
4028
- /* @__PURE__ */ jsx19(TooltipContent5, { children: "Em breve" })
4020
+ /* @__PURE__ */ jsx19(TooltipContent4, { children: "Em breve" })
4029
4021
  ] }),
4030
- /* @__PURE__ */ jsxs17(Tooltip5, { children: [
4031
- /* @__PURE__ */ jsx19(TooltipTrigger5, { asChild: true, children: /* @__PURE__ */ jsx19(
4022
+ /* @__PURE__ */ jsxs17(Tooltip4, { children: [
4023
+ /* @__PURE__ */ jsx19(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx19(
4032
4024
  Button12,
4033
4025
  {
4034
4026
  variant: "ghost",
@@ -4039,10 +4031,10 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
4039
4031
  children: /* @__PURE__ */ jsx19(Pencil4, { className: "h-4 w-4" })
4040
4032
  }
4041
4033
  ) }),
4042
- /* @__PURE__ */ jsx19(TooltipContent5, { children: "Editar" })
4034
+ /* @__PURE__ */ jsx19(TooltipContent4, { children: "Editar" })
4043
4035
  ] }),
4044
- /* @__PURE__ */ jsxs17(Tooltip5, { children: [
4045
- /* @__PURE__ */ jsx19(TooltipTrigger5, { asChild: true, children: /* @__PURE__ */ jsx19(
4036
+ /* @__PURE__ */ jsxs17(Tooltip4, { children: [
4037
+ /* @__PURE__ */ jsx19(TooltipTrigger4, { asChild: true, children: /* @__PURE__ */ jsx19(
4046
4038
  Button12,
4047
4039
  {
4048
4040
  variant: "ghost",
@@ -4053,7 +4045,7 @@ function useColumns3(tools, onEdit, onConnect, onRemove) {
4053
4045
  children: /* @__PURE__ */ jsx19(Trash24, { className: "h-4 w-4" })
4054
4046
  }
4055
4047
  ) }),
4056
- /* @__PURE__ */ jsx19(TooltipContent5, { children: "Remover" })
4048
+ /* @__PURE__ */ jsx19(TooltipContent4, { children: "Remover" })
4057
4049
  ] })
4058
4050
  ] })
4059
4051
  }
@@ -4714,7 +4706,7 @@ function ToolFormDialog({
4714
4706
  }
4715
4707
 
4716
4708
  // src/components/capabilities/advanced-tab.tsx
4717
- import { Info as Info3 } from "lucide-react";
4709
+ import { Info as Info2 } from "lucide-react";
4718
4710
  import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
4719
4711
  function AdvancedTab({ config, agentId, gagentsApiUrl }) {
4720
4712
  const { data: credentialsData, isLoading: isLoadingCredentials } = useToolCredentials(config);
@@ -4731,7 +4723,7 @@ function AdvancedTab({ config, agentId, gagentsApiUrl }) {
4731
4723
  }
4732
4724
  return /* @__PURE__ */ jsxs19("div", { className: "space-y-8", children: [
4733
4725
  /* @__PURE__ */ jsxs19("div", { className: "flex items-start gap-3 rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-900 dark:bg-blue-950/30", children: [
4734
- /* @__PURE__ */ jsx21(Info3, { className: "mt-0.5 h-4 w-4 shrink-0 text-blue-600 dark:text-blue-400" }),
4726
+ /* @__PURE__ */ jsx21(Info2, { className: "mt-0.5 h-4 w-4 shrink-0 text-blue-600 dark:text-blue-400" }),
4735
4727
  /* @__PURE__ */ jsxs19("p", { className: "text-sm text-blue-800 dark:text-blue-300", children: [
4736
4728
  "Use as abas ",
4737
4729
  /* @__PURE__ */ jsx21("strong", { children: "Capacidades" }),
@@ -5474,7 +5466,7 @@ import {
5474
5466
  TabsList as TabsList3,
5475
5467
  TabsTrigger as TabsTrigger3
5476
5468
  } from "@greatapps/greatauth-ui/ui";
5477
- import { Plus as Plus6, Plug as Plug4, KeyRound, Info as Info4 } from "lucide-react";
5469
+ import { Plus as Plus6, Plug as Plug4, KeyRound, Info as Info3 } from "lucide-react";
5478
5470
  import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
5479
5471
  function useCredentialAgentSummary(credentials, tools, agents) {
5480
5472
  return useMemo8(() => {
@@ -5534,7 +5526,7 @@ function IntegrationsManagementPage({
5534
5526
  ) }),
5535
5527
  /* @__PURE__ */ jsxs27(TabsContent3, { value: "credentials", className: "mt-4", children: [
5536
5528
  !credentialsLoading && /* @__PURE__ */ jsxs27("div", { className: "flex items-center gap-4 rounded-lg border bg-muted/50 px-4 py-3 mb-4", children: [
5537
- /* @__PURE__ */ jsx29(Info4, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
5529
+ /* @__PURE__ */ jsx29(Info3, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
5538
5530
  /* @__PURE__ */ jsxs27("div", { className: "flex flex-wrap items-center gap-3 text-sm", children: [
5539
5531
  /* @__PURE__ */ jsxs27("span", { children: [
5540
5532
  /* @__PURE__ */ jsx29(Badge11, { variant: "secondary", className: "mr-1", children: summary.totalCredentials }),