@squadbase/vite-server 0.1.3-dev.1 → 0.1.3-dev.10
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/cli/index.js +71031 -6800
- package/dist/connectors/airtable-oauth.js +77 -3
- package/dist/connectors/airtable.js +85 -2
- package/dist/connectors/amplitude.js +85 -2
- package/dist/connectors/anthropic.js +85 -2
- package/dist/connectors/asana.js +86 -3
- package/dist/connectors/attio.js +85 -2
- package/dist/connectors/customerio.js +86 -3
- package/dist/connectors/dbt.js +85 -2
- package/dist/connectors/gemini.js +86 -3
- package/dist/connectors/gmail-oauth.js +78 -4
- package/dist/connectors/gmail.d.ts +5 -0
- package/dist/connectors/gmail.js +875 -0
- package/dist/connectors/google-ads-oauth.js +78 -4
- package/dist/connectors/google-ads.js +85 -2
- package/dist/connectors/google-analytics-oauth.js +90 -8
- package/dist/connectors/google-analytics.js +85 -2
- package/dist/connectors/google-calendar-oauth.d.ts +5 -0
- package/dist/connectors/google-calendar-oauth.js +817 -0
- package/dist/connectors/google-calendar.d.ts +5 -0
- package/dist/connectors/google-calendar.js +991 -0
- package/dist/connectors/google-sheets-oauth.js +144 -33
- package/dist/connectors/google-sheets.js +119 -10
- package/dist/connectors/{microsoft-teams.d.ts → grafana.d.ts} +1 -1
- package/dist/connectors/grafana.js +638 -0
- package/dist/connectors/hubspot-oauth.js +77 -3
- package/dist/connectors/hubspot.js +79 -5
- package/dist/connectors/intercom-oauth.js +78 -4
- package/dist/connectors/intercom.js +86 -3
- package/dist/connectors/jira-api-key.js +84 -9
- package/dist/connectors/kintone-api-token.js +77 -3
- package/dist/connectors/kintone.js +86 -3
- package/dist/connectors/linkedin-ads-oauth.js +78 -4
- package/dist/connectors/linkedin-ads.js +86 -3
- package/dist/connectors/mailchimp-oauth.js +77 -3
- package/dist/connectors/mailchimp.js +86 -3
- package/dist/connectors/{microsoft-teams-oauth.d.ts → notion-oauth.d.ts} +1 -1
- package/dist/connectors/notion-oauth.js +567 -0
- package/dist/connectors/{slack.d.ts → notion.d.ts} +1 -1
- package/dist/connectors/notion.js +663 -0
- package/dist/connectors/openai.js +85 -2
- package/dist/connectors/shopify-oauth.js +77 -3
- package/dist/connectors/shopify.js +85 -2
- package/dist/connectors/stripe-api-key.d.ts +5 -0
- package/dist/connectors/stripe-api-key.js +600 -0
- package/dist/connectors/stripe-oauth.js +77 -3
- package/dist/connectors/wix-store.js +85 -2
- package/dist/connectors/zendesk-oauth.js +78 -4
- package/dist/connectors/zendesk.js +86 -3
- package/dist/index.js +75373 -8431
- package/dist/main.js +75359 -8417
- package/dist/vite-plugin.js +75210 -8305
- package/package.json +46 -2
- package/dist/connectors/microsoft-teams-oauth.js +0 -479
- package/dist/connectors/microsoft-teams.js +0 -381
- package/dist/connectors/slack.js +0 -362
|
@@ -275,6 +275,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
+
// ../connectors/src/auth-types.ts
|
|
279
|
+
var AUTH_TYPES = {
|
|
280
|
+
OAUTH: "oauth",
|
|
281
|
+
API_KEY: "api-key",
|
|
282
|
+
JWT: "jwt",
|
|
283
|
+
SERVICE_ACCOUNT: "service-account",
|
|
284
|
+
PAT: "pat",
|
|
285
|
+
USER_PASSWORD: "user-password"
|
|
286
|
+
};
|
|
287
|
+
|
|
278
288
|
// ../connectors/src/connectors/customerio/setup.ts
|
|
279
289
|
var customerioOnboarding = new ConnectorOnboarding({
|
|
280
290
|
dataOverviewInstructions: {
|
|
@@ -387,10 +397,10 @@ The App API is the read and management path for Customer.io data.`,
|
|
|
387
397
|
var tools = { request: requestTool };
|
|
388
398
|
var customerioConnector = new ConnectorPlugin({
|
|
389
399
|
slug: "customerio",
|
|
390
|
-
authType:
|
|
400
|
+
authType: AUTH_TYPES.API_KEY,
|
|
391
401
|
name: "Customer.io",
|
|
392
402
|
description: "Connect to Customer.io App API for reading customer data, managing campaigns, segments, and sending transactional messages.",
|
|
393
|
-
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/
|
|
403
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/nngohabT7oHDIgQYAVBpz/6f6c7662ef4692eb9869e3e69dd57114/customerio.png",
|
|
394
404
|
parameters,
|
|
395
405
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
396
406
|
onboarding: customerioOnboarding,
|
|
@@ -589,6 +599,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
589
599
|
return process.env[envVarName] || void 0;
|
|
590
600
|
}
|
|
591
601
|
|
|
602
|
+
// src/connector-client/proxy-fetch.ts
|
|
603
|
+
import { getContext } from "hono/context-storage";
|
|
604
|
+
import { getCookie } from "hono/cookie";
|
|
605
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
606
|
+
function createSandboxProxyFetch(connectionId) {
|
|
607
|
+
return async (input, init) => {
|
|
608
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
609
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
610
|
+
if (!token || !sandboxId) {
|
|
611
|
+
throw new Error(
|
|
612
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
616
|
+
const originalMethod = init?.method ?? "GET";
|
|
617
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
618
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
619
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
620
|
+
return fetch(proxyUrl, {
|
|
621
|
+
method: "POST",
|
|
622
|
+
headers: {
|
|
623
|
+
"Content-Type": "application/json",
|
|
624
|
+
Authorization: `Bearer ${token}`
|
|
625
|
+
},
|
|
626
|
+
body: JSON.stringify({
|
|
627
|
+
url: originalUrl,
|
|
628
|
+
method: originalMethod,
|
|
629
|
+
body: originalBody
|
|
630
|
+
})
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
635
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
636
|
+
if (!projectId) {
|
|
637
|
+
throw new Error(
|
|
638
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
642
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
643
|
+
return async (input, init) => {
|
|
644
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
645
|
+
const originalMethod = init?.method ?? "GET";
|
|
646
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
647
|
+
const c = getContext();
|
|
648
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
649
|
+
if (!appSession) {
|
|
650
|
+
throw new Error(
|
|
651
|
+
"No authentication method available for connection proxy."
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
return fetch(proxyUrl, {
|
|
655
|
+
method: "POST",
|
|
656
|
+
headers: {
|
|
657
|
+
"Content-Type": "application/json",
|
|
658
|
+
Authorization: `Bearer ${appSession}`
|
|
659
|
+
},
|
|
660
|
+
body: JSON.stringify({
|
|
661
|
+
url: originalUrl,
|
|
662
|
+
method: originalMethod,
|
|
663
|
+
body: originalBody
|
|
664
|
+
})
|
|
665
|
+
});
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function createProxyFetch(connectionId) {
|
|
669
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
670
|
+
return createSandboxProxyFetch(connectionId);
|
|
671
|
+
}
|
|
672
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
673
|
+
}
|
|
674
|
+
|
|
592
675
|
// src/connectors/create-connector-sdk.ts
|
|
593
676
|
function loadConnectionsSync() {
|
|
594
677
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -622,7 +705,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
622
705
|
if (val !== void 0) params[param.slug] = val;
|
|
623
706
|
}
|
|
624
707
|
}
|
|
625
|
-
return createClient2(params);
|
|
708
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
626
709
|
};
|
|
627
710
|
}
|
|
628
711
|
|
package/dist/connectors/dbt.js
CHANGED
|
@@ -417,6 +417,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
419
|
|
|
420
|
+
// ../connectors/src/auth-types.ts
|
|
421
|
+
var AUTH_TYPES = {
|
|
422
|
+
OAUTH: "oauth",
|
|
423
|
+
API_KEY: "api-key",
|
|
424
|
+
JWT: "jwt",
|
|
425
|
+
SERVICE_ACCOUNT: "service-account",
|
|
426
|
+
PAT: "pat",
|
|
427
|
+
USER_PASSWORD: "user-password"
|
|
428
|
+
};
|
|
429
|
+
|
|
420
430
|
// ../connectors/src/connectors/dbt/setup.ts
|
|
421
431
|
var dbtOnboarding = new ConnectorOnboarding({
|
|
422
432
|
dataOverviewInstructions: {
|
|
@@ -518,7 +528,7 @@ Authentication is handled automatically using the API token.
|
|
|
518
528
|
var tools = { request: requestTool };
|
|
519
529
|
var dbtConnector = new ConnectorPlugin({
|
|
520
530
|
slug: "dbt",
|
|
521
|
-
authType:
|
|
531
|
+
authType: AUTH_TYPES.API_KEY,
|
|
522
532
|
name: "dbt",
|
|
523
533
|
description: "Connect to dbt Cloud for data transformation and analytics engineering.",
|
|
524
534
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4iT6ncXtdtHdkXexU0WgfZ/0367a38d245f2568eab5eb511f9ee692/dbt.png",
|
|
@@ -770,6 +780,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
770
780
|
return process.env[envVarName] || void 0;
|
|
771
781
|
}
|
|
772
782
|
|
|
783
|
+
// src/connector-client/proxy-fetch.ts
|
|
784
|
+
import { getContext } from "hono/context-storage";
|
|
785
|
+
import { getCookie } from "hono/cookie";
|
|
786
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
787
|
+
function createSandboxProxyFetch(connectionId) {
|
|
788
|
+
return async (input, init) => {
|
|
789
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
790
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
791
|
+
if (!token || !sandboxId) {
|
|
792
|
+
throw new Error(
|
|
793
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
794
|
+
);
|
|
795
|
+
}
|
|
796
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
797
|
+
const originalMethod = init?.method ?? "GET";
|
|
798
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
799
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
800
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
801
|
+
return fetch(proxyUrl, {
|
|
802
|
+
method: "POST",
|
|
803
|
+
headers: {
|
|
804
|
+
"Content-Type": "application/json",
|
|
805
|
+
Authorization: `Bearer ${token}`
|
|
806
|
+
},
|
|
807
|
+
body: JSON.stringify({
|
|
808
|
+
url: originalUrl,
|
|
809
|
+
method: originalMethod,
|
|
810
|
+
body: originalBody
|
|
811
|
+
})
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
816
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
817
|
+
if (!projectId) {
|
|
818
|
+
throw new Error(
|
|
819
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
823
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
824
|
+
return async (input, init) => {
|
|
825
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
826
|
+
const originalMethod = init?.method ?? "GET";
|
|
827
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
828
|
+
const c = getContext();
|
|
829
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
830
|
+
if (!appSession) {
|
|
831
|
+
throw new Error(
|
|
832
|
+
"No authentication method available for connection proxy."
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
return fetch(proxyUrl, {
|
|
836
|
+
method: "POST",
|
|
837
|
+
headers: {
|
|
838
|
+
"Content-Type": "application/json",
|
|
839
|
+
Authorization: `Bearer ${appSession}`
|
|
840
|
+
},
|
|
841
|
+
body: JSON.stringify({
|
|
842
|
+
url: originalUrl,
|
|
843
|
+
method: originalMethod,
|
|
844
|
+
body: originalBody
|
|
845
|
+
})
|
|
846
|
+
});
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
function createProxyFetch(connectionId) {
|
|
850
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
851
|
+
return createSandboxProxyFetch(connectionId);
|
|
852
|
+
}
|
|
853
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
854
|
+
}
|
|
855
|
+
|
|
773
856
|
// src/connectors/create-connector-sdk.ts
|
|
774
857
|
function loadConnectionsSync() {
|
|
775
858
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -803,7 +886,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
803
886
|
if (val !== void 0) params[param.slug] = val;
|
|
804
887
|
}
|
|
805
888
|
}
|
|
806
|
-
return createClient2(params);
|
|
889
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
807
890
|
};
|
|
808
891
|
}
|
|
809
892
|
|
|
@@ -124,14 +124,24 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
// ../connectors/src/auth-types.ts
|
|
128
|
+
var AUTH_TYPES = {
|
|
129
|
+
OAUTH: "oauth",
|
|
130
|
+
API_KEY: "api-key",
|
|
131
|
+
JWT: "jwt",
|
|
132
|
+
SERVICE_ACCOUNT: "service-account",
|
|
133
|
+
PAT: "pat",
|
|
134
|
+
USER_PASSWORD: "user-password"
|
|
135
|
+
};
|
|
136
|
+
|
|
127
137
|
// ../connectors/src/connectors/gemini/index.ts
|
|
128
138
|
var tools = {};
|
|
129
139
|
var geminiConnector = new ConnectorPlugin({
|
|
130
140
|
slug: "gemini",
|
|
131
|
-
authType:
|
|
141
|
+
authType: AUTH_TYPES.API_KEY,
|
|
132
142
|
name: "Gemini",
|
|
133
143
|
description: "Connect to Google Gemini for AI model inference, embeddings, and multimodal generation.",
|
|
134
|
-
iconUrl: "https://
|
|
144
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/6K2qZQZEQq90YENfrXy5my/c83c0c3815af0a97d29ee70f37215f01/gemini.png",
|
|
135
145
|
parameters,
|
|
136
146
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
137
147
|
systemPrompt: {
|
|
@@ -201,6 +211,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
201
211
|
return process.env[envVarName] || void 0;
|
|
202
212
|
}
|
|
203
213
|
|
|
214
|
+
// src/connector-client/proxy-fetch.ts
|
|
215
|
+
import { getContext } from "hono/context-storage";
|
|
216
|
+
import { getCookie } from "hono/cookie";
|
|
217
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
218
|
+
function createSandboxProxyFetch(connectionId) {
|
|
219
|
+
return async (input, init) => {
|
|
220
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
221
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
222
|
+
if (!token || !sandboxId) {
|
|
223
|
+
throw new Error(
|
|
224
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
228
|
+
const originalMethod = init?.method ?? "GET";
|
|
229
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
230
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
231
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
232
|
+
return fetch(proxyUrl, {
|
|
233
|
+
method: "POST",
|
|
234
|
+
headers: {
|
|
235
|
+
"Content-Type": "application/json",
|
|
236
|
+
Authorization: `Bearer ${token}`
|
|
237
|
+
},
|
|
238
|
+
body: JSON.stringify({
|
|
239
|
+
url: originalUrl,
|
|
240
|
+
method: originalMethod,
|
|
241
|
+
body: originalBody
|
|
242
|
+
})
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
247
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
248
|
+
if (!projectId) {
|
|
249
|
+
throw new Error(
|
|
250
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
254
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
255
|
+
return async (input, init) => {
|
|
256
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
257
|
+
const originalMethod = init?.method ?? "GET";
|
|
258
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
259
|
+
const c = getContext();
|
|
260
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
261
|
+
if (!appSession) {
|
|
262
|
+
throw new Error(
|
|
263
|
+
"No authentication method available for connection proxy."
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
return fetch(proxyUrl, {
|
|
267
|
+
method: "POST",
|
|
268
|
+
headers: {
|
|
269
|
+
"Content-Type": "application/json",
|
|
270
|
+
Authorization: `Bearer ${appSession}`
|
|
271
|
+
},
|
|
272
|
+
body: JSON.stringify({
|
|
273
|
+
url: originalUrl,
|
|
274
|
+
method: originalMethod,
|
|
275
|
+
body: originalBody
|
|
276
|
+
})
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
function createProxyFetch(connectionId) {
|
|
281
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
282
|
+
return createSandboxProxyFetch(connectionId);
|
|
283
|
+
}
|
|
284
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
285
|
+
}
|
|
286
|
+
|
|
204
287
|
// src/connectors/create-connector-sdk.ts
|
|
205
288
|
function loadConnectionsSync() {
|
|
206
289
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -234,7 +317,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
234
317
|
if (val !== void 0) params[param.slug] = val;
|
|
235
318
|
}
|
|
236
319
|
}
|
|
237
|
-
return createClient2(params);
|
|
320
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
238
321
|
};
|
|
239
322
|
}
|
|
240
323
|
|
|
@@ -212,7 +212,8 @@ var AUTH_TYPES = {
|
|
|
212
212
|
API_KEY: "api-key",
|
|
213
213
|
JWT: "jwt",
|
|
214
214
|
SERVICE_ACCOUNT: "service-account",
|
|
215
|
-
PAT: "pat"
|
|
215
|
+
PAT: "pat",
|
|
216
|
+
USER_PASSWORD: "user-password"
|
|
216
217
|
};
|
|
217
218
|
|
|
218
219
|
// ../connectors/src/connectors/gmail-oauth/tools/request.ts
|
|
@@ -388,9 +389,9 @@ var tools = { request: requestTool };
|
|
|
388
389
|
var gmailOauthConnector = new ConnectorPlugin({
|
|
389
390
|
slug: "gmail",
|
|
390
391
|
authType: AUTH_TYPES.OAUTH,
|
|
391
|
-
name: "Gmail
|
|
392
|
+
name: "Gmail",
|
|
392
393
|
description: "Connect to Gmail for email data access using OAuth. Read-only access to messages, threads, and labels.",
|
|
393
|
-
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/
|
|
394
|
+
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4V3rfaSc1ksFIt2eHBNIwJ/7f3be41a154a6d96dcf229ed0e5858c9/Gmail_icon__2020_.svg.png",
|
|
394
395
|
parameters,
|
|
395
396
|
releaseFlag: { dev1: true, dev2: false, prod: false },
|
|
396
397
|
onboarding: gmailOnboarding,
|
|
@@ -595,6 +596,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
595
596
|
return process.env[envVarName] || void 0;
|
|
596
597
|
}
|
|
597
598
|
|
|
599
|
+
// src/connector-client/proxy-fetch.ts
|
|
600
|
+
import { getContext } from "hono/context-storage";
|
|
601
|
+
import { getCookie } from "hono/cookie";
|
|
602
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
603
|
+
function createSandboxProxyFetch(connectionId) {
|
|
604
|
+
return async (input, init) => {
|
|
605
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
606
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
607
|
+
if (!token || !sandboxId) {
|
|
608
|
+
throw new Error(
|
|
609
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
613
|
+
const originalMethod = init?.method ?? "GET";
|
|
614
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
615
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
616
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
617
|
+
return fetch(proxyUrl, {
|
|
618
|
+
method: "POST",
|
|
619
|
+
headers: {
|
|
620
|
+
"Content-Type": "application/json",
|
|
621
|
+
Authorization: `Bearer ${token}`
|
|
622
|
+
},
|
|
623
|
+
body: JSON.stringify({
|
|
624
|
+
url: originalUrl,
|
|
625
|
+
method: originalMethod,
|
|
626
|
+
body: originalBody
|
|
627
|
+
})
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
632
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
633
|
+
if (!projectId) {
|
|
634
|
+
throw new Error(
|
|
635
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
639
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
640
|
+
return async (input, init) => {
|
|
641
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
642
|
+
const originalMethod = init?.method ?? "GET";
|
|
643
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
644
|
+
const c = getContext();
|
|
645
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
646
|
+
if (!appSession) {
|
|
647
|
+
throw new Error(
|
|
648
|
+
"No authentication method available for connection proxy."
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
return fetch(proxyUrl, {
|
|
652
|
+
method: "POST",
|
|
653
|
+
headers: {
|
|
654
|
+
"Content-Type": "application/json",
|
|
655
|
+
Authorization: `Bearer ${appSession}`
|
|
656
|
+
},
|
|
657
|
+
body: JSON.stringify({
|
|
658
|
+
url: originalUrl,
|
|
659
|
+
method: originalMethod,
|
|
660
|
+
body: originalBody
|
|
661
|
+
})
|
|
662
|
+
});
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function createProxyFetch(connectionId) {
|
|
666
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
667
|
+
return createSandboxProxyFetch(connectionId);
|
|
668
|
+
}
|
|
669
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
670
|
+
}
|
|
671
|
+
|
|
598
672
|
// src/connectors/create-connector-sdk.ts
|
|
599
673
|
function loadConnectionsSync() {
|
|
600
674
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -628,7 +702,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
628
702
|
if (val !== void 0) params[param.slug] = val;
|
|
629
703
|
}
|
|
630
704
|
}
|
|
631
|
-
return createClient2(params);
|
|
705
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
632
706
|
};
|
|
633
707
|
}
|
|
634
708
|
|