@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.
Files changed (48) hide show
  1. package/dist/cli/index.js +1532 -1335
  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 -46
  17. package/dist/connectors/google-calendar-oauth.js +74 -1
  18. package/dist/connectors/google-calendar.d.ts +1 -8
  19. package/dist/connectors/google-calendar.js +316 -64
  20. package/dist/connectors/google-sheets-oauth.js +85 -18
  21. package/dist/connectors/google-sheets.js +75 -2
  22. package/dist/connectors/grafana.js +74 -1
  23. package/dist/connectors/hubspot-oauth.js +74 -1
  24. package/dist/connectors/hubspot.js +74 -1
  25. package/dist/connectors/intercom-oauth.js +74 -1
  26. package/dist/connectors/intercom.js +74 -1
  27. package/dist/connectors/jira-api-key.js +74 -1
  28. package/dist/connectors/kintone-api-token.js +74 -1
  29. package/dist/connectors/kintone.js +74 -1
  30. package/dist/connectors/linkedin-ads-oauth.js +74 -1
  31. package/dist/connectors/linkedin-ads.js +74 -1
  32. package/dist/connectors/mailchimp-oauth.js +74 -1
  33. package/dist/connectors/mailchimp.js +74 -1
  34. package/dist/connectors/notion-oauth.js +74 -1
  35. package/dist/connectors/notion.js +74 -1
  36. package/dist/connectors/openai.js +74 -1
  37. package/dist/connectors/shopify-oauth.js +74 -1
  38. package/dist/connectors/shopify.js +74 -1
  39. package/dist/connectors/stripe-api-key.js +74 -1
  40. package/dist/connectors/stripe-oauth.js +74 -1
  41. package/dist/connectors/wix-store.js +74 -1
  42. package/dist/connectors/zendesk-oauth.js +74 -1
  43. package/dist/connectors/zendesk.js +74 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.js +1568 -1335
  46. package/dist/main.js +1567 -1333
  47. package/dist/vite-plugin.js +1483 -1286
  48. package/package.json +1 -1
@@ -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;