@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
|
@@ -60,7 +60,7 @@ var parameters = {
|
|
|
60
60
|
envVarBaseKey: "GOOGLE_ADS_DEVELOPER_TOKEN",
|
|
61
61
|
type: "text",
|
|
62
62
|
secret: true,
|
|
63
|
-
required:
|
|
63
|
+
required: true
|
|
64
64
|
})
|
|
65
65
|
};
|
|
66
66
|
|
|
@@ -244,7 +244,8 @@ var AUTH_TYPES = {
|
|
|
244
244
|
API_KEY: "api-key",
|
|
245
245
|
JWT: "jwt",
|
|
246
246
|
SERVICE_ACCOUNT: "service-account",
|
|
247
|
-
PAT: "pat"
|
|
247
|
+
PAT: "pat",
|
|
248
|
+
USER_PASSWORD: "user-password"
|
|
248
249
|
};
|
|
249
250
|
|
|
250
251
|
// ../connectors/src/connectors/google-ads-oauth/tools/list-customers.ts
|
|
@@ -583,7 +584,7 @@ var tools = {
|
|
|
583
584
|
var googleAdsOauthConnector = new ConnectorPlugin({
|
|
584
585
|
slug: "google-ads",
|
|
585
586
|
authType: AUTH_TYPES.OAUTH,
|
|
586
|
-
name: "Google Ads
|
|
587
|
+
name: "Google Ads",
|
|
587
588
|
description: "Connect to Google Ads for advertising campaign data and reporting using OAuth.",
|
|
588
589
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1NGvmgvCxX7Tn11EST2N3N/a745fe7c63d360ed40a27ddaad3af168/google-ads.svg",
|
|
589
590
|
parameters,
|
|
@@ -772,6 +773,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
772
773
|
return process.env[envVarName] || void 0;
|
|
773
774
|
}
|
|
774
775
|
|
|
776
|
+
// src/connector-client/proxy-fetch.ts
|
|
777
|
+
import { getContext } from "hono/context-storage";
|
|
778
|
+
import { getCookie } from "hono/cookie";
|
|
779
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
780
|
+
function createSandboxProxyFetch(connectionId) {
|
|
781
|
+
return async (input, init) => {
|
|
782
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
783
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
784
|
+
if (!token || !sandboxId) {
|
|
785
|
+
throw new Error(
|
|
786
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
790
|
+
const originalMethod = init?.method ?? "GET";
|
|
791
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
792
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
793
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
794
|
+
return fetch(proxyUrl, {
|
|
795
|
+
method: "POST",
|
|
796
|
+
headers: {
|
|
797
|
+
"Content-Type": "application/json",
|
|
798
|
+
Authorization: `Bearer ${token}`
|
|
799
|
+
},
|
|
800
|
+
body: JSON.stringify({
|
|
801
|
+
url: originalUrl,
|
|
802
|
+
method: originalMethod,
|
|
803
|
+
body: originalBody
|
|
804
|
+
})
|
|
805
|
+
});
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
809
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
810
|
+
if (!projectId) {
|
|
811
|
+
throw new Error(
|
|
812
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
813
|
+
);
|
|
814
|
+
}
|
|
815
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
816
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
817
|
+
return async (input, init) => {
|
|
818
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
819
|
+
const originalMethod = init?.method ?? "GET";
|
|
820
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
821
|
+
const c = getContext();
|
|
822
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
823
|
+
if (!appSession) {
|
|
824
|
+
throw new Error(
|
|
825
|
+
"No authentication method available for connection proxy."
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
return fetch(proxyUrl, {
|
|
829
|
+
method: "POST",
|
|
830
|
+
headers: {
|
|
831
|
+
"Content-Type": "application/json",
|
|
832
|
+
Authorization: `Bearer ${appSession}`
|
|
833
|
+
},
|
|
834
|
+
body: JSON.stringify({
|
|
835
|
+
url: originalUrl,
|
|
836
|
+
method: originalMethod,
|
|
837
|
+
body: originalBody
|
|
838
|
+
})
|
|
839
|
+
});
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
function createProxyFetch(connectionId) {
|
|
843
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
844
|
+
return createSandboxProxyFetch(connectionId);
|
|
845
|
+
}
|
|
846
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
847
|
+
}
|
|
848
|
+
|
|
775
849
|
// src/connectors/create-connector-sdk.ts
|
|
776
850
|
function loadConnectionsSync() {
|
|
777
851
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -805,7 +879,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
805
879
|
if (val !== void 0) params[param.slug] = val;
|
|
806
880
|
}
|
|
807
881
|
}
|
|
808
|
-
return createClient2(params);
|
|
882
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
809
883
|
};
|
|
810
884
|
}
|
|
811
885
|
|
|
@@ -347,6 +347,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
347
347
|
}
|
|
348
348
|
};
|
|
349
349
|
|
|
350
|
+
// ../connectors/src/auth-types.ts
|
|
351
|
+
var AUTH_TYPES = {
|
|
352
|
+
OAUTH: "oauth",
|
|
353
|
+
API_KEY: "api-key",
|
|
354
|
+
JWT: "jwt",
|
|
355
|
+
SERVICE_ACCOUNT: "service-account",
|
|
356
|
+
PAT: "pat",
|
|
357
|
+
USER_PASSWORD: "user-password"
|
|
358
|
+
};
|
|
359
|
+
|
|
350
360
|
// ../connectors/src/connectors/google-ads/setup.ts
|
|
351
361
|
var googleAdsOnboarding = new ConnectorOnboarding({
|
|
352
362
|
dataOverviewInstructions: {
|
|
@@ -600,7 +610,7 @@ var tools = {
|
|
|
600
610
|
};
|
|
601
611
|
var googleAdsConnector = new ConnectorPlugin({
|
|
602
612
|
slug: "google-ads",
|
|
603
|
-
authType:
|
|
613
|
+
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
604
614
|
name: "Google Ads",
|
|
605
615
|
description: "Connect to Google Ads for advertising campaign data and reporting using a service account.",
|
|
606
616
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1NGvmgvCxX7Tn11EST2N3N/a745fe7c63d360ed40a27ddaad3af168/google-ads.svg",
|
|
@@ -740,6 +750,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
740
750
|
return process.env[envVarName] || void 0;
|
|
741
751
|
}
|
|
742
752
|
|
|
753
|
+
// src/connector-client/proxy-fetch.ts
|
|
754
|
+
import { getContext } from "hono/context-storage";
|
|
755
|
+
import { getCookie } from "hono/cookie";
|
|
756
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
757
|
+
function createSandboxProxyFetch(connectionId) {
|
|
758
|
+
return async (input, init) => {
|
|
759
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
760
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
761
|
+
if (!token || !sandboxId) {
|
|
762
|
+
throw new Error(
|
|
763
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
767
|
+
const originalMethod = init?.method ?? "GET";
|
|
768
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
769
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
770
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
771
|
+
return fetch(proxyUrl, {
|
|
772
|
+
method: "POST",
|
|
773
|
+
headers: {
|
|
774
|
+
"Content-Type": "application/json",
|
|
775
|
+
Authorization: `Bearer ${token}`
|
|
776
|
+
},
|
|
777
|
+
body: JSON.stringify({
|
|
778
|
+
url: originalUrl,
|
|
779
|
+
method: originalMethod,
|
|
780
|
+
body: originalBody
|
|
781
|
+
})
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
786
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
787
|
+
if (!projectId) {
|
|
788
|
+
throw new Error(
|
|
789
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
793
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
794
|
+
return async (input, init) => {
|
|
795
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
796
|
+
const originalMethod = init?.method ?? "GET";
|
|
797
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
798
|
+
const c = getContext();
|
|
799
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
800
|
+
if (!appSession) {
|
|
801
|
+
throw new Error(
|
|
802
|
+
"No authentication method available for connection proxy."
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
return fetch(proxyUrl, {
|
|
806
|
+
method: "POST",
|
|
807
|
+
headers: {
|
|
808
|
+
"Content-Type": "application/json",
|
|
809
|
+
Authorization: `Bearer ${appSession}`
|
|
810
|
+
},
|
|
811
|
+
body: JSON.stringify({
|
|
812
|
+
url: originalUrl,
|
|
813
|
+
method: originalMethod,
|
|
814
|
+
body: originalBody
|
|
815
|
+
})
|
|
816
|
+
});
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function createProxyFetch(connectionId) {
|
|
820
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
821
|
+
return createSandboxProxyFetch(connectionId);
|
|
822
|
+
}
|
|
823
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
824
|
+
}
|
|
825
|
+
|
|
743
826
|
// src/connectors/create-connector-sdk.ts
|
|
744
827
|
function loadConnectionsSync() {
|
|
745
828
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -773,7 +856,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
773
856
|
if (val !== void 0) params[param.slug] = val;
|
|
774
857
|
}
|
|
775
858
|
}
|
|
776
|
-
return createClient2(params);
|
|
859
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
777
860
|
};
|
|
778
861
|
}
|
|
779
862
|
|
|
@@ -57,7 +57,7 @@ var parameters = {
|
|
|
57
57
|
|
|
58
58
|
// ../connectors/src/connectors/google-analytics-oauth/sdk/index.ts
|
|
59
59
|
var BASE_URL = "https://analyticsdata.googleapis.com/v1beta/";
|
|
60
|
-
function createClient(params, fetchFn
|
|
60
|
+
function createClient(params, fetchFn) {
|
|
61
61
|
const propertyId = params[parameters.propertyId.slug];
|
|
62
62
|
function resolvePropertyId() {
|
|
63
63
|
if (!propertyId) {
|
|
@@ -241,7 +241,8 @@ var AUTH_TYPES = {
|
|
|
241
241
|
API_KEY: "api-key",
|
|
242
242
|
JWT: "jwt",
|
|
243
243
|
SERVICE_ACCOUNT: "service-account",
|
|
244
|
-
PAT: "pat"
|
|
244
|
+
PAT: "pat",
|
|
245
|
+
USER_PASSWORD: "user-password"
|
|
245
246
|
};
|
|
246
247
|
|
|
247
248
|
// ../connectors/src/connectors/google-analytics-oauth/tools/list-accounts.ts
|
|
@@ -482,12 +483,15 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
482
483
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Analytics (OAuth) \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
483
484
|
|
|
484
485
|
1. \`${listAccountsToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001OAuth\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306AGoogle Analytics\u30A2\u30AB\u30A6\u30F3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
485
|
-
2. \
|
|
486
|
-
-
|
|
486
|
+
2. \u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u9078\u629E:
|
|
487
|
+
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **2\u4EF6\u4EE5\u4E0A**: \u300C\u4F7F\u7528\u3059\u308B\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059\uFF08\`options\`: \u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (name)\` \u306E\u5F62\u5F0F\uFF09
|
|
488
|
+
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **1\u4EF6\u306E\u307F**: \`askUserQuestion\` \u306F\u30B9\u30AD\u30C3\u30D7\u3057\u3001\u305D\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u3092\u9078\u629E\u6E08\u307F\u3068\u3057\u3066\u6B21\u3078\u9032\u3080
|
|
489
|
+
- \u30A2\u30AB\u30A6\u30F3\u30C8\u304C **0\u4EF6**: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
|
|
487
490
|
3. \`${listPropertiesToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u9078\u629E\u3055\u308C\u305F\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
488
491
|
4. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
489
492
|
- \`parameterSlug\`: \`"property-id"\`
|
|
490
493
|
- \`options\`: \u30D7\u30ED\u30D1\u30C6\u30A3\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u8868\u793A\u540D (id: \u30D7\u30ED\u30D1\u30C6\u30A3ID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30D7\u30ED\u30D1\u30C6\u30A3ID
|
|
494
|
+
- \u30D7\u30ED\u30D1\u30C6\u30A3\u304C **0\u4EF6** \u306E\u5834\u5408\u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u4E2D\u65AD\u3057\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30D7\u30ED\u30D1\u30C6\u30A3\u304C\u306A\u3044\u65E8\u3092\u4F1D\u3048\u308B
|
|
491
495
|
5. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E \`label\` \u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u3057\u3066\u5C4A\u304F\u306E\u3067\u3001\u6B21\u306E\u30B9\u30C6\u30C3\u30D7\u306B\u9032\u3080
|
|
492
496
|
6. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
493
497
|
- \`property\`: \u9078\u629E\u3055\u308C\u305F\u30D7\u30ED\u30D1\u30C6\u30A3\u306E\u8868\u793A\u540D
|
|
@@ -496,16 +500,20 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
496
500
|
|
|
497
501
|
#### \u5236\u7D04
|
|
498
502
|
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30EC\u30DD\u30FC\u30C8\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3057\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30E1\u30BF\u30C7\u30FC\u30BF\u53D6\u5F97\u306E\u307F
|
|
503
|
+
- \`askUserQuestion\` \u306E \`options\` \u306F\u6700\u4F4E2\u4EF6\u5FC5\u8981\u3002\u5019\u88DC\u304C1\u4EF6\u4EE5\u4E0B\u306E\u5834\u5408\u306F\u5FC5\u305A\u30B9\u30AD\u30C3\u30D7\u3059\u308B\u3053\u3068
|
|
499
504
|
- \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u3002\u4E0D\u8981\u306A\u8AAC\u660E\u306F\u7701\u7565\u3057\u3001\u52B9\u7387\u7684\u306B\u9032\u3081\u308B`,
|
|
500
505
|
en: `Follow these steps to set up the Google Analytics (OAuth) connection.
|
|
501
506
|
|
|
502
507
|
1. Call \`${listAccountsToolName}\` to get the list of Google Analytics accounts accessible with the OAuth credentials
|
|
503
|
-
2.
|
|
504
|
-
-
|
|
508
|
+
2. Select an account:
|
|
509
|
+
- **2 or more accounts**: Tell the user "Please select an account.", then call \`askUserQuestion\` (\`options\`: each option's \`label\` should be \`Display Name (name)\`)
|
|
510
|
+
- **Only 1 account**: Skip \`askUserQuestion\` and proceed using that account as the selection
|
|
511
|
+
- **0 accounts**: Abort setup and inform the user that no accessible accounts are available
|
|
505
512
|
3. Call \`${listPropertiesToolName}\` to get the list of properties for the selected account
|
|
506
513
|
4. Call \`updateConnectionParameters\`:
|
|
507
514
|
- \`parameterSlug\`: \`"property-id"\`
|
|
508
515
|
- \`options\`: The property list. Each option's \`label\` should be \`Display Name (id: propertyId)\`, \`value\` should be the property ID
|
|
516
|
+
- If **0 properties** are returned, abort setup and inform the user that no accessible properties are available
|
|
509
517
|
5. The \`label\` of the user's selected property will arrive as a message. Proceed to the next step
|
|
510
518
|
6. Call \`updateConnectionContext\`:
|
|
511
519
|
- \`property\`: The selected property's display name
|
|
@@ -514,6 +522,7 @@ var googleAnalyticsOauthOnboarding = new ConnectorOnboarding({
|
|
|
514
522
|
|
|
515
523
|
#### Constraints
|
|
516
524
|
- **Do NOT fetch report data during setup**. Only the metadata requests specified in the steps above are allowed
|
|
525
|
+
- \`askUserQuestion\` requires at least 2 \`options\`. Always skip it when there is 1 or fewer candidates
|
|
517
526
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
518
527
|
},
|
|
519
528
|
dataOverviewInstructions: {
|
|
@@ -649,7 +658,7 @@ var tools = {
|
|
|
649
658
|
var googleAnalyticsOauthConnector = new ConnectorPlugin({
|
|
650
659
|
slug: "google-analytics",
|
|
651
660
|
authType: AUTH_TYPES.OAUTH,
|
|
652
|
-
name: "Google Analytics
|
|
661
|
+
name: "Google Analytics",
|
|
653
662
|
description: "Connect to Google Analytics for web analytics and reporting using OAuth.",
|
|
654
663
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
|
|
655
664
|
parameters,
|
|
@@ -846,6 +855,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
846
855
|
return process.env[envVarName] || void 0;
|
|
847
856
|
}
|
|
848
857
|
|
|
858
|
+
// src/connector-client/proxy-fetch.ts
|
|
859
|
+
import { getContext } from "hono/context-storage";
|
|
860
|
+
import { getCookie } from "hono/cookie";
|
|
861
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
862
|
+
function createSandboxProxyFetch(connectionId) {
|
|
863
|
+
return async (input, init) => {
|
|
864
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
865
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
866
|
+
if (!token || !sandboxId) {
|
|
867
|
+
throw new Error(
|
|
868
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
872
|
+
const originalMethod = init?.method ?? "GET";
|
|
873
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
874
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
875
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
876
|
+
return fetch(proxyUrl, {
|
|
877
|
+
method: "POST",
|
|
878
|
+
headers: {
|
|
879
|
+
"Content-Type": "application/json",
|
|
880
|
+
Authorization: `Bearer ${token}`
|
|
881
|
+
},
|
|
882
|
+
body: JSON.stringify({
|
|
883
|
+
url: originalUrl,
|
|
884
|
+
method: originalMethod,
|
|
885
|
+
body: originalBody
|
|
886
|
+
})
|
|
887
|
+
});
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
891
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
892
|
+
if (!projectId) {
|
|
893
|
+
throw new Error(
|
|
894
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
898
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
899
|
+
return async (input, init) => {
|
|
900
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
901
|
+
const originalMethod = init?.method ?? "GET";
|
|
902
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
903
|
+
const c = getContext();
|
|
904
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
905
|
+
if (!appSession) {
|
|
906
|
+
throw new Error(
|
|
907
|
+
"No authentication method available for connection proxy."
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
return fetch(proxyUrl, {
|
|
911
|
+
method: "POST",
|
|
912
|
+
headers: {
|
|
913
|
+
"Content-Type": "application/json",
|
|
914
|
+
Authorization: `Bearer ${appSession}`
|
|
915
|
+
},
|
|
916
|
+
body: JSON.stringify({
|
|
917
|
+
url: originalUrl,
|
|
918
|
+
method: originalMethod,
|
|
919
|
+
body: originalBody
|
|
920
|
+
})
|
|
921
|
+
});
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
function createProxyFetch(connectionId) {
|
|
925
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
926
|
+
return createSandboxProxyFetch(connectionId);
|
|
927
|
+
}
|
|
928
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
929
|
+
}
|
|
930
|
+
|
|
849
931
|
// src/connectors/create-connector-sdk.ts
|
|
850
932
|
function loadConnectionsSync() {
|
|
851
933
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -879,7 +961,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
879
961
|
if (val !== void 0) params[param.slug] = val;
|
|
880
962
|
}
|
|
881
963
|
}
|
|
882
|
-
return createClient2(params);
|
|
964
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
883
965
|
};
|
|
884
966
|
}
|
|
885
967
|
|
|
@@ -321,6 +321,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
+
// ../connectors/src/auth-types.ts
|
|
325
|
+
var AUTH_TYPES = {
|
|
326
|
+
OAUTH: "oauth",
|
|
327
|
+
API_KEY: "api-key",
|
|
328
|
+
JWT: "jwt",
|
|
329
|
+
SERVICE_ACCOUNT: "service-account",
|
|
330
|
+
PAT: "pat",
|
|
331
|
+
USER_PASSWORD: "user-password"
|
|
332
|
+
};
|
|
333
|
+
|
|
324
334
|
// ../connectors/src/connectors/google-analytics/setup.ts
|
|
325
335
|
var googleAnalyticsOnboarding = new ConnectorOnboarding({
|
|
326
336
|
dataOverviewInstructions: {
|
|
@@ -418,7 +428,7 @@ Authentication is handled automatically using a service account.
|
|
|
418
428
|
var tools = { request: requestTool };
|
|
419
429
|
var googleAnalyticsConnector = new ConnectorPlugin({
|
|
420
430
|
slug: "google-analytics",
|
|
421
|
-
authType:
|
|
431
|
+
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
422
432
|
name: "Google Analytics",
|
|
423
433
|
description: "Connect to Google Analytics for web analytics and reporting.",
|
|
424
434
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/7fs0ipzxuD9mACDzBATtxX/3c53ed90d15c96483e4f78cb29dab5e9/google-analytics.svg",
|
|
@@ -588,6 +598,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
588
598
|
return process.env[envVarName] || void 0;
|
|
589
599
|
}
|
|
590
600
|
|
|
601
|
+
// src/connector-client/proxy-fetch.ts
|
|
602
|
+
import { getContext } from "hono/context-storage";
|
|
603
|
+
import { getCookie } from "hono/cookie";
|
|
604
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
605
|
+
function createSandboxProxyFetch(connectionId) {
|
|
606
|
+
return async (input, init) => {
|
|
607
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
608
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
609
|
+
if (!token || !sandboxId) {
|
|
610
|
+
throw new Error(
|
|
611
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
615
|
+
const originalMethod = init?.method ?? "GET";
|
|
616
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
617
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
618
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
619
|
+
return fetch(proxyUrl, {
|
|
620
|
+
method: "POST",
|
|
621
|
+
headers: {
|
|
622
|
+
"Content-Type": "application/json",
|
|
623
|
+
Authorization: `Bearer ${token}`
|
|
624
|
+
},
|
|
625
|
+
body: JSON.stringify({
|
|
626
|
+
url: originalUrl,
|
|
627
|
+
method: originalMethod,
|
|
628
|
+
body: originalBody
|
|
629
|
+
})
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
634
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
635
|
+
if (!projectId) {
|
|
636
|
+
throw new Error(
|
|
637
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
641
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
642
|
+
return async (input, init) => {
|
|
643
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
644
|
+
const originalMethod = init?.method ?? "GET";
|
|
645
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
646
|
+
const c = getContext();
|
|
647
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
648
|
+
if (!appSession) {
|
|
649
|
+
throw new Error(
|
|
650
|
+
"No authentication method available for connection proxy."
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
return fetch(proxyUrl, {
|
|
654
|
+
method: "POST",
|
|
655
|
+
headers: {
|
|
656
|
+
"Content-Type": "application/json",
|
|
657
|
+
Authorization: `Bearer ${appSession}`
|
|
658
|
+
},
|
|
659
|
+
body: JSON.stringify({
|
|
660
|
+
url: originalUrl,
|
|
661
|
+
method: originalMethod,
|
|
662
|
+
body: originalBody
|
|
663
|
+
})
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
function createProxyFetch(connectionId) {
|
|
668
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
669
|
+
return createSandboxProxyFetch(connectionId);
|
|
670
|
+
}
|
|
671
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
672
|
+
}
|
|
673
|
+
|
|
591
674
|
// src/connectors/create-connector-sdk.ts
|
|
592
675
|
function loadConnectionsSync() {
|
|
593
676
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -621,7 +704,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
621
704
|
if (val !== void 0) params[param.slug] = val;
|
|
622
705
|
}
|
|
623
706
|
}
|
|
624
|
-
return createClient2(params);
|
|
707
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
625
708
|
};
|
|
626
709
|
}
|
|
627
710
|
|