@squadbase/vite-server 0.1.3-dev.6 → 0.1.3-dev.8

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.
Files changed (49) hide show
  1. package/dist/cli/index.js +1858 -1340
  2. package/dist/connectors/airtable-oauth.js +74 -1
  3. package/dist/connectors/airtable.js +74 -1
  4. package/dist/connectors/amplitude.js +74 -1
  5. package/dist/connectors/anthropic.js +74 -1
  6. package/dist/connectors/asana.js +74 -1
  7. package/dist/connectors/attio.js +74 -1
  8. package/dist/connectors/customerio.js +74 -1
  9. package/dist/connectors/dbt.js +74 -1
  10. package/dist/connectors/gemini.js +74 -1
  11. package/dist/connectors/gmail-oauth.js +74 -1
  12. package/dist/connectors/gmail.js +74 -1
  13. package/dist/connectors/google-ads-oauth.js +74 -1
  14. package/dist/connectors/google-ads.js +74 -1
  15. package/dist/connectors/google-analytics-oauth.js +87 -6
  16. package/dist/connectors/google-analytics.js +117 -52
  17. package/dist/connectors/google-calendar-oauth.js +75 -2
  18. package/dist/connectors/google-calendar.d.ts +1 -8
  19. package/dist/connectors/google-calendar.js +363 -60
  20. package/dist/connectors/google-sheets-oauth.js +141 -31
  21. package/dist/connectors/google-sheets.js +108 -9
  22. package/dist/connectors/grafana.d.ts +5 -0
  23. package/dist/connectors/grafana.js +638 -0
  24. package/dist/connectors/hubspot-oauth.js +74 -1
  25. package/dist/connectors/hubspot.js +74 -1
  26. package/dist/connectors/intercom-oauth.js +74 -1
  27. package/dist/connectors/intercom.js +74 -1
  28. package/dist/connectors/jira-api-key.js +74 -1
  29. package/dist/connectors/kintone-api-token.js +74 -1
  30. package/dist/connectors/kintone.js +74 -1
  31. package/dist/connectors/linkedin-ads-oauth.js +74 -1
  32. package/dist/connectors/linkedin-ads.js +74 -1
  33. package/dist/connectors/mailchimp-oauth.js +74 -1
  34. package/dist/connectors/mailchimp.js +74 -1
  35. package/dist/connectors/notion-oauth.js +74 -1
  36. package/dist/connectors/notion.js +74 -1
  37. package/dist/connectors/openai.js +74 -1
  38. package/dist/connectors/shopify-oauth.js +74 -1
  39. package/dist/connectors/shopify.js +74 -1
  40. package/dist/connectors/stripe-api-key.js +74 -1
  41. package/dist/connectors/stripe-oauth.js +74 -1
  42. package/dist/connectors/wix-store.js +74 -1
  43. package/dist/connectors/zendesk-oauth.js +74 -1
  44. package/dist/connectors/zendesk.js +74 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js +1808 -1291
  47. package/dist/main.js +1807 -1289
  48. package/dist/vite-plugin.js +1807 -1289
  49. package/package.json +5 -1
@@ -435,6 +435,79 @@ function resolveEnvVarOptional(entry, key) {
435
435
  return process.env[envVarName] || void 0;
436
436
  }
437
437
 
438
+ // src/connector-client/proxy-fetch.ts
439
+ import { getContext } from "hono/context-storage";
440
+ import { getCookie } from "hono/cookie";
441
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
442
+ function createSandboxProxyFetch(connectionId) {
443
+ return async (input, init) => {
444
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
445
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
446
+ if (!token || !sandboxId) {
447
+ throw new Error(
448
+ "Connection proxy is not configured. Please check your deployment settings."
449
+ );
450
+ }
451
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
452
+ const originalMethod = init?.method ?? "GET";
453
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
454
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
455
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
456
+ return fetch(proxyUrl, {
457
+ method: "POST",
458
+ headers: {
459
+ "Content-Type": "application/json",
460
+ Authorization: `Bearer ${token}`
461
+ },
462
+ body: JSON.stringify({
463
+ url: originalUrl,
464
+ method: originalMethod,
465
+ body: originalBody
466
+ })
467
+ });
468
+ };
469
+ }
470
+ function createDeployedAppProxyFetch(connectionId) {
471
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
472
+ if (!projectId) {
473
+ throw new Error(
474
+ "Connection proxy is not configured. Please check your deployment settings."
475
+ );
476
+ }
477
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
478
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
479
+ return async (input, init) => {
480
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
481
+ const originalMethod = init?.method ?? "GET";
482
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
483
+ const c = getContext();
484
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
485
+ if (!appSession) {
486
+ throw new Error(
487
+ "No authentication method available for connection proxy."
488
+ );
489
+ }
490
+ return fetch(proxyUrl, {
491
+ method: "POST",
492
+ headers: {
493
+ "Content-Type": "application/json",
494
+ Authorization: `Bearer ${appSession}`
495
+ },
496
+ body: JSON.stringify({
497
+ url: originalUrl,
498
+ method: originalMethod,
499
+ body: originalBody
500
+ })
501
+ });
502
+ };
503
+ }
504
+ function createProxyFetch(connectionId) {
505
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
506
+ return createSandboxProxyFetch(connectionId);
507
+ }
508
+ return createDeployedAppProxyFetch(connectionId);
509
+ }
510
+
438
511
  // src/connectors/create-connector-sdk.ts
