integrate-sdk 0.8.42 → 0.8.44-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.
Files changed (97) hide show
  1. package/dist/adapters/auto-routes.d.ts.map +1 -1
  2. package/dist/adapters/auto-routes.js +309 -143
  3. package/dist/adapters/base-handler.d.ts.map +1 -1
  4. package/dist/adapters/index.js +305 -141
  5. package/dist/adapters/nextjs-oauth-redirect.d.ts.map +1 -1
  6. package/dist/adapters/nextjs-oauth-redirect.js +47 -2
  7. package/dist/adapters/nextjs.d.ts.map +1 -1
  8. package/dist/adapters/nextjs.js +304 -141
  9. package/dist/adapters/node.js +304 -141
  10. package/dist/adapters/svelte-kit.js +304 -141
  11. package/dist/adapters/tanstack-start.js +304 -141
  12. package/dist/index.d.ts +19 -40
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +319 -183
  15. package/dist/oauth.js +309 -143
  16. package/dist/react.js +59 -14
  17. package/dist/server.js +308 -141
  18. package/dist/src/adapters/auto-routes.d.ts.map +1 -1
  19. package/dist/src/adapters/base-handler.d.ts.map +1 -1
  20. package/dist/src/adapters/nextjs-oauth-redirect.d.ts.map +1 -1
  21. package/dist/src/adapters/nextjs.d.ts.map +1 -1
  22. package/dist/src/client.d.ts.map +1 -1
  23. package/dist/src/config/types.d.ts +15 -0
  24. package/dist/src/config/types.d.ts.map +1 -1
  25. package/dist/src/integrations/airtable.d.ts.map +1 -1
  26. package/dist/src/integrations/calcom.d.ts.map +1 -1
  27. package/dist/src/integrations/cursor.d.ts.map +1 -1
  28. package/dist/src/integrations/figma.d.ts.map +1 -1
  29. package/dist/src/integrations/gcal.d.ts.map +1 -1
  30. package/dist/src/integrations/github.d.ts.map +1 -1
  31. package/dist/src/integrations/gmail.d.ts.map +1 -1
  32. package/dist/src/integrations/gworkspace.d.ts.map +1 -1
  33. package/dist/src/integrations/hubspot.d.ts.map +1 -1
  34. package/dist/src/integrations/intercom.d.ts.map +1 -1
  35. package/dist/src/integrations/linear.d.ts.map +1 -1
  36. package/dist/src/integrations/notion.d.ts.map +1 -1
  37. package/dist/src/integrations/onedrive.d.ts.map +1 -1
  38. package/dist/src/integrations/outlook.d.ts.map +1 -1
  39. package/dist/src/integrations/polar.d.ts.map +1 -1
  40. package/dist/src/integrations/ramp.d.ts.map +1 -1
  41. package/dist/src/integrations/server-client.d.ts +15 -1
  42. package/dist/src/integrations/server-client.d.ts.map +1 -1
  43. package/dist/src/integrations/slack.d.ts.map +1 -1
  44. package/dist/src/integrations/stripe.d.ts.map +1 -1
  45. package/dist/src/integrations/todoist.d.ts.map +1 -1
  46. package/dist/src/integrations/vercel.d.ts.map +1 -1
  47. package/dist/src/integrations/whatsapp.d.ts.map +1 -1
  48. package/dist/src/integrations/youtube.d.ts.map +1 -1
  49. package/dist/src/integrations/zendesk.d.ts.map +1 -1
  50. package/dist/src/oauth/email-fetcher.d.ts.map +1 -1
  51. package/dist/src/oauth/manager.d.ts.map +1 -1
  52. package/dist/src/oauth/window-manager.d.ts.map +1 -1
  53. package/dist/src/react/hooks.d.ts.map +1 -1
  54. package/dist/src/server.d.ts.map +1 -1
  55. package/dist/src/transport/http-session.d.ts.map +1 -1
  56. package/dist/src/transport/http-stream.d.ts.map +1 -1
  57. package/dist/src/utils/logger.d.ts +37 -0
  58. package/dist/src/utils/logger.d.ts.map +1 -0
  59. package/index.ts +20 -72
  60. package/package.json +2 -2
  61. package/dist/adapters/base-handler.js +0 -561
  62. package/dist/ai/cloudflare.d.ts +0 -158
  63. package/dist/ai/cloudflare.d.ts.map +0 -1
  64. package/dist/ai/cloudflare.js +0 -4249
  65. package/dist/ai/langchain.d.ts +0 -139
  66. package/dist/ai/langchain.d.ts.map +0 -1
  67. package/dist/ai/langchain.js +0 -4237
  68. package/dist/ai/llamaindex.d.ts +0 -125
  69. package/dist/ai/llamaindex.d.ts.map +0 -1
  70. package/dist/ai/llamaindex.js +0 -4236
  71. package/dist/ai/mastra.d.ts +0 -138
  72. package/dist/ai/mastra.d.ts.map +0 -1
  73. package/dist/ai/mastra.js +0 -4240
  74. package/dist/src/ai/cloudflare.d.ts +0 -158
  75. package/dist/src/ai/cloudflare.d.ts.map +0 -1
  76. package/dist/src/ai/langchain.d.ts +0 -139
  77. package/dist/src/ai/langchain.d.ts.map +0 -1
  78. package/dist/src/ai/llamaindex.d.ts +0 -125
  79. package/dist/src/ai/llamaindex.d.ts.map +0 -1
  80. package/dist/src/ai/mastra.d.ts +0 -138
  81. package/dist/src/ai/mastra.d.ts.map +0 -1
  82. package/dist/src/integrations/vercel-ai.d.ts +0 -127
  83. package/dist/src/integrations/vercel-ai.d.ts.map +0 -1
  84. package/dist/src/plugins/generic.d.ts +0 -99
  85. package/dist/src/plugins/generic.d.ts.map +0 -1
  86. package/dist/src/plugins/github-client.d.ts +0 -320
  87. package/dist/src/plugins/github-client.d.ts.map +0 -1
  88. package/dist/src/plugins/github.d.ts +0 -89
  89. package/dist/src/plugins/github.d.ts.map +0 -1
  90. package/dist/src/plugins/gmail-client.d.ts +0 -106
  91. package/dist/src/plugins/gmail-client.d.ts.map +0 -1
  92. package/dist/src/plugins/gmail.d.ts +0 -87
  93. package/dist/src/plugins/gmail.d.ts.map +0 -1
  94. package/dist/src/plugins/server-client.d.ts +0 -18
  95. package/dist/src/plugins/server-client.d.ts.map +0 -1
  96. package/dist/src/plugins/types.d.ts +0 -70
  97. package/dist/src/plugins/types.d.ts.map +0 -1
