integrate-sdk 0.9.43-dev.0 → 0.9.45-dev.0

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
@@ -1103,7 +1103,7 @@ var INTEGRATION_LIBRARY_METADATA = {
1103
1103
  category: "Finance"
1104
1104
  },
1105
1105
  ga4: {
1106
- description: "Read Google Analytics 4 reports, properties, and events",
1106
+ description: "Read Google Analytics reports, properties, and events",
1107
1107
  category: "Analytics"
1108
1108
  },
1109
1109
  gchat: {
@@ -1671,100 +1671,263 @@ class IndexedDBStorage {
1671
1671
 
1672
1672
  // src/oauth/email-fetcher.ts
1673
1673
  var logger3 = createLogger("EmailFetcher");
1674
+ var EMAIL_FETCHERS = {
1675
+ github: fetchGitHubEmail,
1676
+ gmail: fetchGoogleEmail,
1677
+ google: fetchGoogleEmail,
1678
+ gcal: fetchGoogleEmail,
1679
+ gdrive: fetchGoogleEmail,
1680
+ gdocs: fetchGoogleEmail,
1681
+ gsheets: fetchGoogleEmail,
1682
+ gslides: fetchGoogleEmail,
1683
+ gcontacts: fetchGoogleEmail,
1684
+ gmeet: fetchGoogleEmail,
1685
+ gchat: fetchGoogleEmail,
1686
+ gtasks: fetchGoogleEmail,
1687
+ ga4: fetchGoogleEmail,
1688
+ youtube: fetchGoogleEmail,
1689
+ notion: fetchNotionEmail,
1690
+ linear: fetchLinearEmail,
1691
+ hubspot: fetchHubSpotEmail,
1692
+ polar: fetchPolarEmail,
1693
+ todoist: fetchTodoistEmail,
1694
+ vercel: fetchVercelEmail,
1695
+ slack: fetchSlackEmail,
1696
+ intercom: fetchIntercomEmail,
1697
+ jira: fetchAtlassianEmail,
1698
+ zendesk: fetchZendeskEmail,
1699
+ airtable: fetchAirtableEmail,
1700
+ discord: fetchDiscordEmail,
1701
+ dropbox: fetchDropboxEmail,
1702
+ gitlab: fetchGitLabEmail,
1703
+ reddit: fetchRedditEmail,
1704
+ outlook: fetchMicrosoftEmail,
1705
+ teams: fetchMicrosoftEmail,
1706
+ onedrive: fetchMicrosoftEmail,
1707
+ sharepoint: fetchMicrosoftEmail,
1708
+ excel: fetchMicrosoftEmail,
1709
+ word: fetchMicrosoftEmail,
1710
+ powerpoint: fetchMicrosoftEmail,
1711
+ planner: fetchMicrosoftEmail
1712
+ };
1674
1713
  async function fetchUserEmail(provider, tokenData) {
1714
+ const fetcher = EMAIL_FETCHERS[provider.toLowerCase()];
1715
+ if (!fetcher) {
1716
+ return tokenData.email;
1717
+ }
1675
1718
  try {
1676
- switch (provider.toLowerCase()) {
1677
- case "github":
1678
- return await fetchGitHubEmail(tokenData.accessToken);
1679
- case "gmail":
1680
- case "google":
1681
- return await fetchGoogleEmail(tokenData.accessToken);
1682
- case "notion":
1683
- return await fetchNotionEmail(tokenData.accessToken);
1684
- default:
1685
- return tokenData.email;
1686
- }
1719
+ const email = await fetcher(tokenData);
1720
+ return email ?? tokenData.email;
1687
1721
  } catch (error) {
1688
1722
  logger3.error(`Failed to fetch email for ${provider}:`, error);
1689
- return;
1723
+ return tokenData.email;
1690
1724
  }
1691
1725
  }
1692
- async function fetchGitHubEmail(accessToken) {
1693
- try {
1694
- const userResponse = await fetch("https://api.github.com/user", {
1695
- headers: {
1696
- Authorization: `Bearer ${accessToken}`,
1697
- Accept: "application/vnd.github.v3+json"
1698
- }
1699
- });
1700
- if (!userResponse.ok) {
1701
- return;
1702
- }
1703
- const user = await userResponse.json();
1704
- if (user.email) {
1705
- return user.email;
1706
- }
1707
- const emailsResponse = await fetch("https://api.github.com/user/emails", {
1708
- headers: {
1709
- Authorization: `Bearer ${accessToken}`,
1710
- Accept: "application/vnd.github.v3+json"
1711
- }
1712
- });
1713
- if (!emailsResponse.ok) {
1714
- return;
1715
- }
1716
- const emails = await emailsResponse.json();
1717
- const primaryEmail = emails.find((e) => e.primary && e.verified);
1718
- if (primaryEmail) {
1719
- return primaryEmail.email;
1726
+ async function fetchGitHubEmail(token) {
1727
+ const headers = {
1728
+ Authorization: `Bearer ${token.accessToken}`,
1729
+ Accept: "application/vnd.github.v3+json"
1730
+ };
1731
+ const userResponse = await fetch("https://api.github.com/user", { headers });
1732
+ if (!userResponse.ok)
1733
+ return;
1734
+ const user = await userResponse.json();
1735
+ if (user.email)
1736
+ return user.email;
1737
+ const emailsResponse = await fetch("https://api.github.com/user/emails", { headers });
1738
+ if (!emailsResponse.ok)
1739
+ return;
1740
+ const emails = await emailsResponse.json();
1741
+ const primary = emails.find((e) => e.primary && e.verified);
1742
+ if (primary)
1743
+ return primary.email;
1744
+ const verified = emails.find((e) => e.verified);
1745
+ if (verified)
1746
+ return verified.email;
1747
+ return emails[0]?.email;
1748
+ }
1749
+ async function fetchGoogleEmail(token) {
1750
+ const response = await fetch("https://www.googleapis.com/oauth2/v2/userinfo", {
1751
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1752
+ });
1753
+ if (!response.ok)
1754
+ return;
1755
+ const user = await response.json();
1756
+ return user.email;
1757
+ }
1758
+ async function fetchNotionEmail(token) {
1759
+ const response = await fetch("https://api.notion.com/v1/users/me", {
1760
+ headers: {
1761
+ Authorization: `Bearer ${token.accessToken}`,
1762
+ "Notion-Version": "2022-06-28"
1720
1763
  }
1721
- const verifiedEmail = emails.find((e) => e.verified);
1722
- if (verifiedEmail) {
1723
- return verifiedEmail.email;
1764
+ });
1765
+ if (!response.ok)
1766
+ return;
1767
+ const user = await response.json();
1768
+ return user.person?.email ?? user.bot?.owner?.user?.person?.email;
1769
+ }
1770
+ async function fetchLinearEmail(token) {
1771
+ const response = await fetch("https://api.linear.app/graphql", {
1772
+ method: "POST",
1773
+ headers: {
1774
+ Authorization: `Bearer ${token.accessToken}`,
1775
+ "Content-Type": "application/json"
1776
+ },
1777
+ body: JSON.stringify({ query: "{ viewer { email } }" })
1778
+ });
1779
+ if (!response.ok)
1780
+ return;
1781
+ const body = await response.json();
1782
+ return body.data?.viewer?.email;
1783
+ }
1784
+ async function fetchHubSpotEmail(token) {
1785
+ const url = `https://api.hubapi.com/oauth/v1/access-tokens/${encodeURIComponent(token.accessToken)}`;
1786
+ const response = await fetch(url);
1787
+ if (!response.ok)
1788
+ return;
1789
+ const body = await response.json();
1790
+ return body.user;
1791
+ }
1792
+ async function fetchPolarEmail(token) {
1793
+ const response = await fetch("https://api.polar.sh/v1/oauth2/userinfo", {
1794
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1795
+ });
1796
+ if (!response.ok)
1797
+ return;
1798
+ const body = await response.json();
1799
+ return body.email;
1800
+ }
1801
+ async function fetchTodoistEmail(token) {
1802
+ const response = await fetch("https://api.todoist.com/sync/v9/sync", {
1803
+ method: "POST",
1804
+ headers: {
1805
+ Authorization: `Bearer ${token.accessToken}`,
1806
+ "Content-Type": "application/x-www-form-urlencoded"
1807
+ },
1808
+ body: 'sync_token=*&resource_types=["user"]'
1809
+ });
1810
+ if (!response.ok)
1811
+ return;
1812
+ const body = await response.json();
1813
+ return body.user?.email;
1814
+ }
1815
+ async function fetchVercelEmail(token) {
1816
+ const response = await fetch("https://api.vercel.com/v2/user", {
1817
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1818
+ });
1819
+ if (!response.ok)
1820
+ return;
1821
+ const body = await response.json();
1822
+ return body.user?.email ?? body.email;
1823
+ }
1824
+ async function fetchSlackEmail(token) {
1825
+ const response = await fetch("https://slack.com/api/users.identity", {
1826
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1827
+ });
1828
+ if (!response.ok)
1829
+ return;
1830
+ const body = await response.json();
1831
+ if (!body.ok)
1832
+ return;
1833
+ return body.user?.email;
1834
+ }
1835
+ async function fetchIntercomEmail(token) {
1836
+ const response = await fetch("https://api.intercom.io/me", {
1837
+ headers: {
1838
+ Authorization: `Bearer ${token.accessToken}`,
1839
+ Accept: "application/json"
1724
1840
  }
1725
- if (emails.length > 0 && emails[0]?.email) {
1726
- return emails[0].email;
1841
+ });
1842
+ if (!response.ok)
1843
+ return;
1844
+ const body = await response.json();
1845
+ return body.email;
1846
+ }
1847
+ async function fetchAtlassianEmail(token) {
1848
+ const response = await fetch("https://api.atlassian.com/me", {
1849
+ headers: {
1850
+ Authorization: `Bearer ${token.accessToken}`,
1851
+ Accept: "application/json"
1727
1852
  }
1853
+ });
1854
+ if (!response.ok)
1728
1855
  return;
1729
- } catch (error) {
1730
- logger3.error("Failed to fetch GitHub email:", error);
1856
+ const body = await response.json();
1857
+ return body.email;
1858
+ }
1859
+ async function fetchZendeskEmail(token) {
1860
+ const subdomain = token.providerConfig?.subdomain?.trim();
1861
+ if (!subdomain)
1731
1862
  return;
1732
- }
1863
+ const response = await fetch(`https://${subdomain}.zendesk.com/api/v2/users/me.json`, {
1864
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1865
+ });
1866
+ if (!response.ok)
1867
+ return;
1868
+ const body = await response.json();
1869
+ return body.user?.email;
1733
1870
  }
1734
- async function fetchGoogleEmail(accessToken) {
1735
- try {
1736
- const response = await fetch("https://www.googleapis.com/oauth2/v2/userinfo", {
1737
- headers: {
1738
- Authorization: `Bearer ${accessToken}`
1739
- }
1740
- });
1741
- if (!response.ok) {
1742
- return;
1743
- }
1744
- const user = await response.json();
1745
- return user.email;
1746
- } catch (error) {
1747
- logger3.error("Failed to fetch Google email:", error);
1871
+ async function fetchAirtableEmail(token) {
1872
+ const response = await fetch("https://api.airtable.com/v0/meta/whoami", {
1873
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1874
+ });
1875
+ if (!response.ok)
1748
1876
  return;
1749
- }
1877
+ const body = await response.json();
1878
+ return body.email;
1750
1879
  }
1751
- async function fetchNotionEmail(accessToken) {
1752
- try {
1753
- const response = await fetch("https://api.notion.com/v1/users/me", {
1754
- headers: {
1755
- Authorization: `Bearer ${accessToken}`,
1756
- "Notion-Version": "2022-06-28"
1757
- }
1758
- });
1759
- if (!response.ok) {
1760
- return;
1880
+ async function fetchDiscordEmail(token) {
1881
+ const response = await fetch("https://discord.com/api/users/@me", {
1882
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1883
+ });
1884
+ if (!response.ok)
1885
+ return;
1886
+ const body = await response.json();
1887
+ return body.email;
1888
+ }
1889
+ async function fetchDropboxEmail(token) {
1890
+ const response = await fetch("https://api.dropboxapi.com/2/users/get_current_account", {
1891
+ method: "POST",
1892
+ headers: {
1893
+ Authorization: `Bearer ${token.accessToken}`
1894
+ },
1895
+ body: "null"
1896
+ });
1897
+ if (!response.ok)
1898
+ return;
1899
+ const body = await response.json();
1900
+ return body.email;
1901
+ }
1902
+ async function fetchGitLabEmail(token) {
1903
+ const response = await fetch("https://gitlab.com/api/v4/user", {
1904
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1905
+ });
1906
+ if (!response.ok)
1907
+ return;
1908
+ const body = await response.json();
1909
+ return body.email;
1910
+ }
1911
+ async function fetchRedditEmail(token) {
1912
+ const response = await fetch("https://oauth.reddit.com/api/v1/me", {
1913
+ headers: {
1914
+ Authorization: `Bearer ${token.accessToken}`,
1915
+ "User-Agent": "integrate-sdk"
1761
1916
  }
1762
- const user = await response.json();
1763
- return user.person?.email;
1764
- } catch (error) {
1765
- logger3.error("Failed to fetch Notion email:", error);
1917
+ });
1918
+ if (!response.ok)
1766
1919
  return;
1767
- }
1920
+ const body = await response.json();
1921
+ return body.name;
1922
+ }
1923
+ async function fetchMicrosoftEmail(token) {
1924
+ const response = await fetch("https://graph.microsoft.com/v1.0/me", {
1925
+ headers: { Authorization: `Bearer ${token.accessToken}` }
1926
+ });
1927
+ if (!response.ok)
1928
+ return;
1929
+ const body = await response.json();
1930
+ return body.mail ?? body.userPrincipalName;
1768
1931
  }
1769
1932
 
1770
1933
  // src/oauth/refresh.ts
@@ -5814,6 +5977,7 @@ function plannerIntegration(config = {}) {
5814
5977
  return {
5815
5978
  id: "planner",
5816
5979
  name: "Microsoft Planner",
5980
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/microsoft_planner.png",
5817
5981
  tools: [...PLANNER_TOOLS],
5818
5982
  oauth
5819
5983
  };
@@ -8124,6 +8288,7 @@ function mailchimpIntegration(config = {}) {
8124
8288
  return {
8125
8289
  id: "mailchimp",
8126
8290
  name: "Mailchimp",
8291
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/mailchimp.png",
8127
8292
  tools: [...MAILCHIMP_TOOLS],
8128
8293
  oauth
8129
8294
  };
@@ -8581,6 +8746,7 @@ function clickupIntegration(config = {}) {
8581
8746
  return {
8582
8747
  id: "clickup",
8583
8748
  name: "ClickUp",
8749
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/clickup.png",
8584
8750
  tools: [...CLICKUP_TOOLS],
8585
8751
  oauth,
8586
8752
  async onInit(_client) {
@@ -8654,7 +8820,8 @@ function ga4Integration(config = {}) {
8654
8820
  };
8655
8821
  return {
8656
8822
  id: "ga4",
8657
- name: "Google Analytics 4",
8823
+ name: "Google Analytics",
8824
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/google_analytics.png",
8658
8825
  tools: [...GA4_TOOLS],
8659
8826
  oauth
8660
8827
  };
@@ -8867,6 +9034,7 @@ function planetscaleIntegration(config = {}) {
8867
9034
  id: "planetscale",
8868
9035
  name: "PlanetScale",
8869
9036
  category: "Infrastructure",
9037
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/planetscale.png",
8870
9038
  tools: [...PLANETSCALE_TOOLS],
8871
9039
  oauth
8872
9040
  };
@@ -8931,6 +9099,7 @@ function redditIntegration(config = {}) {
8931
9099
  return {
8932
9100
  id: "reddit",
8933
9101
  name: "Reddit",
9102
+ logoUrl: "https://wdvtnli2jn3texa6.public.blob.vercel-storage.com/reddit.png",
8934
9103
  tools: [...REDDIT_TOOLS],
8935
9104
  oauth
8936
9105
  };