439
512
  function loadConnectionsSync() {
440
513
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -468,7 +541,7 @@ function createConnectorSdk(plugin, createClient2) {
468
541
  if (val !== void 0) params[param.slug] = val;
469
542
  }
470
543
  }
471
- return createClient2(params);
544
+ return createClient2(params, createProxyFetch(connectionId));
472
545
  };
473
546
  }
474
547
 
@@ -688,6 +688,79 @@ function resolveEnvVarOptional(entry, key) {
688
688
  return process.env[envVarName] || void 0;
689
689
  }
690
690
 
691
+ // src/connector-client/proxy-fetch.ts
692
+ import { getContext } from "hono/context-storage";
693
+ import { getCookie } from "hono/cookie";
694
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
695
+ function createSandboxProxyFetch(connectionId) {
696
+ return async (input, init) => {
697
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
698
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
699
+ if (!token || !sandboxId) {
700
+ throw new Error(
701
+ "Connection proxy is not configured. Please check your deployment settings."
702
+ );
703
+ }
704
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
705
+ const originalMethod = init?.method ?? "GET";
706
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
707
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
708
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
709
+ return fetch(proxyUrl, {
710
+ method: "POST",
711
+ headers: {
712
+ "Content-Type": "application/json",
713
+ Authorization: `Bearer ${token}`
714
+ },
715
+ body: JSON.stringify({
716
+ url: originalUrl,
717
+ method: originalMethod,
718
+ body: originalBody
719
+ })
720
+ });
721
+ };
722
+ }
723
+ function createDeployedAppProxyFetch(connectionId) {
724
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
725
+ if (!projectId) {
726
+ throw new Error(
727
+ "Connection proxy is not configured. Please check your deployment settings."
728
+ );
729
+ }
730
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
731
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
732
+ return async (input, init) => {
733
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
734
+ const originalMethod = init?.method ?? "GET";
735
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
736
+ const c = getContext();
737
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
738
+ if (!appSession) {
739
+ throw new Error(
740
+ "No authentication method available for connection proxy."
741
+ );
742
+ }
743
+ return fetch(proxyUrl, {
744
+ method: "POST",
745
+ headers: {
746
+ "Content-Type": "application/json",
747
+ Authorization: `Bearer ${appSession}`
748
+ },
749
+ body: JSON.stringify({
750
+ url: originalUrl,
751
+ method: originalMethod,
752
+ body: originalBody
753
+ })
754
+ });
755
+ };
756
+ }
757
+ function createProxyFetch(connectionId) {
758
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
759
+ return createSandboxProxyFetch(connectionId);
760
+ }
761
+ return createDeployedAppProxyFetch(connectionId);
762
+ }
763
+
691
764
  // src/connectors/create-connector-sdk.ts
692
765
  function loadConnectionsSync() {
693
766
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -721,7 +794,7 @@ function createConnectorSdk(plugin, createClient2) {
721
794
  if (val !== void 0) params[param.slug] = val;
722
795
  }
723
796
  }
724
- return createClient2(params);
797
+ return createClient2(params, createProxyFetch(connectionId));
725
798
  };
726
799
  }
727
800
 
@@ -483,6 +483,79 @@ function resolveEnvVarOptional(entry, key) {
483
483
  return process.env[envVarName] || void 0;
484
484
  }
485
485
 