package/dist/react.js CHANGED
@@ -10,8 +10,53 @@ var __export = (target, all) => {
10
10
  };
11
11
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
12
12
 
13
+ // src/utils/logger.ts
14
+ function shouldLog(level) {
15
+ return logLevelHierarchy[level] <= logLevelHierarchy[globalLogLevel];
16
+ }
17
+ function setLogLevel(level) {
18
+ globalLogLevel = level;
19
+ }
20
+ function createLogger(namespace) {
21
+ const prefix = `[${namespace}]`;
22
+ return {
23
+ debug: (...args) => {
24
+ if (shouldLog("debug")) {
25
+ console.log(prefix, ...args);
26
+ }
27
+ },
28
+ info: (...args) => {
29
+ if (shouldLog("info")) {
30
+ console.log(prefix, ...args);
31
+ }
32
+ },
33
+ warn: (...args) => {
34
+ if (shouldLog("warn")) {
35
+ console.warn(prefix, ...args);
36
+ }
37
+ },
38
+ error: (...args) => {
39
+ if (shouldLog("error")) {
40
+ console.error(prefix, ...args);
41
+ }
42
+ }
43
+ };
44
+ }
45
+ var globalLogLevel = "error", logLevelHierarchy;
46
+ var init_logger = __esm(() => {
47
+ logLevelHierarchy = {
48
+ none: 0,
49
+ error: 1,
50
+ warn: 2,
51
+ info: 3,
52
+ debug: 4
53
+ };
54
+ });
55
+
13
56
  // src/react/hooks.ts
57
+ init_logger();
14
58
  import { useState, useEffect } from "react";
