@supyagent/sdk 0.1.7 → 0.1.9

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/react.js CHANGED
@@ -768,8 +768,21 @@ function formatRecipients(to) {
768
768
  if (Array.isArray(to)) return to.join(", ");
769
769
  return to;
770
770
  }
771
+ var HIDDEN_LABELS = /* @__PURE__ */ new Set(["INBOX", "UNREAD", "SENT", "DRAFT", "SPAM", "TRASH", "STARRED", "IMPORTANT"]);
772
+ function humanizeLabel(label) {
773
+ if (label.startsWith("CATEGORY_")) return label.slice(9).charAt(0) + label.slice(10).toLowerCase();
774
+ return label;
775
+ }
776
+ function resolveLabels(email) {
777
+ if (email.labels && email.labels.length > 0) return email.labels;
778
+ if (email.labelIds && email.labelIds.length > 0) {
779
+ return email.labelIds.filter((id) => !HIDDEN_LABELS.has(id)).map(humanizeLabel);
780
+ }
781
+ return [];
782
+ }
771
783
  function EmailCard({ email }) {
772
784
  const recipients = formatRecipients(email.to);
785
+ const labels = resolveLabels(email);
773
786
  return /* @__PURE__ */ jsxs3("div", { className: "rounded-lg border border-border bg-card p-3 space-y-2", children: [
774
787
  /* @__PURE__ */ jsxs3("div", { className: "flex items-start gap-2", children: [
775
788
  /* @__PURE__ */ jsx4(Mail2, { className: "h-4 w-4 text-muted-foreground mt-0.5 shrink-0" }),
@@ -786,7 +799,7 @@ function EmailCard({ email }) {
786
799
  email.date && /* @__PURE__ */ jsx4("span", { className: "text-xs text-muted-foreground", children: formatRelativeDate(email.date) })
787
800
  ] })
788
801
  ] }),
789
- email.labels && email.labels.length > 0 && /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-1.5 flex-wrap", children: email.labels.map((label) => /* @__PURE__ */ jsxs3(
802
+ labels.length > 0 && /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-1.5 flex-wrap", children: labels.map((label) => /* @__PURE__ */ jsxs3(
790
803
  "span",
791
804
  {
792
805
  className: "inline-flex items-center gap-1 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground",
@@ -957,11 +970,12 @@ function MessageBubble({ message }) {
957
970
  ] });
958
971
  }