486
+ // src/connector-client/proxy-fetch.ts
487
+ import { getContext } from "hono/context-storage";
488
+ import { getCookie } from "hono/cookie";
489
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
490
+ function createSandboxProxyFetch(connectionId) {
491
+ return async (input, init) => {
492
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
493
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
494
+ if (!token || !sandboxId) {
495
+ throw new Error(
496
+ "Connection proxy is not configured. Please check your deployment settings."
497
+ );
498
+ }
499
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
500
+ const originalMethod = init?.method ?? "GET";
501
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
502
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
503
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
504
+ return fetch(proxyUrl, {
505
+ method: "POST",
506
+ headers: {
507
+ "Content-Type": "application/json",
508
+ Authorization: `Bearer ${token}`
509
+ },
510
+ body: JSON.stringify({
511
+ url: originalUrl,
512
+ method: originalMethod,
513
+ body: originalBody
514
+ })
515
+ });
516
+ };
517
+ }
518
+ function createDeployedAppProxyFetch(connectionId) {
519
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
520
+ if (!projectId) {
521
+ throw new Error(
522
+ "Connection proxy is not configured. Please check your deployment settings."
523
+ );
524
+ }
525
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
526
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
527
+ return async (input, init) => {
528
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
529
+ const originalMethod = init?.method ?? "GET";
530
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
531
+ const c = getContext();
532
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
533
+ if (!appSession) {
534
+ throw new Error(
535
+ "No authentication method available for connection proxy."
536
+ );
537
+ }
538
+ return fetch(proxyUrl, {
539
+ method: "POST",
540
+ headers: {
541
+ "Content-Type": "application/json",
542
+ Authorization: `Bearer ${appSession}`
543
+ },
544
+ body: JSON.stringify({
545
+ url: originalUrl,
546
+ method: originalMethod,
547
+ body: originalBody
548
+ })
549
+ });
550
+ };
551
+ }
552
+ function createProxyFetch(connectionId) {
553
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
554
+ return createSandboxProxyFetch(connectionId);
555
+ }
556
+ return createDeployedAppProxyFetch(connectionId);
557
+ }
558
+
486
559
  // src/connectors/create-connector-sdk.ts
487
560
  function loadConnectionsSync() {
488
561
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -516,7 +589,7 @@ function createConnectorSdk(plugin, createClient2) {
516
589
  if (val !== void 0) params[param.slug] = val;
517
590
  }
518
591
  }
519
- return createClient2(params);
592
+ return createClient2(params, createProxyFetch(connectionId));
520
593
  };
521
594
  }
522
595
 
@@ -442,6 +442,79 @@ function resolveEnvVarOptional(entry, key) {
442
442
  return process.env[envVarName] || void 0;
443
443
  }
444
444
 
445
+ // src/connector-client/proxy-fetch.ts
446
+ import { getContext } from "hono/context-storage";
447
+ import { getCookie } from "hono/cookie";
448
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
449
+ function createSandboxProxyFetch(connectionId) {
450
+ return async (input, init) => {
451
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
452
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
453
+ if (!token || !sandboxId) {
454
+ throw new Error(
455
+ "Connection proxy is not configured. Please check your deployment settings."
456
+ );
457
+ }
458
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
459
+ const originalMethod = init?.method ?? "GET";
460
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
461
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
462
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
463
+ return fetch(proxyUrl, {
464
+ method: "POST",
465
+ headers: {
466
+ "Content-Type": "application/json",
467
+ Authorization: `Bearer ${token}`
468
+ },
469
+ body: JSON.stringify({
470
+ url: originalUrl,
471
+ method: originalMethod,
472
+ body: originalBody
473
+ })
474
+ });
475
+ };
476
+ }
477
+ function createDeployedAppProxyFetch(connectionId) {
478
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
479
+ if (!projectId) {
480
+ throw new Error(
481
+ "Connection proxy is not configured. Please check your deployment settings."
482
+ );
483
+ }
484
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
485
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
486
+ return async (input, init) => {
487
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
488
+ const originalMethod = init?.method ?? "GET";
489
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
490
+ const c = getContext();
491
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
492
+ if (!appSession) {
493
+ throw new Error(
494
+ "No authentication method available for connection proxy."
495
+ );
496
+ }
497
+ return fetch(proxyUrl, {
498
+ method: "POST",
499
+ headers: {
500
+ "Content-Type": "application/json",
501
+ Authorization: `Bearer ${appSession}`
502
+ },
503
+ body: JSON.stringify({
504
+ url: originalUrl,
505
+ method: originalMethod,
506
+ body: originalBody
507
+ })
508
+ });
509
+ };
510
+ }
511
+ function createProxyFetch(connectionId) {
512
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
513
+ return createSandboxProxyFetch(connectionId);
514
+ }
515
+ return createDeployedAppProxyFetch(connectionId);
516
+ }
517
+
445
518
  // src/connectors/create-connector-sdk.ts
446
519
  function loadConnectionsSync() {
447
520
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -475,7 +548,7 @@ function createConnectorSdk(plugin, createClient2) {
475
548
  if (val !== void 0) params[param.slug] = val;
476
549
  }
477
550
  }
