@squadbase/vite-server 0.1.3-dev.0 → 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 +82859 -9645
- 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/{slack.d.ts → asana.d.ts} +1 -1
- package/dist/connectors/asana.js +744 -0
- package/dist/connectors/attio.js +85 -2
- package/dist/connectors/{microsoft-teams-oauth.d.ts → customerio.d.ts} +1 -1
- package/dist/connectors/customerio.js +716 -0
- package/dist/connectors/dbt.js +85 -2
- package/dist/connectors/gemini.js +86 -3
- package/dist/connectors/{microsoft-teams.d.ts → gmail-oauth.d.ts} +1 -1
- package/dist/connectors/gmail-oauth.js +713 -0
- 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.d.ts +5 -0
- package/dist/connectors/google-ads.js +867 -0
- 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.d.ts +5 -0
- package/dist/connectors/google-sheets.js +707 -0
- package/dist/connectors/grafana.d.ts +5 -0
- package/dist/connectors/grafana.js +638 -0
- package/dist/connectors/hubspot-oauth.js +77 -3
- package/dist/connectors/hubspot.js +89 -6
- package/dist/connectors/intercom-oauth.d.ts +5 -0
- package/dist/connectors/intercom-oauth.js +584 -0
- package/dist/connectors/intercom.d.ts +5 -0
- package/dist/connectors/intercom.js +710 -0
- package/dist/connectors/jira-api-key.d.ts +5 -0
- package/dist/connectors/jira-api-key.js +598 -0
- package/dist/connectors/kintone-api-token.js +77 -3
- package/dist/connectors/kintone.js +86 -3
- package/dist/connectors/linkedin-ads-oauth.d.ts +5 -0
- package/dist/connectors/linkedin-ads-oauth.js +848 -0
- package/dist/connectors/linkedin-ads.d.ts +5 -0
- package/dist/connectors/linkedin-ads.js +865 -0
- package/dist/connectors/mailchimp-oauth.d.ts +5 -0
- package/dist/connectors/mailchimp-oauth.js +613 -0
- package/dist/connectors/mailchimp.d.ts +5 -0
- package/dist/connectors/mailchimp.js +729 -0
- package/dist/connectors/notion-oauth.d.ts +5 -0
- package/dist/connectors/notion-oauth.js +567 -0
- package/dist/connectors/notion.d.ts +5 -0
- 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.d.ts +5 -0
- package/dist/connectors/zendesk-oauth.js +579 -0
- package/dist/connectors/zendesk.d.ts +5 -0
- package/dist/connectors/zendesk.js +714 -0
- package/dist/index.js +83024 -7099
- package/dist/main.js +82988 -7063
- package/dist/vite-plugin.js +82862 -6974
- package/package.json +86 -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
|
@@ -173,7 +173,8 @@ var AUTH_TYPES = {
|
|
|
173
173
|
API_KEY: "api-key",
|
|
174
174
|
JWT: "jwt",
|
|
175
175
|
SERVICE_ACCOUNT: "service-account",
|
|
176
|
-
PAT: "pat"
|
|
176
|
+
PAT: "pat",
|
|
177
|
+
USER_PASSWORD: "user-password"
|
|
177
178
|
};
|
|
178
179
|
|
|
179
180
|
// ../connectors/src/connectors/airtable-oauth/tools/request.ts
|
|
@@ -350,7 +351,7 @@ var tools = { request: requestTool };
|
|
|
350
351
|
var airtableOauthConnector = new ConnectorPlugin({
|
|
351
352
|
slug: "airtable",
|
|
352
353
|
authType: AUTH_TYPES.OAUTH,
|
|
353
|
-
name: "Airtable
|
|
354
|
+
name: "Airtable",
|
|
354
355
|
description: "Connect to Airtable for spreadsheet-database hybrid data management using OAuth.",
|
|
355
356
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19JUphfOZjyjTK6Zg4NGCf/8c56227b088cada52d3a2d9385a3be97/airtable.svg",
|
|
356
357
|
parameters,
|
|
@@ -513,6 +514,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
513
514
|
return process.env[envVarName] || void 0;
|
|
514
515
|
}
|
|
515
516
|
|
|
517
|
+
// src/connector-client/proxy-fetch.ts
|
|
518
|
+
import { getContext } from "hono/context-storage";
|
|
519
|
+
import { getCookie } from "hono/cookie";
|
|
520
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
521
|
+
function createSandboxProxyFetch(connectionId) {
|
|
522
|
+
return async (input, init) => {
|
|
523
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
524
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
525
|
+
if (!token || !sandboxId) {
|
|
526
|
+
throw new Error(
|
|
527
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
531
|
+
const originalMethod = init?.method ?? "GET";
|
|
532
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
533
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
534
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
535
|
+
return fetch(proxyUrl, {
|
|
536
|
+
method: "POST",
|
|
537
|
+
headers: {
|
|
538
|
+
"Content-Type": "application/json",
|
|
539
|
+
Authorization: `Bearer ${token}`
|
|
540
|
+
},
|
|
541
|
+
body: JSON.stringify({
|
|
542
|
+
url: originalUrl,
|
|
543
|
+
method: originalMethod,
|
|
544
|
+
body: originalBody
|
|
545
|
+
})
|
|
546
|
+
});
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
550
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
551
|
+
if (!projectId) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
557
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
558
|
+
return async (input, init) => {
|
|
559
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
560
|
+
const originalMethod = init?.method ?? "GET";
|
|
561
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
562
|
+
const c = getContext();
|
|
563
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
564
|
+
if (!appSession) {
|
|
565
|
+
throw new Error(
|
|
566
|
+
"No authentication method available for connection proxy."
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
return fetch(proxyUrl, {
|
|
570
|
+
method: "POST",
|
|
571
|
+
headers: {
|
|
572
|
+
"Content-Type": "application/json",
|
|
573
|
+
Authorization: `Bearer ${appSession}`
|
|
574
|
+
},
|
|
575
|
+
body: JSON.stringify({
|
|
576
|
+
url: originalUrl,
|
|
577
|
+
method: originalMethod,
|
|
578
|
+
body: originalBody
|
|
579
|
+
})
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
}
|
|
583
|
+
function createProxyFetch(connectionId) {
|
|
584
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
585
|
+
return createSandboxProxyFetch(connectionId);
|
|
586
|
+
}
|
|
587
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
588
|
+
}
|
|
589
|
+
|
|
516
590
|
// src/connectors/create-connector-sdk.ts
|
|
517
591
|
function loadConnectionsSync() {
|
|
518
592
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -546,7 +620,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
546
620
|
if (val !== void 0) params[param.slug] = val;
|
|
547
621
|
}
|
|
548
622
|
}
|
|
549
|
-
return createClient2(params);
|
|
623
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
550
624
|
};
|
|
551
625
|
}
|
|
552
626
|
|
|
@@ -297,6 +297,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
299
|
|
|
300
|
+
// ../connectors/src/auth-types.ts
|
|
301
|
+
var AUTH_TYPES = {
|
|
302
|
+
OAUTH: "oauth",
|
|
303
|
+
API_KEY: "api-key",
|
|
304
|
+
JWT: "jwt",
|
|
305
|
+
SERVICE_ACCOUNT: "service-account",
|
|
306
|
+
PAT: "pat",
|
|
307
|
+
USER_PASSWORD: "user-password"
|
|
308
|
+
};
|
|
309
|
+
|
|
300
310
|
// ../connectors/src/connectors/airtable/setup.ts
|
|
301
311
|
var airtableOnboarding = new ConnectorOnboarding({
|
|
302
312
|
dataOverviewInstructions: {
|
|
@@ -382,7 +392,7 @@ Authentication is handled automatically using the API Key.
|
|
|
382
392
|
var tools = { request: requestTool };
|
|
383
393
|
var airtableConnector = new ConnectorPlugin({
|
|
384
394
|
slug: "airtable",
|
|
385
|
-
authType:
|
|
395
|
+
authType: AUTH_TYPES.API_KEY,
|
|
386
396
|
name: "Airtable",
|
|
387
397
|
description: "Connect to Airtable for spreadsheet-database hybrid data management.",
|
|
388
398
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/19JUphfOZjyjTK6Zg4NGCf/8c56227b088cada52d3a2d9385a3be97/airtable.svg",
|
|
@@ -534,6 +544,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
534
544
|
return process.env[envVarName] || void 0;
|
|
535
545
|
}
|
|
536
546
|
|
|
547
|
+
// src/connector-client/proxy-fetch.ts
|
|
548
|
+
import { getContext } from "hono/context-storage";
|
|
549
|
+
import { getCookie } from "hono/cookie";
|
|
550
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
551
|
+
function createSandboxProxyFetch(connectionId) {
|
|
552
|
+
return async (input, init) => {
|
|
553
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
554
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
555
|
+
if (!token || !sandboxId) {
|
|
556
|
+
throw new Error(
|
|
557
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
561
|
+
const originalMethod = init?.method ?? "GET";
|
|
562
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
563
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
564
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
565
|
+
return fetch(proxyUrl, {
|
|
566
|
+
method: "POST",
|
|
567
|
+
headers: {
|
|
568
|
+
"Content-Type": "application/json",
|
|
569
|
+
Authorization: `Bearer ${token}`
|
|
570
|
+
},
|
|
571
|
+
body: JSON.stringify({
|
|
572
|
+
url: originalUrl,
|
|
573
|
+
method: originalMethod,
|
|
574
|
+
body: originalBody
|
|
575
|
+
})
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
580
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
581
|
+
if (!projectId) {
|
|
582
|
+
throw new Error(
|
|
583
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
584
|
+
);
|
|
585
|
+
}
|
|
586
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
587
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
588
|
+
return async (input, init) => {
|
|
589
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
590
|
+
const originalMethod = init?.method ?? "GET";
|
|
591
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
592
|
+
const c = getContext();
|
|
593
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
594
|
+
if (!appSession) {
|
|
595
|
+
throw new Error(
|
|
596
|
+
"No authentication method available for connection proxy."
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
return fetch(proxyUrl, {
|
|
600
|
+
method: "POST",
|
|
601
|
+
headers: {
|
|
602
|
+
"Content-Type": "application/json",
|
|
603
|
+
Authorization: `Bearer ${appSession}`
|
|
604
|
+
},
|
|
605
|
+
body: JSON.stringify({
|
|
606
|
+
url: originalUrl,
|
|
607
|
+
method: originalMethod,
|
|
608
|
+
body: originalBody
|
|
609
|
+
})
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function createProxyFetch(connectionId) {
|
|
614
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
615
|
+
return createSandboxProxyFetch(connectionId);
|
|
616
|
+
}
|
|
617
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
618
|
+
}
|
|
619
|
+
|
|
537
620
|
// src/connectors/create-connector-sdk.ts
|
|
538
621
|
function loadConnectionsSync() {
|
|
539
622
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -567,7 +650,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
567
650
|
if (val !== void 0) params[param.slug] = val;
|
|
568
651
|
}
|
|
569
652
|
}
|
|
570
|
-
return createClient2(params);
|
|
653
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
571
654
|
};
|
|
572
655
|
}
|
|
573
656
|
|
|
@@ -257,6 +257,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
+
// ../connectors/src/auth-types.ts
|
|
261
|
+
var AUTH_TYPES = {
|
|
262
|
+
OAUTH: "oauth",
|
|
263
|
+
API_KEY: "api-key",
|
|
264
|
+
JWT: "jwt",
|
|
265
|
+
SERVICE_ACCOUNT: "service-account",
|
|
266
|
+
PAT: "pat",
|
|
267
|
+
USER_PASSWORD: "user-password"
|
|
268
|
+
};
|
|
269
|
+
|
|
260
270
|
// ../connectors/src/connectors/amplitude/setup.ts
|
|
261
271
|
var amplitudeOnboarding = new ConnectorOnboarding({
|
|
262
272
|
dataOverviewInstructions: {
|
|
@@ -363,7 +373,7 @@ IMPORTANT: Dashboard REST API endpoints (events/segmentation, funnels, retention
|
|
|
363
373
|
var tools = { request: requestTool };
|
|
364
374
|
var amplitudeConnector = new ConnectorPlugin({
|
|
365
375
|
slug: "amplitude",
|
|
366
|
-
authType:
|
|
376
|
+
authType: AUTH_TYPES.API_KEY,
|
|
367
377
|
name: "Amplitude",
|
|
368
378
|
description: "Connect to Amplitude for product analytics and user behavior data.",
|
|
369
379
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/2UBJSdRlFJaLq52WUCTBEB/308b59b374cf6c662ac70989860bffd7/amplitude-icon.svg",
|
|
@@ -525,6 +535,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
525
535
|
return process.env[envVarName] || void 0;
|
|
526
536
|
}
|
|
527
537
|
|
|
538
|
+
// src/connector-client/proxy-fetch.ts
|
|
539
|
+
import { getContext } from "hono/context-storage";
|
|
540
|
+
import { getCookie } from "hono/cookie";
|
|
541
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
542
|
+
function createSandboxProxyFetch(connectionId) {
|
|
543
|
+
return async (input, init) => {
|
|
544
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
545
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
546
|
+
if (!token || !sandboxId) {
|
|
547
|
+
throw new Error(
|
|
548
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
552
|
+
const originalMethod = init?.method ?? "GET";
|
|
553
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
554
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
555
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
556
|
+
return fetch(proxyUrl, {
|
|
557
|
+
method: "POST",
|
|
558
|
+
headers: {
|
|
559
|
+
"Content-Type": "application/json",
|
|
560
|
+
Authorization: `Bearer ${token}`
|
|
561
|
+
},
|
|
562
|
+
body: JSON.stringify({
|
|
563
|
+
url: originalUrl,
|
|
564
|
+
method: originalMethod,
|
|
565
|
+
body: originalBody
|
|
566
|
+
})
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
571
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
572
|
+
if (!projectId) {
|
|
573
|
+
throw new Error(
|
|
574
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
578
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
579
|
+
return async (input, init) => {
|
|
580
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
581
|
+
const originalMethod = init?.method ?? "GET";
|
|
582
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
583
|
+
const c = getContext();
|
|
584
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
585
|
+
if (!appSession) {
|
|
586
|
+
throw new Error(
|
|
587
|
+
"No authentication method available for connection proxy."
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
return fetch(proxyUrl, {
|
|
591
|
+
method: "POST",
|
|
592
|
+
headers: {
|
|
593
|
+
"Content-Type": "application/json",
|
|
594
|
+
Authorization: `Bearer ${appSession}`
|
|
595
|
+
},
|
|
596
|
+
body: JSON.stringify({
|
|
597
|
+
url: originalUrl,
|
|
598
|
+
method: originalMethod,
|
|
599
|
+
body: originalBody
|
|
600
|
+
})
|
|
601
|
+
});
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function createProxyFetch(connectionId) {
|
|
605
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
606
|
+
return createSandboxProxyFetch(connectionId);
|
|
607
|
+
}
|
|
608
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
609
|
+
}
|
|
610
|
+
|
|
528
611
|
// src/connectors/create-connector-sdk.ts
|
|
529
612
|
function loadConnectionsSync() {
|
|
530
613
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -558,7 +641,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
558
641
|
if (val !== void 0) params[param.slug] = val;
|
|
559
642
|
}
|
|
560
643
|
}
|
|
561
|
-
return createClient2(params);
|
|
644
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
562
645
|
};
|
|
563
646
|
}
|
|
564
647
|
|
|
@@ -124,11 +124,21 @@ 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/anthropic/index.ts
|
|
128
138
|
var tools = {};
|
|
129
139
|
var anthropicConnector = new ConnectorPlugin({
|
|
130
140
|
slug: "anthropic",
|
|
131
|
-
authType:
|
|
141
|
+
authType: AUTH_TYPES.API_KEY,
|
|
132
142
|
name: "Anthropic",
|
|
133
143
|
description: "Connect to Anthropic for AI model inference and text generation with Claude.",
|
|
134
144
|
iconUrl: "https://www.anthropic.com/images/icons/safari-pinned-tab.svg",
|
|
@@ -209,6 +219,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
209
219
|
return process.env[envVarName] || void 0;
|
|
210
220
|
}
|
|
211
221
|
|
|
222
|
+
// src/connector-client/proxy-fetch.ts
|
|
223
|
+
import { getContext } from "hono/context-storage";
|
|
224
|
+
import { getCookie } from "hono/cookie";
|
|
225
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
226
|
+
function createSandboxProxyFetch(connectionId) {
|
|
227
|
+
return async (input, init) => {
|
|
228
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
229
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
230
|
+
if (!token || !sandboxId) {
|
|
231
|
+
throw new Error(
|
|
232
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
236
|
+
const originalMethod = init?.method ?? "GET";
|
|
237
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
238
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
239
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
240
|
+
return fetch(proxyUrl, {
|
|
241
|
+
method: "POST",
|
|
242
|
+
headers: {
|
|
243
|
+
"Content-Type": "application/json",
|
|
244
|
+
Authorization: `Bearer ${token}`
|
|
245
|
+
},
|
|
246
|
+
body: JSON.stringify({
|
|
247
|
+
url: originalUrl,
|
|
248
|
+
method: originalMethod,
|
|
249
|
+
body: originalBody
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
255
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
256
|
+
if (!projectId) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
262
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
263
|
+
return async (input, init) => {
|
|
264
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
265
|
+
const originalMethod = init?.method ?? "GET";
|
|
266
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
267
|
+
const c = getContext();
|
|
268
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
269
|
+
if (!appSession) {
|
|
270
|
+
throw new Error(
|
|
271
|
+
"No authentication method available for connection proxy."
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
return fetch(proxyUrl, {
|
|
275
|
+
method: "POST",
|
|
276
|
+
headers: {
|
|
277
|
+
"Content-Type": "application/json",
|
|
278
|
+
Authorization: `Bearer ${appSession}`
|
|
279
|
+
},
|
|
280
|
+
body: JSON.stringify({
|
|
281
|
+
url: originalUrl,
|
|
282
|
+
method: originalMethod,
|
|
283
|
+
body: originalBody
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function createProxyFetch(connectionId) {
|
|
289
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
290
|
+
return createSandboxProxyFetch(connectionId);
|
|
291
|
+
}
|
|
292
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
293
|
+
}
|
|
294
|
+
|
|
212
295
|
// src/connectors/create-connector-sdk.ts
|
|
213
296
|
function loadConnectionsSync() {
|
|
214
297
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -242,7 +325,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
242
325
|
if (val !== void 0) params[param.slug] = val;
|
|
243
326
|
}
|
|
244
327
|
}
|
|
245
|
-
return createClient2(params);
|
|
328
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
246
329
|
};
|
|
247
330
|
}
|
|
248
331
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
|
|
2
2
|
|
|
3
|
-
declare const connection: (connectionId: string) => _squadbase_connectors_sdk.
|
|
3
|
+
declare const connection: (connectionId: string) => _squadbase_connectors_sdk.AsanaConnectorSdk;
|
|
4
4
|
|
|
5
5
|
export { connection };
|