959
972
  function ChannelCard({ channel }) {
973
+ const members = channel.num_members ?? channel.memberCount;
960
974
  return /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2 rounded-lg border border-border bg-card p-3", children: [
961
975
  /* @__PURE__ */ jsx6(Hash, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
962
976
  /* @__PURE__ */ jsx6("span", { className: "text-sm text-foreground flex-1", children: channel.name || channel.id }),
963
- channel.num_members !== void 0 && /* @__PURE__ */ jsxs5("span", { className: "text-xs text-muted-foreground", children: [
964
- channel.num_members,
977
+ members !== void 0 && /* @__PURE__ */ jsxs5("span", { className: "text-xs text-muted-foreground", children: [
978
+ members,
965
979
  " members"
966
980
  ] })
967
981
  ] });
@@ -1334,7 +1348,9 @@ import { Users as Users3, Building2, Mail as Mail3, Phone as Phone2 } from "luci
1334
1348
  import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
1335
1349
  function isHubspotContact(data) {
1336
1350
  if (typeof data !== "object" || data === null) return false;
1337
- const props = data.properties;
1351
+ const d = data;
1352
+ if ("firstName" in d || "lastName" in d || d.email && d.id) return true;
1353
+ const props = d.properties;
1338
1354
  return props && ("firstname" in props || "lastname" in props || "email" in props);
1339
1355
  }
1340
1356
  function isHubspotCompany(data) {
@@ -1344,23 +1360,28 @@ function isHubspotCompany(data) {
1344
1360
  }
1345
1361
  function ContactCard({ contact }) {
1346
1362
  const p = contact.properties || {};
1347
- const name = [p.firstname, p.lastname].filter(Boolean).join(" ") || "Unknown contact";
1363
+ const first = contact.firstName || p.firstname;
1364
+ const last = contact.lastName || p.lastname;
1365
+ const email = contact.email || p.email;
1366
+ const phone = contact.phone || p.phone;
1367
+ const company = contact.company || p.company;
1368
+ const name = [first, last].filter(Boolean).join(" ") || "Unknown contact";
1348
1369
  return /* @__PURE__ */ jsxs12("div", { className: "rounded-lg border border-border bg-card p-3 space-y-1.5", children: [
1349
1370
  /* @__PURE__ */ jsxs12("div", { className: "flex items-start gap-2", children: [
1350
1371
  /* @__PURE__ */ jsx13(Users3, { className: "h-4 w-4 text-muted-foreground mt-0.5 shrink-0" }),
1351
1372
  /* @__PURE__ */ jsxs12("div", { className: "min-w-0 flex-1", children: [
1352
1373
  /* @__PURE__ */ jsx13("p", { className: "text-sm font-medium text-foreground", children: name }),
1353
- p.company && /* @__PURE__ */ jsx13("p", { className: "text-xs text-muted-foreground", children: p.company })
1374
+ company && /* @__PURE__ */ jsx13("p", { className: "text-xs text-muted-foreground", children: company })
1354
1375
  ] })
1355
1376
  ] }),
1356
1377
  /* @__PURE__ */ jsxs12("div", { className: "flex flex-wrap gap-x-4 gap-y-1 pl-6", children: [
1357
- p.email && /* @__PURE__ */ jsxs12("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
1378
+ email && /* @__PURE__ */ jsxs12("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
1358
1379
  /* @__PURE__ */ jsx13(Mail3, { className: "h-3 w-3" }),
1359
- p.email
1380
+ email
1360
1381
  ] }),
1361
- p.phone && /* @__PURE__ */ jsxs12("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
1382
+ phone && /* @__PURE__ */ jsxs12("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
1362
1383
  /* @__PURE__ */ jsx13(Phone2, { className: "h-3 w-3" }),
1363
- p.phone
1384
+ phone
1364
1385
  ] })
1365
1386
  ] })
1366
1387
  ] });
@@ -1401,6 +1422,15 @@ function HubspotFormatter({ data }) {
1401
1422
  return /* @__PURE__ */ jsx13("div", { className: "space-y-2", children: companies.map((c, i) => /* @__PURE__ */ jsx13(CompanyCard, { company: c }, c.id || i)) });
1402
1423
  }
1403
1424
  }
1425
+ if (typeof data === "object" && data !== null && "contacts" in data) {
1426
+ const contacts = data.contacts;
1427
+ if (Array.isArray(contacts)) {
1428
+ const valid = contacts.filter(isHubspotContact);
1429
+ if (valid.length > 0) {
1430
+ return /* @__PURE__ */ jsx13("div", { className: "space-y-2", children: valid.map((c, i) => /* @__PURE__ */ jsx13(ContactCard, { contact: c }, c.id || i)) });
1431
+ }
1432
+ }
1433
+ }
1404
1434
  if (typeof data === "object" && data !== null && "results" in data) {
1405
1435
  const results = data.results;
1406
1436
  if (Array.isArray(results)) {
@@ -1592,6 +1622,21 @@ function PipedriveFormatter({ data }) {
1592
1622
  return /* @__PURE__ */ jsx15("div", { className: "space-y-2", children: deals.map((deal, i) => /* @__PURE__ */ jsx15(DealCard, { deal }, deal.id || i)) });
1593
1623
  }
1594
1624
  }
1625
+ if (typeof data === "object" && data !== null && "deals" in data) {
1626
+ const items = data.deals;
1627
+ if (Array.isArray(items)) {
1628
+ const deals = items.filter(isPipedriveDeal);
1629
+ if (deals.length > 0) {
1630
+ return /* @__PURE__ */ jsx15("div", { className: "space-y-2", children: deals.map((deal, i) => /* @__PURE__ */ jsx15(DealCard, { deal }, deal.id || i)) });
1631
+ }
1632
+ }
1633
+ }
1634
+ if (typeof data === "object" && data !== null && "deal" in data) {
1635
+ const item = data.deal;
1636
+ if (isPipedriveDeal(item)) {
1637
+ return /* @__PURE__ */ jsx15(DealCard, { deal: item });
1638
+ }
1639
+ }
1595
1640
  if (typeof data === "object" && data !== null && "data" in data) {
1596
1641
  const items = data.data;
1597
1642
  if (Array.isArray(items)) {
@@ -1893,11 +1938,16 @@ import { FileText as FileText4, Database, ExternalLink as ExternalLink6, Clock a
1893
1938
  import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
1894
1939
  function isNotionPage(data) {
1895
1940
  if (typeof data !== "object" || data === null) return false;
1896
- return "properties" in data || "id" in data && "url" in data && String(data.url || "").includes("notion");
1941
+ if ("properties" in data) return true;
1942
+ if ("id" in data && "url" in data && String(data.url || "").includes("notion")) return true;
1943
+ if ("title" in data && "id" in data && "parentType" in data) return true;
1944
+ return false;
1897
1945
  }
1898
1946
  function isNotionDatabase(data) {
1899
1947
  if (typeof data !== "object" || data === null) return false;
1900
- return "title" in data && Array.isArray(data.title) && "id" in data;
1948
+ if ("title" in data && Array.isArray(data.title) && "id" in data) return true;
1949
+ if ("title" in data && "id" in data && "propertyCount" in data) return true;
1950
+ return false;
1901
1951
  }
1902
1952
  function extractPageTitle(page) {
1903
1953
  if (page.title) return page.title;
@@ -1940,17 +1990,17 @@ function PageCard({ page }) {
1940
1990
  /* @__PURE__ */ jsx20(FileText4, { className: "h-4 w-4 text-muted-foreground mt-0.5 shrink-0" }),
1941
1991
  /* @__PURE__ */ jsx20("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx20("p", { className: "text-sm font-medium text-foreground truncate", children: page.url ? /* @__PURE__ */ jsx20("a", { href: page.url, target: "_blank", rel: "noopener noreferrer", className: "hover:underline", children: title }) : title }) }),
1942
1992
  /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-1.5 shrink-0", children: [
1943
- page.last_edited_time && /* @__PURE__ */ jsxs19("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
1993
+ (page.last_edited_time || page.lastEditedTime) && /* @__PURE__ */ jsxs19("span", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [
1944
1994
  /* @__PURE__ */ jsx20(Clock3, { className: "h-3 w-3" }),
1945
- formatRelativeDate4(page.last_edited_time)
1995
+ formatRelativeDate4(page.last_edited_time || page.lastEditedTime)
1946
1996
  ] }),
1947
1997
  page.url && /* @__PURE__ */ jsx20("a", { href: page.url, target: "_blank", rel: "noopener noreferrer", className: "text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ jsx20(ExternalLink6, { className: "h-3 w-3" }) })
1948
1998
  ] })
1949
1999
  ] }) });
1950
2000
  }
1951
2001
  function DatabaseCard({ db }) {
1952
- const title = Array.isArray(db.title) && db.title.length > 0 ? db.title.map((t) => t.plain_text || "").join("") : "Untitled database";
1953
- const desc = Array.isArray(db.description) && db.description.length > 0 ? db.description.map((d) => d.plain_text || "").join("") : null;
2002
+ const title = typeof db.title === "string" ? db.title : Array.isArray(db.title) && db.title.length > 0 ? db.title.map((t) => t.plain_text || "").join("") : "Untitled database";
2003
+ const desc = typeof db.description === "string" ? db.description : Array.isArray(db.description) && db.description.length > 0 ? db.description.map((d) => d.plain_text || "").join("") : null;
1954
2004
  return /* @__PURE__ */ jsx20("div", { className: "rounded-lg border border-border bg-card p-3 space-y-1", children: /* @__PURE__ */ jsxs19("div", { className: "flex items-start gap-2", children: [
1955
2005
  /* @__PURE__ */ jsx20(Database, { className: "h-4 w-4 text-muted-foreground mt-0.5 shrink-0" }),
1956
2006
  /* @__PURE__ */ jsxs19("div", { className: "min-w-0 flex-1", children: [