478
- return createClient2(params);
551
+ return createClient2(params, createProxyFetch(connectionId));
479
552
  };
480
553
  }
481
554
 
@@ -577,6 +577,79 @@ function resolveEnvVarOptional(entry, key) {
577
577
  return process.env[envVarName] || void 0;
578
578
  }
579
579
 
580
+ // src/connector-client/proxy-fetch.ts
581
+ import { getContext } from "hono/context-storage";
582
+ import { getCookie } from "hono/cookie";
583
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
584
+ function createSandboxProxyFetch(connectionId) {
585
+ return async (input, init) => {
586
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
587
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
588
+ if (!token || !sandboxId) {
589
+ throw new Error(
590
+ "Connection proxy is not configured. Please check your deployment settings."
591
+ );
592
+ }
593
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
594
+ const originalMethod = init?.method ?? "GET";
595
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
596
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
597
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
598
+ return fetch(proxyUrl, {
599
+ method: "POST",
600
+ headers: {
601
+ "Content-Type": "application/json",
602
+ Authorization: `Bearer ${token}`
603
+ },
604
+ body: JSON.stringify({
605
+ url: originalUrl,
606
+ method: originalMethod,
607
+ body: originalBody
608
+ })
609
+ });
610
+ };
611
+ }
612
+ function createDeployedAppProxyFetch(connectionId) {
613
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
614
+ if (!projectId) {
615
+ throw new Error(
616
+ "Connection proxy is not configured. Please check your deployment settings."
617
+ );
618
+ }
619
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
620
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
621
+ return async (input, init) => {
622
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
623
+ const originalMethod = init?.method ?? "GET";
624
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
625
+ const c = getContext();
626
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
627
+ if (!appSession) {
628
+ throw new Error(
629
+ "No authentication method available for connection proxy."
630
+ );
631
+ }
632
+ return fetch(proxyUrl, {
633
+ method: "POST",
634
+ headers: {
635
+ "Content-Type": "application/json",
636
+ Authorization: `Bearer ${appSession}`
637
+ },
638
+ body: JSON.stringify({
639
+ url: originalUrl,
640
+ method: originalMethod,
641
+ body: originalBody
642
+ })
643
+ });
644
+ };
645
+ }
646
+ function createProxyFetch(connectionId) {
647
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
648
+ return createSandboxProxyFetch(connectionId);
649
+ }
650
+ return createDeployedAppProxyFetch(connectionId);
651
+ }
652
+
580
653
  // src/connectors/create-connector-sdk.ts
581
654
  function loadConnectionsSync() {
582
655
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -610,7 +683,7 @@ function createConnectorSdk(plugin, createClient2) {
610
683
  if (val !== void 0) params[param.slug] = val;
611
684
  }
612
685
  }
613
- return createClient2(params);
686
+ return createClient2(params, createProxyFetch(connectionId));
614
687
  };
615
688
  }
616
689
 
@@ -462,6 +462,79 @@ function resolveEnvVarOptional(entry, key) {
462
462
  return process.env[envVarName] || void 0;
463
463
  }
464
464
 
465
+ // src/connector-client/proxy-fetch.ts
466
+ import { getContext } from "hono/context-storage";
467
+ import { getCookie } from "hono/cookie";
468
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
469
+ function createSandboxProxyFetch(connectionId) {
470
+ return async (input, init) => {
471
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
472
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
473
+ if (!token || !sandboxId) {
474
+ throw new Error(
475
+ "Connection proxy is not configured. Please check your deployment settings."
476
+ );
477
+ }
478
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
479
+ const originalMethod = init?.method ?? "GET";
480
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
481
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
482
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
483
+ return fetch(proxyUrl, {
484
+ method: "POST",
485
+ headers: {
486
+ "Content-Type": "application/json",
487
+ Authorization: `Bearer ${token}`
488
+ },
489
+ body: JSON.stringify({
490
+ url: originalUrl,
491
+ method: originalMethod,
492
+ body: originalBody
493
+ })
494
+ });
495
+ };
496
+ }
497
+ function createDeployedAppProxyFetch(connectionId) {
498
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
499
+ if (!projectId) {
500
+ throw new Error(
501
+ "Connection proxy is not configured. Please check your deployment settings."
502
+ );
503
+ }
504
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
505
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
506
+ return async (input, init) => {
507
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
508
+ const originalMethod = init?.method ?? "GET";
509
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
510
+ const c = getContext();
511
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
512
+ if (!appSession) {
513
+ throw new Error(
514
+ "No authentication method available for connection proxy."
515
+ );
516
+ }
517
+ return fetch(proxyUrl, {
518
+ method: "POST",
519
+ headers: {
520
+ "Content-Type": "application/json",
521
+ Authorization: `Bearer ${appSession}`
522
+ },
523
+ body: JSON.stringify({
524
+ url: originalUrl,
525
+ method: originalMethod,
526
+ body: originalBody
527
+ })
528
+ });
529
+ };
530
+ }
531
+ function createProxyFetch(connectionId) {
532
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
533
+ return createSandboxProxyFetch(connectionId);
534
+ }
535
+ return createDeployedAppProxyFetch(connectionId);
536
+ }
537
+
465
538
  // src/connectors/create-connector-sdk.ts