59
+ var logger = createLogger("ReactHooks");
15
60
  function getSafeFallback() {
16
61
  return {
17
62
  tokens: {},
@@ -32,7 +77,7 @@ function isReactHooksAvailable() {
32
77
  }
33
78
  function useIntegrateTokens(client) {
34
79
  if (!isReactHooksAvailable()) {
35
- console.warn("[useIntegrateTokens] React hooks are not available. " + "This can happen during SSR, before React initialization, or in Suspense boundaries. " + "Returning safe fallback values.");
80
+ logger.warn("[useIntegrateTokens] React hooks are not available. " + "This can happen during SSR, before React initialization, or in Suspense boundaries. " + "Returning safe fallback values.");
36
81
  return getSafeFallback();
37
82
  }
38
83
  if (!client) {
@@ -51,7 +96,7 @@ function useIntegrateTokens(client) {
51
96
  setTokens(currentTokens);
52
97
  setIsLoading(false);
53
98
  } catch (error) {
54
- console.error("[useIntegrateTokens] Failed to get provider tokens:", error);
99
+ logger.error("[useIntegrateTokens] Failed to get provider tokens:", error);
55
100
  setIsLoading(false);
56
101
  }
57
102
  };
@@ -74,7 +119,7 @@ function useIntegrateTokens(client) {
74
119
  client.off("auth:logout", handleAuthLogout);
75
120
  };
76
121
  } catch (error) {
77
- console.error("[useIntegrateTokens] Error setting up hook:", error);
122
+ logger.error("[useIntegrateTokens] Error setting up hook:", error);
78
123
  setIsLoading(false);
79
124
  return;
80
125
  }
@@ -89,7 +134,7 @@ function useIntegrateAI(client, options = {}) {
89
134
  useEffect(() => {
90
135
  if (!client || typeof window === "undefined") {
91
136
  if (debug && !client) {
92
- console.warn("[useIntegrateAI] No client provided, skipping interceptor setup");
137
+ logger.warn("[useIntegrateAI] No client provided, skipping interceptor setup");
93
138
  }
94
139
  return;
95
140
  }
@@ -98,25 +143,25 @@ function useIntegrateAI(client, options = {}) {
98
143
  try {
99
144
  currentTokens = client.getAllProviderTokens();
100
145
  if (debug) {
101
- console.log("[useIntegrateAI] Initial tokens loaded:", Object.keys(currentTokens));
146
+ logger.debug("[useIntegrateAI] Initial tokens loaded:", Object.keys(currentTokens));
102
147
  }
103
148
  } catch (error) {
104
- console.error("[useIntegrateAI] Failed to get initial tokens:", error);
149
+ logger.error("[useIntegrateAI] Failed to get initial tokens:", error);
105
150
  }
106
151
  const updateTokens = () => {
107
152
  try {
108
153
  currentTokens = client.getAllProviderTokens();
109
154
  if (debug) {
110
- console.log("[useIntegrateAI] Tokens updated:", Object.keys(currentTokens));
155
+ logger.debug("[useIntegrateAI] Tokens updated:", Object.keys(currentTokens));
111
156
  }
112
157
  } catch (error) {
113
- console.error("[useIntegrateAI] Failed to update tokens:", error);
158
+ logger.error("[useIntegrateAI] Failed to update tokens:", error);
114
159
  }
115
160
  };
116
161
  const handleLogout = () => {
117
162
  currentTokens = {};
118
163
  if (debug) {
119
- console.log("[useIntegrateAI] Tokens cleared (logout)");
164
+ logger.debug("[useIntegrateAI] Tokens cleared (logout)");
120
165
  }
121
166
  };
122
167
  client.on("auth:complete", updateTokens);
@@ -127,8 +172,8 @@ function useIntegrateAI(client, options = {}) {
127
172
  const shouldIntercept = typeof apiPattern === "string" ? url.includes(apiPattern) : apiPattern.test(url);
128
173
  if (shouldIntercept && Object.keys(currentTokens).length > 0) {
129
174
  if (debug) {
130
- console.log("[useIntegrateAI] Intercepting request to:", url);
131
- console.log("[useIntegrateAI] Injecting tokens:", Object.keys(currentTokens));
175
+ logger.debug("[useIntegrateAI] Intercepting request to:", url);
176
+ logger.debug("[useIntegrateAI] Injecting tokens:", Object.keys(currentTokens));
132
177
  }
133
178
  const headers = new Headers(init?.headers);
134
179
  headers.set("x-integrate-tokens", JSON.stringify(currentTokens));
@@ -141,8 +186,8 @@ function useIntegrateAI(client, options = {}) {
141
186
  };
142
187
  window.fetch = interceptedFetch;
143
188
  if (debug) {
144
- console.log("[useIntegrateAI] Global fetch interceptor installed");
145
- console.log("[useIntegrateAI] Pattern:", apiPattern);
189
+ logger.debug("[useIntegrateAI] Global fetch interceptor installed");
190
+ logger.debug("[useIntegrateAI] Pattern:", apiPattern);
146
191
  }
147
192
  return () => {
148
193
  window.fetch = originalFetch;
@@ -150,7 +195,7 @@ function useIntegrateAI(client, options = {}) {
150
195
  client.off("auth:disconnect", updateTokens);
151
196
  client.off("auth:logout", handleLogout);
152
197
  if (debug) {
153
- console.log("[useIntegrateAI] Global fetch interceptor removed");
198
+ logger.debug("[useIntegrateAI] Global fetch interceptor removed");
154
199
  }
155
200
  };
156
201
  }, [client, apiPattern, debug]);