@squadbase/vite-server 0.1.3-dev.1 → 0.1.3-dev.11
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 +71446 -6941
- 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/{microsoft-teams.d.ts → backlog-api-key.d.ts} +1 -1
- package/dist/connectors/backlog-api-key.js +592 -0
- 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-oauth.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/notion-oauth.d.ts +5 -0
- 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 +75463 -8247
- package/dist/main.js +75191 -7975
- package/dist/vite-plugin.js +75300 -8121
- package/package.json +50 -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
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __esm = (fn, res) => function __init() {
|
|
4
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
+
};
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// ../connectors/src/connectors/google-sheets/utils.ts
|
|
12
|
+
function extractSpreadsheetId(urlOrId) {
|
|
13
|
+
const trimmed = urlOrId.trim();
|
|
14
|
+
const match = trimmed.match(SPREADSHEET_URL_PATTERN);
|
|
15
|
+
if (match) {
|
|
16
|
+
return match[1];
|
|
17
|
+
}
|
|
18
|
+
return trimmed;
|
|
19
|
+
}
|
|
20
|
+
var SPREADSHEET_URL_PATTERN;
|
|
21
|
+
var init_utils = __esm({
|
|
22
|
+
"../connectors/src/connectors/google-sheets/utils.ts"() {
|
|
23
|
+
"use strict";
|
|
24
|
+
SPREADSHEET_URL_PATTERN = /docs\.google\.com\/spreadsheets\/d\/([a-zA-Z0-9_-]+)/;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// ../connectors/src/connectors/google-sheets-oauth/utils.ts
|
|
29
|
+
var utils_exports = {};
|
|
30
|
+
__export(utils_exports, {
|
|
31
|
+
extractSpreadsheetId: () => extractSpreadsheetId
|
|
32
|
+
});
|
|
33
|
+
var init_utils2 = __esm({
|
|
34
|
+
"../connectors/src/connectors/google-sheets-oauth/utils.ts"() {
|
|
35
|
+
"use strict";
|
|
36
|
+
init_utils();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
1
40
|
// ../connectors/src/parameter-definition.ts
|
|
2
41
|
var ParameterDefinition = class {
|
|
3
42
|
slug;
|
|
@@ -44,21 +83,23 @@ var ParameterDefinition = class {
|
|
|
44
83
|
|
|
45
84
|
// ../connectors/src/connectors/google-sheets-oauth/parameters.ts
|
|
46
85
|
var parameters = {
|
|
47
|
-
|
|
48
|
-
slug: "spreadsheet-
|
|
49
|
-
name: "
|
|
50
|
-
description: "The
|
|
51
|
-
envVarBaseKey: "
|
|
86
|
+
spreadsheetUrl: new ParameterDefinition({
|
|
87
|
+
slug: "spreadsheet-url",
|
|
88
|
+
name: "Google Spreadsheet URL",
|
|
89
|
+
description: "The URL of the Google Spreadsheet (e.g., https://docs.google.com/spreadsheets/d/xxxxx/edit). The spreadsheet ID is automatically extracted from the URL.",
|
|
90
|
+
envVarBaseKey: "GOOGLE_SHEETS_OAUTH_SPREADSHEET_URL",
|
|
52
91
|
type: "text",
|
|
53
92
|
secret: false,
|
|
54
|
-
required:
|
|
93
|
+
required: true
|
|
55
94
|
})
|
|
56
95
|
};
|
|
57
96
|
|
|
58
97
|
// ../connectors/src/connectors/google-sheets-oauth/sdk/index.ts
|
|
98
|
+
init_utils2();
|
|
59
99
|
var BASE_URL = "https://sheets.googleapis.com/v4/spreadsheets";
|
|
60
100
|
function createClient(params, fetchFn = fetch) {
|
|
61
|
-
const
|
|
101
|
+
const spreadsheetUrl = params[parameters.spreadsheetUrl.slug];
|
|
102
|
+
const defaultSpreadsheetId = spreadsheetUrl ? extractSpreadsheetId(spreadsheetUrl) : void 0;
|
|
62
103
|
function resolveSpreadsheetId(override) {
|
|
63
104
|
const id = override ?? defaultSpreadsheetId;
|
|
64
105
|
if (!id) {
|
|
@@ -227,11 +268,13 @@ var AUTH_TYPES = {
|
|
|
227
268
|
API_KEY: "api-key",
|
|
228
269
|
JWT: "jwt",
|
|
229
270
|
SERVICE_ACCOUNT: "service-account",
|
|
230
|
-
PAT: "pat"
|
|
271
|
+
PAT: "pat",
|
|
272
|
+
USER_PASSWORD: "user-password"
|
|
231
273
|
};
|
|
232
274
|
|
|
233
275
|
// ../connectors/src/connectors/google-sheets-oauth/tools/request.ts
|
|
234
276
|
import { z } from "zod";
|
|
277
|
+
init_utils2();
|
|
235
278
|
var BASE_URL2 = "https://sheets.googleapis.com/v4/spreadsheets";
|
|
236
279
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
237
280
|
var cachedToken = null;
|
|
@@ -306,7 +349,8 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
306
349
|
`[connector-request] google-sheets-oauth/${connection2.name}: ${method} ${path2}`
|
|
307
350
|
);
|
|
308
351
|
try {
|
|
309
|
-
const
|
|
352
|
+
const spreadsheetUrl = parameters.spreadsheetUrl.tryGetValue(connection2);
|
|
353
|
+
const spreadsheetId = spreadsheetUrl ? extractSpreadsheetId(spreadsheetUrl) : void 0;
|
|
310
354
|
const resolvedPath = spreadsheetId ? path2.replace(/\{spreadsheetId\}/g, spreadsheetId) : path2;
|
|
311
355
|
let url = `${BASE_URL2}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
|
|
312
356
|
if (queryParams) {
|
|
@@ -350,43 +394,35 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
350
394
|
var requestToolName = `google-sheets-oauth_${requestTool.name}`;
|
|
351
395
|
var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
352
396
|
connectionSetupInstructions: {
|
|
353
|
-
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Sheets\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
354
|
-
|
|
355
|
-
1. \
|
|
356
|
-
2. \u30E6\u30FC\u30B6\u30FC\u304CURL\u307E\u305F\u306F\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8ID\u3092\u63D0\u4F9B\u3057\u305F\u3089\u3001URL\u304B\u3089ID\u3092\u62BD\u51FA\u3059\u308B\uFF08\`/d/\` \u3068 \`/edit\` \u306E\u9593\u306E\u6587\u5B57\u5217\uFF09
|
|
357
|
-
3. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
358
|
-
- \`parameterSlug\`: \`"spreadsheet-id"\`
|
|
359
|
-
- \`value\`: \u62BD\u51FA\u3057\u305F\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8ID
|
|
360
|
-
4. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3059\u308B:
|
|
397
|
+
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Sheets\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8URL\u306F\u63A5\u7D9A\u30D1\u30E9\u30E1\u30FC\u30BF\u3068\u3057\u3066\u65E2\u306B\u767B\u9332\u6E08\u307F\u3067\u3059\u3002\u30E6\u30FC\u30B6\u30FC\u306B\u805E\u304D\u8FD4\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
398
|
+
|
|
399
|
+
1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97\u3059\u308B:
|
|
361
400
|
- \`method\`: \`"GET"\`
|
|
362
401
|
- \`path\`: \`"/{spreadsheetId}?fields=spreadsheetId,properties.title,sheets.properties.title"\`
|
|
363
|
-
|
|
364
|
-
|
|
402
|
+
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u5171\u6709\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
403
|
+
3. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
|
|
365
404
|
- \`spreadsheet\`: \u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30BF\u30A4\u30C8\u30EB
|
|
366
405
|
- \`sheets\`: \u30B7\u30FC\u30C8\u540D\u4E00\u89A7\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09
|
|
367
406
|
- \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
|
|
368
407
|
|
|
369
408
|
#### \u5236\u7D04
|
|
370
409
|
- **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30B7\u30FC\u30C8\u306E\u30C7\u30FC\u30BF\u3092\u8AAD\u307F\u53D6\u3089\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\u30EA\u30AF\u30A8\u30B9\u30C8\u306E\u307F
|
|
410
|
+
- \u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8URL\u3092\u30E6\u30FC\u30B6\u30FC\u306B\u805E\u304D\u8FD4\u3055\u306A\u3044\u3053\u3068\uFF08\u767B\u9332\u6E08\u307F\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u305D\u306E\u307E\u307E\u4F7F\u7528\u3059\u308B\uFF09
|
|
371
411
|
- \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`,
|
|
372
|
-
en: `Follow these steps to set up the Google Sheets connection.
|
|
373
|
-
|
|
374
|
-
1.
|
|
375
|
-
2. When the user provides a URL or spreadsheet ID, extract the ID from the URL (the string between \`/d/\` and \`/edit\`)
|
|
376
|
-
3. Call \`updateConnectionParameters\`:
|
|
377
|
-
- \`parameterSlug\`: \`"spreadsheet-id"\`
|
|
378
|
-
- \`value\`: The extracted spreadsheet ID
|
|
379
|
-
4. Call \`${requestToolName}\` to fetch spreadsheet metadata:
|
|
412
|
+
en: `Follow these steps to set up the Google Sheets connection. The spreadsheet URL is already registered as a connection parameter \u2014 do NOT ask the user for it again.
|
|
413
|
+
|
|
414
|
+
1. Call \`${requestToolName}\` to fetch spreadsheet metadata:
|
|
380
415
|
- \`method\`: \`"GET"\`
|
|
381
416
|
- \`path\`: \`"/{spreadsheetId}?fields=spreadsheetId,properties.title,sheets.properties.title"\`
|
|
382
|
-
|
|
383
|
-
|
|
417
|
+
2. If an error is returned, ask the user to check the spreadsheet sharing settings
|
|
418
|
+
3. Call \`updateConnectionContext\`:
|
|
384
419
|
- \`spreadsheet\`: The spreadsheet title
|
|
385
420
|
- \`sheets\`: Sheet names (comma-separated)
|
|
386
421
|
- \`note\`: Brief description of the setup
|
|
387
422
|
|
|
388
423
|
#### Constraints
|
|
389
424
|
- **Do NOT read sheet data during setup**. Only the metadata request specified in the steps above is allowed
|
|
425
|
+
- Do NOT ask the user for the spreadsheet URL \u2014 it is already stored as a connection parameter
|
|
390
426
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
391
427
|
},
|
|
392
428
|
dataOverviewInstructions: {
|
|
@@ -402,7 +438,7 @@ var tools = { request: requestTool };
|
|
|
402
438
|
var googleSheetsOauthConnector = new ConnectorPlugin({
|
|
403
439
|
slug: "google-sheets",
|
|
404
440
|
authType: AUTH_TYPES.OAUTH,
|
|
405
|
-
name: "Google Sheets
|
|
441
|
+
name: "Google Sheets",
|
|
406
442
|
description: "Connect to Google Sheets for spreadsheet data access using OAuth.",
|
|
407
443
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1UPQuggyiZmbb26CuaSr2h/032770e8739b183fa00b7625f024e536/google-sheets.svg",
|
|
408
444
|
parameters,
|
|
@@ -517,10 +553,12 @@ batch.valueRanges.forEach(vr => console.log(vr.range, vr.values));
|
|
|
517
553
|
tools,
|
|
518
554
|
async checkConnection(params, config) {
|
|
519
555
|
const { proxyFetch } = config;
|
|
520
|
-
const
|
|
521
|
-
if (!
|
|
556
|
+
const spreadsheetUrl = params[parameters.spreadsheetUrl.slug];
|
|
557
|
+
if (!spreadsheetUrl) {
|
|
522
558
|
return { success: true };
|
|
523
559
|
}
|
|
560
|
+
const { extractSpreadsheetId: extractSpreadsheetId2 } = await Promise.resolve().then(() => (init_utils2(), utils_exports));
|
|
561
|
+
const spreadsheetId = extractSpreadsheetId2(spreadsheetUrl);
|
|
524
562
|
const url = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}?fields=spreadsheetId,properties.title`;
|
|
525
563
|
try {
|
|
526
564
|
const res = await proxyFetch(url, { method: "GET" });
|
|
@@ -563,6 +601,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
563
601
|
return process.env[envVarName] || void 0;
|
|
564
602
|
}
|
|
565
603
|
|
|
604
|
+
// src/connector-client/proxy-fetch.ts
|
|
605
|
+
import { getContext } from "hono/context-storage";
|
|
606
|
+
import { getCookie } from "hono/cookie";
|
|
607
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
608
|
+
function createSandboxProxyFetch(connectionId) {
|
|
609
|
+
return async (input, init) => {
|
|
610
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
611
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
612
|
+
if (!token || !sandboxId) {
|
|
613
|
+
throw new Error(
|
|
614
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
615
|
+
);
|
|
616
|
+
}
|
|
617
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
618
|
+
const originalMethod = init?.method ?? "GET";
|
|
619
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
620
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
621
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
622
|
+
return fetch(proxyUrl, {
|
|
623
|
+
method: "POST",
|
|
624
|
+
headers: {
|
|
625
|
+
"Content-Type": "application/json",
|
|
626
|
+
Authorization: `Bearer ${token}`
|
|
627
|
+
},
|
|
628
|
+
body: JSON.stringify({
|
|
629
|
+
url: originalUrl,
|
|
630
|
+
method: originalMethod,
|
|
631
|
+
body: originalBody
|
|
632
|
+
})
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
637
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
638
|
+
if (!projectId) {
|
|
639
|
+
throw new Error(
|
|
640
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
644
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
645
|
+
return async (input, init) => {
|
|
646
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
647
|
+
const originalMethod = init?.method ?? "GET";
|
|
648
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
649
|
+
const c = getContext();
|
|
650
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
651
|
+
if (!appSession) {
|
|
652
|
+
throw new Error(
|
|
653
|
+
"No authentication method available for connection proxy."
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
return fetch(proxyUrl, {
|
|
657
|
+
method: "POST",
|
|
658
|
+
headers: {
|
|
659
|
+
"Content-Type": "application/json",
|
|
660
|
+
Authorization: `Bearer ${appSession}`
|
|
661
|
+
},
|
|
662
|
+
body: JSON.stringify({
|
|
663
|
+
url: originalUrl,
|
|
664
|
+
method: originalMethod,
|
|
665
|
+
body: originalBody
|
|
666
|
+
})
|
|
667
|
+
});
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
function createProxyFetch(connectionId) {
|
|
671
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
672
|
+
return createSandboxProxyFetch(connectionId);
|
|
673
|
+
}
|
|
674
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
675
|
+
}
|
|
676
|
+
|
|
566
677
|
// src/connectors/create-connector-sdk.ts
|
|
567
678
|
function loadConnectionsSync() {
|
|
568
679
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -596,7 +707,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
596
707
|
if (val !== void 0) params[param.slug] = val;
|
|
597
708
|
}
|
|
598
709
|
}
|
|
599
|
-
return createClient2(params);
|
|
710
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
600
711
|
};
|
|
601
712
|
}
|
|
602
713
|
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __esm = (fn, res) => function __init() {
|
|
3
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// ../connectors/src/connectors/google-sheets/utils.ts
|
|
7
|
+
function extractSpreadsheetId(urlOrId) {
|
|
8
|
+
const trimmed = urlOrId.trim();
|
|
9
|
+
const match = trimmed.match(SPREADSHEET_URL_PATTERN);
|
|
10
|
+
if (match) {
|
|
11
|
+
return match[1];
|
|
12
|
+
}
|
|
13
|
+
return trimmed;
|
|
14
|
+
}
|
|
15
|
+
var SPREADSHEET_URL_PATTERN;
|
|
16
|
+
var init_utils = __esm({
|
|
17
|
+
"../connectors/src/connectors/google-sheets/utils.ts"() {
|
|
18
|
+
"use strict";
|
|
19
|
+
SPREADSHEET_URL_PATTERN = /docs\.google\.com\/spreadsheets\/d\/([a-zA-Z0-9_-]+)/;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
1
23
|
// ../connectors/src/parameter-definition.ts
|
|
2
24
|
var ParameterDefinition = class {
|
|
3
25
|
slug;
|
|
@@ -56,18 +78,19 @@ var parameters = {
|
|
|
56
78
|
secret: true,
|
|
57
79
|
required: true
|
|
58
80
|
}),
|
|
59
|
-
|
|
60
|
-
slug: "spreadsheet-
|
|
61
|
-
name: "
|
|
62
|
-
description: "The
|
|
63
|
-
envVarBaseKey: "
|
|
81
|
+
spreadsheetUrl: new ParameterDefinition({
|
|
82
|
+
slug: "spreadsheet-url",
|
|
83
|
+
name: "Google Spreadsheet URL",
|
|
84
|
+
description: "The URL of the Google Spreadsheet (e.g., https://docs.google.com/spreadsheets/d/xxxxx/edit). The spreadsheet ID is automatically extracted from the URL.",
|
|
85
|
+
envVarBaseKey: "GOOGLE_SHEETS_SPREADSHEET_URL",
|
|
64
86
|
type: "text",
|
|
65
87
|
secret: false,
|
|
66
|
-
required:
|
|
88
|
+
required: true
|
|
67
89
|
})
|
|
68
90
|
};
|
|
69
91
|
|
|
70
92
|
// ../connectors/src/connectors/google-sheets/sdk/index.ts
|
|
93
|
+
init_utils();
|
|
71
94
|
var TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
72
95
|
var BASE_URL = "https://sheets.googleapis.com/v4/spreadsheets";
|
|
73
96
|
var SCOPE = "https://www.googleapis.com/auth/spreadsheets.readonly";
|
|
@@ -95,7 +118,8 @@ function buildJwt(clientEmail, privateKey, nowSec) {
|
|
|
95
118
|
}
|
|
96
119
|
function createClient(params) {
|
|
97
120
|
const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
|
|
98
|
-
const
|
|
121
|
+
const spreadsheetUrl = params[parameters.spreadsheetUrl.slug];
|
|
122
|
+
const defaultSpreadsheetId = spreadsheetUrl ? extractSpreadsheetId(spreadsheetUrl) : void 0;
|
|
99
123
|
if (!serviceAccountKeyJsonBase64) {
|
|
100
124
|
throw new Error(
|
|
101
125
|
`google-sheets: missing required parameter: ${parameters.serviceAccountKeyJsonBase64.slug}`
|
|
@@ -313,6 +337,16 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
313
337
|
}
|
|
314
338
|
};
|
|
315
339
|
|
|
340
|
+
// ../connectors/src/auth-types.ts
|
|
341
|
+
var AUTH_TYPES = {
|
|
342
|
+
OAUTH: "oauth",
|
|
343
|
+
API_KEY: "api-key",
|
|
344
|
+
JWT: "jwt",
|
|
345
|
+
SERVICE_ACCOUNT: "service-account",
|
|
346
|
+
PAT: "pat",
|
|
347
|
+
USER_PASSWORD: "user-password"
|
|
348
|
+
};
|
|
349
|
+
|
|
316
350
|
// ../connectors/src/connectors/google-sheets/setup.ts
|
|
317
351
|
var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
318
352
|
dataOverviewInstructions: {
|
|
@@ -325,6 +359,7 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
325
359
|
|
|
326
360
|
// ../connectors/src/connectors/google-sheets/tools/request.ts
|
|
327
361
|
import { z } from "zod";
|
|
362
|
+
init_utils();
|
|
328
363
|
var BASE_URL2 = "https://sheets.googleapis.com/v4/spreadsheets";
|
|
329
364
|
var REQUEST_TIMEOUT_MS = 6e4;
|
|
330
365
|
var inputSchema = z.object({
|
|
@@ -370,7 +405,8 @@ Authentication is handled automatically using a service account.
|
|
|
370
405
|
try {
|
|
371
406
|
const { GoogleAuth } = await import("google-auth-library");
|
|
372
407
|
const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
373
|
-
const
|
|
408
|
+
const spreadsheetUrl = parameters.spreadsheetUrl.tryGetValue(connection2);
|
|
409
|
+
const spreadsheetId = spreadsheetUrl ? extractSpreadsheetId(spreadsheetUrl) : void 0;
|
|
374
410
|
const credentials = JSON.parse(
|
|
375
411
|
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
376
412
|
);
|
|
@@ -424,7 +460,7 @@ Authentication is handled automatically using a service account.
|
|
|
424
460
|
var tools = { request: requestTool };
|
|
425
461
|
var googleSheetsConnector = new ConnectorPlugin({
|
|
426
462
|
slug: "google-sheets",
|
|
427
|
-
authType:
|
|
463
|
+
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
428
464
|
name: "Google Sheets",
|
|
429
465
|
description: "Connect to Google Sheets for spreadsheet data access using a service account.",
|
|
430
466
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/1UPQuggyiZmbb26CuaSr2h/032770e8739b183fa00b7625f024e536/google-sheets.svg",
|
|
@@ -554,6 +590,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
554
590
|
return process.env[envVarName] || void 0;
|
|
555
591
|
}
|
|
556
592
|
|
|
593
|
+
// src/connector-client/proxy-fetch.ts
|
|
594
|
+
import { getContext } from "hono/context-storage";
|
|
595
|
+
import { getCookie } from "hono/cookie";
|
|
596
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
597
|
+
function createSandboxProxyFetch(connectionId) {
|
|
598
|
+
return async (input, init) => {
|
|
599
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
600
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
601
|
+
if (!token || !sandboxId) {
|
|
602
|
+
throw new Error(
|
|
603
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
607
|
+
const originalMethod = init?.method ?? "GET";
|
|
608
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
609
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
610
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
611
|
+
return fetch(proxyUrl, {
|
|
612
|
+
method: "POST",
|
|
613
|
+
headers: {
|
|
614
|
+
"Content-Type": "application/json",
|
|
615
|
+
Authorization: `Bearer ${token}`
|
|
616
|
+
},
|
|
617
|
+
body: JSON.stringify({
|
|
618
|
+
url: originalUrl,
|
|
619
|
+
method: originalMethod,
|
|
620
|
+
body: originalBody
|
|
621
|
+
})
|
|
622
|
+
});
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
626
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
627
|
+
if (!projectId) {
|
|
628
|
+
throw new Error(
|
|
629
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
633
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
634
|
+
return async (input, init) => {
|
|
635
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
636
|
+
const originalMethod = init?.method ?? "GET";
|
|
637
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
638
|
+
const c = getContext();
|
|
639
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
640
|
+
if (!appSession) {
|
|
641
|
+
throw new Error(
|
|
642
|
+
"No authentication method available for connection proxy."
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
return fetch(proxyUrl, {
|
|
646
|
+
method: "POST",
|
|
647
|
+
headers: {
|
|
648
|
+
"Content-Type": "application/json",
|
|
649
|
+
Authorization: `Bearer ${appSession}`
|
|
650
|
+
},
|
|
651
|
+
body: JSON.stringify({
|
|
652
|
+
url: originalUrl,
|
|
653
|
+
method: originalMethod,
|
|
654
|
+
body: originalBody
|
|
655
|
+
})
|
|
656
|
+
});
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function createProxyFetch(connectionId) {
|
|
660
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
661
|
+
return createSandboxProxyFetch(connectionId);
|
|
662
|
+
}
|
|
663
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
664
|
+
}
|
|
665
|
+
|
|
557
666
|
// src/connectors/create-connector-sdk.ts
|
|
558
667
|
function loadConnectionsSync() {
|
|
559
668
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -587,7 +696,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
587
696
|
if (val !== void 0) params[param.slug] = val;
|
|
588
697
|
}
|
|
589
698
|
}
|
|
590
|
-
return createClient2(params);
|
|
699
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
591
700
|
};
|
|
592
701
|
}
|
|
593
702
|
|
|
@@ -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.GrafanaConnectorSdk;
|
|
4
4
|
|
|
5
5
|
export { connection };
|