466
539
  function loadConnectionsSync() {
467
540
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -495,7 +568,7 @@ function createConnectorSdk(plugin, createClient2) {
495
568
  if (val !== void 0) params[param.slug] = val;
496
569
  }
497
570
  }
498
- return createClient2(params);
571
+ return createClient2(params, createProxyFetch(connectionId));
499
572
  };
500
573
  }
501
574
 
@@ -597,6 +597,79 @@ function resolveEnvVarOptional(entry, key) {
597
597
  return process.env[envVarName] || void 0;
598
598
  }
599
599
 
600
+ // src/connector-client/proxy-fetch.ts
601
+ import { getContext } from "hono/context-storage";
602
+ import { getCookie } from "hono/cookie";
603
+ var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
604
+ function createSandboxProxyFetch(connectionId) {
605
+ return async (input, init) => {
606
+ const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
607
+ const sandboxId = process.env.INTERNAL_SQUADBASE_SANDBOX_ID;
608
+ if (!token || !sandboxId) {
609
+ throw new Error(
610
+ "Connection proxy is not configured. Please check your deployment settings."
611
+ );
612
+ }
613
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
614
+ const originalMethod = init?.method ?? "GET";
615
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
616
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
617
+ const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
618
+ return fetch(proxyUrl, {
619
+ method: "POST",
620
+ headers: {
621
+ "Content-Type": "application/json",
622
+ Authorization: `Bearer ${token}`
623
+ },
624
+ body: JSON.stringify({
625
+ url: originalUrl,
626
+ method: originalMethod,
627
+ body: originalBody
628
+ })
629
+ });
630
+ };
631
+ }
632
+ function createDeployedAppProxyFetch(connectionId) {
633
+ const projectId = process.env["SQUADBASE_PROJECT_ID"];
634
+ if (!projectId) {
635
+ throw new Error(
636
+ "Connection proxy is not configured. Please check your deployment settings."
637
+ );
638
+ }
639
+ const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
640
+ const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
641
+ return async (input, init) => {
642
+ const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
643
+ const originalMethod = init?.method ?? "GET";
644
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
645
+ const c = getContext();
646
+ const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
647
+ if (!appSession) {
648
+ throw new Error(
649
+ "No authentication method available for connection proxy."
650
+ );
651
+ }
652
+ return fetch(proxyUrl, {
653
+ method: "POST",
654
+ headers: {
655
+ "Content-Type": "application/json",
656
+ Authorization: `Bearer ${appSession}`
657
+ },
658
+ body: JSON.stringify({
659
+ url: originalUrl,
660
+ method: originalMethod,
661
+ body: originalBody
662
+ })
663
+ });
664
+ };
665
+ }
666
+ function createProxyFetch(connectionId) {
667
+ if (process.env.INTERNAL_SQUADBASE_SANDBOX_ID) {
668
+ return createSandboxProxyFetch(connectionId);
669
+ }
670
+ return createDeployedAppProxyFetch(connectionId);
671
+ }
672
+
600
673
  // src/connectors/create-connector-sdk.ts
601
674
  function loadConnectionsSync() {
602
675
  const filePath = process.env.CONNECTIONS_PATH ?? path.join(process.cwd(), ".squadbase/connections.json");
@@ -630,7 +703,7 @@ function createConnectorSdk(plugin, createClient2) {
630
703
  if (val !== void 0) params[param.slug] = val;
631
704
  }
632
705
  }
633
- return createClient2(params);
706
+ return createClient2(params, createProxyFetch(connectionId));
634
707
  };
635
708
  }
636
709
 
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ interface AirtableRecord {
39
39
  declare function createAirtableClient(entry: ConnectionEntry, slug: string): AirtableClient;
40
40
 
41
41
  interface GoogleAnalyticsClient {
42
- runReport(request: {
42
+ runReport(propertyId: string, request: {
43
43
  dateRanges: {
44
44
  startDate: string;
45
45
  endDate: string;