@squadbase/vite-server 0.1.3-dev.7 → 0.1.3-dev.9
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 +1532 -1335
- package/dist/connectors/airtable-oauth.js +74 -1
- package/dist/connectors/airtable.js +74 -1
- package/dist/connectors/amplitude.js +74 -1
- package/dist/connectors/anthropic.js +74 -1
- package/dist/connectors/asana.js +74 -1
- package/dist/connectors/attio.js +74 -1
- package/dist/connectors/customerio.js +74 -1
- package/dist/connectors/dbt.js +74 -1
- package/dist/connectors/gemini.js +74 -1
- package/dist/connectors/gmail-oauth.js +74 -1
- package/dist/connectors/gmail.js +74 -1
- package/dist/connectors/google-ads-oauth.js +74 -1
- package/dist/connectors/google-ads.js +74 -1
- package/dist/connectors/google-analytics-oauth.js +87 -6
- package/dist/connectors/google-analytics.js +117 -46
- package/dist/connectors/google-calendar-oauth.js +74 -1
- package/dist/connectors/google-calendar.d.ts +1 -8
- package/dist/connectors/google-calendar.js +316 -64
- package/dist/connectors/google-sheets-oauth.js +85 -18
- package/dist/connectors/google-sheets.js +75 -2
- package/dist/connectors/grafana.js +74 -1
- package/dist/connectors/hubspot-oauth.js +74 -1
- package/dist/connectors/hubspot.js +74 -1
- package/dist/connectors/intercom-oauth.js +74 -1
- package/dist/connectors/intercom.js +74 -1
- package/dist/connectors/jira-api-key.js +74 -1
- package/dist/connectors/kintone-api-token.js +74 -1
- package/dist/connectors/kintone.js +74 -1
- package/dist/connectors/linkedin-ads-oauth.js +74 -1
- package/dist/connectors/linkedin-ads.js +74 -1
- package/dist/connectors/mailchimp-oauth.js +74 -1
- package/dist/connectors/mailchimp.js +74 -1
- package/dist/connectors/notion-oauth.js +74 -1
- package/dist/connectors/notion.js +74 -1
- package/dist/connectors/openai.js +74 -1
- package/dist/connectors/shopify-oauth.js +74 -1
- package/dist/connectors/shopify.js +74 -1
- package/dist/connectors/stripe-api-key.js +74 -1
- package/dist/connectors/stripe-oauth.js +74 -1
- package/dist/connectors/wix-store.js +74 -1
- package/dist/connectors/zendesk-oauth.js +74 -1
- package/dist/connectors/zendesk.js +74 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1568 -1335
- package/dist/main.js +1567 -1333
- package/dist/vite-plugin.js +1483 -1286
- package/package.json +1 -1
|
@@ -514,6 +514,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
514
514
|
return process.env[envVarName] || void 0;
|
|
515
515
|
}
|
|
516
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
|
+
|
|
517
590
|
// src/connectors/create-connector-sdk.ts
|
|
518
591
|
function loadConnectionsSync() {
|
|
519
592
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -547,7 +620,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
547
620
|
if (val !== void 0) params[param.slug] = val;
|
|
548
621
|
}
|
|
549
622
|
}
|
|
550
|
-
return createClient2(params);
|
|
623
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
551
624
|
};
|
|
552
625
|
}
|
|
553
626
|
|
|
@@ -544,6 +544,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
544
544
|
return process.env[envVarName] || void 0;
|
|
545
545
|
}
|
|
546
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
|
+
|
|
547
620
|
// src/connectors/create-connector-sdk.ts
|
|
548
621
|
function loadConnectionsSync() {
|
|
549
622
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -577,7 +650,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
577
650
|
if (val !== void 0) params[param.slug] = val;
|
|
578
651
|
}
|
|
579
652
|
}
|
|
580
|
-
return createClient2(params);
|
|
653
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
581
654
|
};
|
|
582
655
|
}
|
|
583
656
|
|
|
@@ -535,6 +535,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
535
535
|
return process.env[envVarName] || void 0;
|
|
536
536
|
}
|
|
537
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
|
+
|
|
538
611
|
// src/connectors/create-connector-sdk.ts
|
|
539
612
|
function loadConnectionsSync() {
|
|
540
613
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -568,7 +641,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
568
641
|
if (val !== void 0) params[param.slug] = val;
|
|
569
642
|
}
|
|
570
643
|
}
|
|
571
|
-
return createClient2(params);
|
|
644
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
572
645
|
};
|
|
573
646
|
}
|
|
574
647
|
|
|
@@ -219,6 +219,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
219
219
|
return process.env[envVarName] || void 0;
|
|
220
220
|
}
|
|
221
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
|
+
|
|
222
295
|
// src/connectors/create-connector-sdk.ts
|
|
223
296
|
function loadConnectionsSync() {
|
|
224
297
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -252,7 +325,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
252
325
|
if (val !== void 0) params[param.slug] = val;
|
|
253
326
|
}
|
|
254
327
|
}
|
|
255
|
-
return createClient2(params);
|
|
328
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
256
329
|
};
|
|
257
330
|
}
|
|
258
331
|
|
package/dist/connectors/asana.js
CHANGED
|
@@ -627,6 +627,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
627
627
|
return process.env[envVarName] || void 0;
|
|
628
628
|
}
|
|
629
629
|
|
|
630
|
+
// src/connector-client/proxy-fetch.ts
|
|
631
|
+
import { getContext } from "hono/context-storage";
|
|
632
|
+
import { getCookie } from "hono/cookie";
|
|
633
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
634
|
+
function createSandboxProxyFetch(connectionId) {
|
|
635
|
+
return async (input, init) => {
|
|
636
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
637
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
638
|
+
if (!token || !sandboxId) {
|
|
639
|
+
throw new Error(
|
|
640
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
641
|
+
);
|
|
642
|
+
}
|
|
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 baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
647
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
648
|
+
return fetch(proxyUrl, {
|
|
649
|
+
method: "POST",
|
|
650
|
+
headers: {
|
|
651
|
+
"Content-Type": "application/json",
|
|
652
|
+
Authorization: `Bearer ${token}`
|
|
653
|
+
},
|
|
654
|
+
body: JSON.stringify({
|
|
655
|
+
url: originalUrl,
|
|
656
|
+
method: originalMethod,
|
|
657
|
+
body: originalBody
|
|
658
|
+
})
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
663
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
664
|
+
if (!projectId) {
|
|
665
|
+
throw new Error(
|
|
666
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
670
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
671
|
+
return async (input, init) => {
|
|
672
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
673
|
+
const originalMethod = init?.method ?? "GET";
|
|
674
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
675
|
+
const c = getContext();
|
|
676
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
677
|
+
if (!appSession) {
|
|
678
|
+
throw new Error(
|
|
679
|
+
"No authentication method available for connection proxy."
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
return fetch(proxyUrl, {
|
|
683
|
+
method: "POST",
|
|
684
|
+
headers: {
|
|
685
|
+
"Content-Type": "application/json",
|
|
686
|
+
Authorization: `Bearer ${appSession}`
|
|
687
|
+
},
|
|
688
|
+
body: JSON.stringify({
|
|
689
|
+
url: originalUrl,
|
|
690
|
+
method: originalMethod,
|
|
691
|
+
body: originalBody
|
|
692
|
+
})
|
|
693
|
+
});
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
function createProxyFetch(connectionId) {
|
|
697
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
698
|
+
return createSandboxProxyFetch(connectionId);
|
|
699
|
+
}
|
|
700
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
701
|
+
}
|
|
702
|
+
|
|
630
703
|
// src/connectors/create-connector-sdk.ts
|
|
631
704
|
function loadConnectionsSync() {
|
|
632
705
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -660,7 +733,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
660
733
|
if (val !== void 0) params[param.slug] = val;
|
|
661
734
|
}
|
|
662
735
|
}
|
|
663
|
-
return createClient2(params);
|
|
736
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
664
737
|
};
|
|
665
738
|
}
|
|
666
739
|
|
package/dist/connectors/attio.js
CHANGED
|
@@ -501,6 +501,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
501
501
|
return process.env[envVarName] || void 0;
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
+
// src/connector-client/proxy-fetch.ts
|
|
505
|
+
import { getContext } from "hono/context-storage";
|
|
506
|
+
import { getCookie } from "hono/cookie";
|
|
507
|
+
var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
|
|
508
|
+
function createSandboxProxyFetch(connectionId) {
|
|
509
|
+
return async (input, init) => {
|
|
510
|
+
const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
|
|
511
|
+
const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
|
|
512
|
+
if (!token || !sandboxId) {
|
|
513
|
+
throw new Error(
|
|
514
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
518
|
+
const originalMethod = init?.method ?? "GET";
|
|
519
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
520
|
+
const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
|
|
521
|
+
const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
522
|
+
return fetch(proxyUrl, {
|
|
523
|
+
method: "POST",
|
|
524
|
+
headers: {
|
|
525
|
+
"Content-Type": "application/json",
|
|
526
|
+
Authorization: `Bearer ${token}`
|
|
527
|
+
},
|
|
528
|
+
body: JSON.stringify({
|
|
529
|
+
url: originalUrl,
|
|
530
|
+
method: originalMethod,
|
|
531
|
+
body: originalBody
|
|
532
|
+
})
|
|
533
|
+
});
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function createDeployedAppProxyFetch(connectionId) {
|
|
537
|
+
const projectId = process.env["SQUADBASE_PROJECT_ID"];
|
|
538
|
+
if (!projectId) {
|
|
539
|
+
throw new Error(
|
|
540
|
+
"Connection proxy is not configured. Please check your deployment settings."
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
|
|
544
|
+
const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
|
|
545
|
+
return async (input, init) => {
|
|
546
|
+
const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
547
|
+
const originalMethod = init?.method ?? "GET";
|
|
548
|
+
const originalBody = init?.body ? JSON.parse(init.body) : void 0;
|
|
549
|
+
const c = getContext();
|
|
550
|
+
const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
|
|
551
|
+
if (!appSession) {
|
|
552
|
+
throw new Error(
|
|
553
|
+
"No authentication method available for connection proxy."
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
return fetch(proxyUrl, {
|
|
557
|
+
method: "POST",
|
|
558
|
+
headers: {
|
|
559
|
+
"Content-Type": "application/json",
|
|
560
|
+
Authorization: `Bearer ${appSession}`
|
|
561
|
+
},
|
|
562
|
+
body: JSON.stringify({
|
|
563
|
+
url: originalUrl,
|
|
564
|
+
method: originalMethod,
|
|
565
|
+
body: originalBody
|
|
566
|
+
})
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function createProxyFetch(connectionId) {
|
|
571
|
+
if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
|
|
572
|
+
return createSandboxProxyFetch(connectionId);
|
|
573
|
+
}
|
|
574
|
+
return createDeployedAppProxyFetch(connectionId);
|
|
575
|
+
}
|
|
576
|
+
|
|
504
577
|
// src/connectors/create-connector-sdk.ts
|
|
505
578
|
function loadConnectionsSync() {
|
|
506
579
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -534,7 +607,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
534
607
|
if (val !== void 0) params[param.slug] = val;
|
|
535
608
|
}
|
|
536
609
|
}
|
|
537
|
-
return createClient2(params);
|
|
610
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
538
611
|
};
|
|
539
612
|
}
|
|
540
613
|
|
|
@@ -599,6 +599,79 @@ function resolveEnvVarOptional(entry, key) {
|
|
|
599
599
|
return process.env[envVarName] || void 0;
|
|
600
600
|
}
|
|
601
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
|
+
|
|
602
675
|
// src/connectors/create-connector-sdk.ts
|
|
603
676
|
function loadConnectionsSync() {
|
|
604
677
|
const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
|
|
@@ -632,7 +705,7 @@ function createConnectorSdk(plugin, createClient2) {
|
|
|
632
705
|
if (val !== void 0) params[param.slug] = val;
|
|
633
706
|
}
|
|
634
707
|
}
|
|
635
|
-
return createClient2(params);
|
|
708
|
+
return createClient2(params, createProxyFetch(connectionId));
|
|
636
709
|
};
|
|
637
710
|
}
|
|
638
711
|
|