@squadbase/vite-server 0.1.12-dev.93b8799 → 0.1.17-dev.24af54e

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 (77) hide show
  1. package/dist/cli/index.js +12128 -934
  2. package/dist/connectors/airtable-oauth.js +248 -46
  3. package/dist/connectors/airtable.js +285 -51
  4. package/dist/connectors/amplitude.js +288 -47
  5. package/dist/connectors/anthropic.js +126 -47
  6. package/dist/connectors/asana.js +293 -49
  7. package/dist/connectors/attio.js +268 -49
  8. package/dist/connectors/aws-billing.js +253 -46
  9. package/dist/connectors/azure-sql.js +387 -102
  10. package/dist/connectors/backlog-api-key.js +283 -47
  11. package/dist/connectors/clickup.js +304 -49
  12. package/dist/connectors/cosmosdb.js +271 -50
  13. package/dist/connectors/customerio.js +285 -47
  14. package/dist/connectors/dbt.js +306 -47
  15. package/dist/connectors/freshdesk.js +308 -53
  16. package/dist/connectors/freshsales.js +299 -52
  17. package/dist/connectors/freshservice.js +327 -53
  18. package/dist/connectors/gamma.js +293 -52
  19. package/dist/connectors/gemini.js +125 -47
  20. package/dist/connectors/github.js +352 -49
  21. package/dist/connectors/gmail-oauth.js +170 -7
  22. package/dist/connectors/gmail.js +316 -47
  23. package/dist/connectors/google-ads.js +254 -46
  24. package/dist/connectors/google-analytics-oauth.js +276 -46
  25. package/dist/connectors/google-analytics.js +378 -49
  26. package/dist/connectors/google-audit-log.js +404 -47
  27. package/dist/connectors/google-calendar-oauth.js +225 -46
  28. package/dist/connectors/google-calendar.js +325 -47
  29. package/dist/connectors/google-docs.js +186 -6
  30. package/dist/connectors/google-drive.js +228 -5
  31. package/dist/connectors/google-search-console-oauth.js +222 -46
  32. package/dist/connectors/google-sheets.js +238 -47
  33. package/dist/connectors/google-slides.js +171 -6
  34. package/dist/connectors/grafana.js +298 -49
  35. package/dist/connectors/hubspot-oauth.js +174 -5
  36. package/dist/connectors/hubspot.js +272 -49
  37. package/dist/connectors/influxdb.js +382 -51
  38. package/dist/connectors/intercom-oauth.js +176 -5
  39. package/dist/connectors/intercom.js +268 -49
  40. package/dist/connectors/jdbc.js +728 -110
  41. package/dist/connectors/jira-api-key.js +292 -47
  42. package/dist/connectors/kintone-api-token.js +247 -47
  43. package/dist/connectors/kintone.js +294 -47
  44. package/dist/connectors/linear.js +296 -49
  45. package/dist/connectors/linkedin-ads.js +234 -50
  46. package/dist/connectors/mailchimp-oauth.js +234 -46
  47. package/dist/connectors/mailchimp.js +286 -49
  48. package/dist/connectors/meta-ads-oauth.js +239 -48
  49. package/dist/connectors/meta-ads.js +251 -50
  50. package/dist/connectors/mixpanel.js +304 -47
  51. package/dist/connectors/monday.js +326 -49
  52. package/dist/connectors/mongodb.js +285 -57
  53. package/dist/connectors/notion-oauth.js +197 -5
  54. package/dist/connectors/notion.js +289 -51
  55. package/dist/connectors/openai.js +125 -47
  56. package/dist/connectors/oracle.js +405 -103
  57. package/dist/connectors/outlook-oauth.js +170 -5
  58. package/dist/connectors/powerbi-oauth.js +217 -5
  59. package/dist/connectors/salesforce.js +350 -49
  60. package/dist/connectors/semrush.js +280 -49
  61. package/dist/connectors/sentry.js +255 -50
  62. package/dist/connectors/shopify-oauth.js +153 -5
  63. package/dist/connectors/shopify.js +323 -47
  64. package/dist/connectors/sqlserver.js +381 -102
  65. package/dist/connectors/stripe-api-key.js +235 -46
  66. package/dist/connectors/stripe-oauth.js +168 -5
  67. package/dist/connectors/supabase.js +269 -48
  68. package/dist/connectors/tableau.js +337 -206
  69. package/dist/connectors/tiktok-ads.js +245 -48
  70. package/dist/connectors/wix-store.js +286 -49
  71. package/dist/connectors/zendesk-oauth.js +205 -5
  72. package/dist/connectors/zendesk.js +324 -47
  73. package/dist/index.d.ts +149 -1
  74. package/dist/index.js +18297 -6886
  75. package/dist/main.js +12785 -1382
  76. package/dist/vite-plugin.js +12140 -936
  77. package/package.json +1 -1
@@ -1,48 +1,60 @@
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
+
1
6
  // ../connectors/src/parameter-definition.ts
2
- var ParameterDefinition = class {
3
- slug;
4
- name;
5
- description;
6
- envVarBaseKey;
7
- type;
8
- secret;
9
- required;
10
- constructor(config) {
11
- this.slug = config.slug;
12
- this.name = config.name;
13
- this.description = config.description;
14
- this.envVarBaseKey = config.envVarBaseKey;
15
- this.type = config.type;
16
- this.secret = config.secret;
17
- this.required = config.required;
18
- }
19
- /**
20
- * Get the parameter value from a ConnectorConnectionObject.
21
- */
22
- getValue(connection2) {
23
- const param = connection2.parameters.find(
24
- (p) => p.parameterSlug === this.slug
25
- );
26
- if (!param || param.value == null) {
27
- throw new Error(
28
- `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
29
- );
30
- }
31
- return param.value;
32
- }
33
- /**
34
- * Try to get the parameter value. Returns undefined if not found (for optional params).
35
- */
36
- tryGetValue(connection2) {
37
- const param = connection2.parameters.find(
38
- (p) => p.parameterSlug === this.slug
39
- );
40
- if (!param || param.value == null) return void 0;
41
- return param.value;
7
+ var ParameterDefinition;
8
+ var init_parameter_definition = __esm({
9
+ "../connectors/src/parameter-definition.ts"() {
10
+ "use strict";
11
+ ParameterDefinition = class {
12
+ slug;
13
+ name;
14
+ description;
15
+ envVarBaseKey;
16
+ type;
17
+ secret;
18
+ required;
19
+ constructor(config) {
20
+ this.slug = config.slug;
21
+ this.name = config.name;
22
+ this.description = config.description;
23
+ this.envVarBaseKey = config.envVarBaseKey;
24
+ this.type = config.type;
25
+ this.secret = config.secret;
26
+ this.required = config.required;
27
+ }
28
+ /**
29
+ * Get the parameter value from a ConnectorConnectionObject.
30
+ */
31
+ getValue(connection2) {
32
+ const param = connection2.parameters.find(
33
+ (p) => p.parameterSlug === this.slug
34
+ );
35
+ if (!param || param.value == null) {
36
+ throw new Error(
37
+ `Parameter "${this.slug}" not found or has no value in connection "${connection2.id}"`
38
+ );
39
+ }
40
+ return param.value;
41
+ }
42
+ /**
43
+ * Try to get the parameter value. Returns undefined if not found (for optional params).
44
+ */
45
+ tryGetValue(connection2) {
46
+ const param = connection2.parameters.find(
47
+ (p) => p.parameterSlug === this.slug
48
+ );
49
+ if (!param || param.value == null) return void 0;
50
+ return param.value;
51
+ }
52
+ };
42
53
  }
43
- };
54
+ });
44
55
 
45
56
  // ../connectors/src/connectors/google-audit-log/parameters.ts
57
+ init_parameter_definition();
46
58
  var parameters = {
47
59
  serviceAccountKeyJsonBase64: new ParameterDefinition({
48
60
  slug: "service-account-key-json-base64",
@@ -173,6 +185,20 @@ var ConnectorPlugin = class _ConnectorPlugin {
173
185
  * `runSetupFlow` from `setup-flow.ts`.
174
186
  */
175
187
  setup;
188
+ /**
189
+ * Opt-out of the default "verify before save" behavior on connection
190
+ * creation. The backend invokes `checkConnection` synchronously while
191
+ * creating the connection and aborts (no row inserted) if it fails — this
192
+ * flag disables that for connectors where the check cannot succeed pre-save:
193
+ *
194
+ * - `squadbase-db` populates `connection-url` only after Neon provisioning
195
+ * - OAuth connectors require an OAuth-aware proxyFetch keyed by the
196
+ * connectionId, which doesn't exist until the row is saved
197
+ *
198
+ * Exceptions are the explicit position; new credential-input connectors get
199
+ * the default verify-on-create behavior without opt-in.
200
+ */
201
+ skipConnectionCheckOnCreate;
176
202
  constructor(config) {
177
203
  this.slug = config.slug;
178
204
  this.authType = config.authType;
@@ -190,6 +216,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
190
216
  this.query = config.query;
191
217
  this.checkConnection = config.checkConnection;
192
218
  this.setup = config.setup;
219
+ this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
193
220
  }
194
221
  get connectorKey() {
195
222
  return _ConnectorPlugin.deriveKey(this.slug, this.authType);
@@ -254,6 +281,51 @@ var ConnectorPlugin = class _ConnectorPlugin {
254
281
  }
255
282
  };
256
283
 
284
+ // ../connectors/src/setup-flow.ts
285
+ async function runSetupFlow(flow, params, ctx, config) {
286
+ const runtime = {
287
+ params,
288
+ language: ctx.language,
289
+ config
290
+ };
291
+ let state = flow.initialState();
292
+ let answerIdx = 0;
293
+ for (const step of flow.steps) {
294
+ const ans = ctx.answers[answerIdx];
295
+ if (ans && ans.questionSlug === step.slug) {
296
+ state = step.applyAnswer(state, ans.answer);
297
+ answerIdx += 1;
298
+ continue;
299
+ }
300
+ if (step.type === "text") {
301
+ return {
302
+ type: "nextQuestion",
303
+ questionSlug: step.slug,
304
+ question: step.question[ctx.language],
305
+ questionType: "text"
306
+ };
307
+ }
308
+ const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
309
+ if (options.length === 0) {
310
+ continue;
311
+ }
312
+ return {
313
+ type: "nextQuestion",
314
+ questionSlug: step.slug,
315
+ question: step.question[ctx.language],
316
+ questionType: step.type,
317
+ options
318
+ };
319
+ }
320
+ const dataInvestigationResult = await flow.finalize(state, runtime);
321
+ return { type: "fulfilled", dataInvestigationResult };
322
+ }
323
+ async function resolveSetupSelection(params) {
324
+ const { selected, allSentinel, fetchAll, limit } = params;
325
+ const resolved = selected.includes(allSentinel) ? await fetchAll() : selected.filter((v) => v !== allSentinel);
326
+ return resolved.slice(0, limit);
327
+ }
328
+
257
329
  // ../connectors/src/auth-types.ts
258
330
  var AUTH_TYPES = {
259
331
  OAUTH: "oauth",
@@ -479,6 +551,221 @@ var googleAuditLogOnboarding = new ConnectorOnboarding({
479
551
  }
480
552
  });
481
553
 
554
+ // ../connectors/src/connectors/google-audit-log/setup-flow.ts
555
+ var ALL_APPLICATIONS = "__ALL_APPLICATIONS__";
556
+ var GOOGLE_AUDIT_LOG_SETUP_MAX_APPS = 24;
557
+ var APPLICATIONS = [
558
+ {
559
+ value: "access_transparency",
560
+ label: {
561
+ en: "Access Transparency \u2014 Google staff access events",
562
+ ja: "Access Transparency \u2014 Google \u30B9\u30BF\u30C3\u30D5\u306E\u30A2\u30AF\u30BB\u30B9\u8A18\u9332"
563
+ }
564
+ },
565
+ {
566
+ value: "admin",
567
+ label: {
568
+ en: "Admin \u2014 Workspace admin console actions",
569
+ ja: "Admin \u2014 \u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u306E\u64CD\u4F5C"
570
+ }
571
+ },
572
+ {
573
+ value: "calendar",
574
+ label: {
575
+ en: "Calendar \u2014 calendar events and sharing changes",
576
+ ja: "Calendar \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u30A4\u30D9\u30F3\u30C8\u3068\u5171\u6709\u8A2D\u5B9A\u306E\u5909\u66F4"
577
+ }
578
+ },
579
+ {
580
+ value: "chat",
581
+ label: {
582
+ en: "Chat \u2014 Google Chat messages and spaces",
583
+ ja: "Chat \u2014 Google Chat \u306E\u30E1\u30C3\u30BB\u30FC\u30B8\u3068\u30B9\u30DA\u30FC\u30B9"
584
+ }
585
+ },
586
+ {
587
+ value: "chrome",
588
+ label: {
589
+ en: "Chrome \u2014 Chrome browser/device management events",
590
+ ja: "Chrome \u2014 Chrome \u30D6\u30E9\u30A6\u30B6\u30FB\u30C7\u30D0\u30A4\u30B9\u7BA1\u7406\u30A4\u30D9\u30F3\u30C8"
591
+ }
592
+ },
593
+ {
594
+ value: "context_aware_access",
595
+ label: {
596
+ en: "Context-aware Access \u2014 access policy evaluations",
597
+ ja: "Context-aware Access \u2014 \u30A2\u30AF\u30BB\u30B9\u30DD\u30EA\u30B7\u30FC\u8A55\u4FA1"
598
+ }
599
+ },
600
+ {
601
+ value: "data_studio",
602
+ label: {
603
+ en: "Looker Studio \u2014 report/data source activity",
604
+ ja: "Looker Studio \u2014 \u30EC\u30DD\u30FC\u30C8 / \u30C7\u30FC\u30BF\u30BD\u30FC\u30B9\u306E\u64CD\u4F5C"
605
+ }
606
+ },
607
+ {
608
+ value: "drive",
609
+ label: {
610
+ en: "Drive \u2014 file create / share / download / delete",
611
+ ja: "Drive \u2014 \u30D5\u30A1\u30A4\u30EB\u306E\u4F5C\u6210\u30FB\u5171\u6709\u30FB\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9\u30FB\u524A\u9664"
612
+ }
613
+ },
614
+ {
615
+ value: "gcp",
616
+ label: {
617
+ en: "GCP \u2014 Workspace-linked GCP project events",
618
+ ja: "GCP \u2014 Workspace \u306B\u7D10\u3065\u304F GCP \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30A4\u30D9\u30F3\u30C8"
619
+ }
620
+ },
621
+ {
622
+ value: "gplus",
623
+ label: {
624
+ en: "Currents/Google+ \u2014 community events (legacy)",
625
+ ja: "Currents/Google+ \u2014 \u30B3\u30DF\u30E5\u30CB\u30C6\u30A3\u30A4\u30D9\u30F3\u30C8 (\u30EC\u30AC\u30B7\u30FC)"
626
+ }
627
+ },
628
+ {
629
+ value: "groups",
630
+ label: {
631
+ en: "Groups \u2014 group membership and settings",
632
+ ja: "Groups \u2014 \u30B0\u30EB\u30FC\u30D7\u30E1\u30F3\u30D0\u30FC\u30B7\u30C3\u30D7\u3068\u8A2D\u5B9A"
633
+ }
634
+ },
635
+ {
636
+ value: "groups_enterprise",
637
+ label: {
638
+ en: "Groups Enterprise \u2014 enterprise group activity",
639
+ ja: "Groups Enterprise \u2014 \u30A8\u30F3\u30BF\u30FC\u30D7\u30E9\u30A4\u30BA\u30B0\u30EB\u30FC\u30D7\u306E\u30A2\u30AF\u30C6\u30A3\u30D3\u30C6\u30A3"
640
+ }
641
+ },
642
+ {
643
+ value: "jamboard",
644
+ label: {
645
+ en: "Jamboard \u2014 Jamboard device events",
646
+ ja: "Jamboard \u2014 Jamboard \u30C7\u30D0\u30A4\u30B9\u30A4\u30D9\u30F3\u30C8"
647
+ }
648
+ },
649
+ {
650
+ value: "keep",
651
+ label: {
652
+ en: "Keep \u2014 Keep notes activity",
653
+ ja: "Keep \u2014 Keep \u306E\u30E1\u30E2\u64CD\u4F5C"
654
+ }
655
+ },
656
+ {
657
+ value: "login",
658
+ label: {
659
+ en: "Login \u2014 user sign-in successes and failures",
660
+ ja: "Login \u2014 \u30E6\u30FC\u30B6\u30FC\u306E\u30B5\u30A4\u30F3\u30A4\u30F3\u6210\u5426"
661
+ }
662
+ },
663
+ {
664
+ value: "meet",
665
+ label: {
666
+ en: "Meet \u2014 meeting and recording events",
667
+ ja: "Meet \u2014 \u4F1A\u8B70\u30FB\u9332\u753B\u30A4\u30D9\u30F3\u30C8"
668
+ }
669
+ },
670
+ {
671
+ value: "mobile",
672
+ label: {
673
+ en: "Mobile \u2014 managed mobile device events",
674
+ ja: "Mobile \u2014 \u7BA1\u7406\u5BFE\u8C61\u30E2\u30D0\u30A4\u30EB\u30C7\u30D0\u30A4\u30B9\u306E\u30A4\u30D9\u30F3\u30C8"
675
+ }
676
+ },
677
+ {
678
+ value: "rules",
679
+ label: {
680
+ en: "Rules \u2014 automated rule triggers",
681
+ ja: "Rules \u2014 \u81EA\u52D5\u30EB\u30FC\u30EB\u306E\u767A\u706B"
682
+ }
683
+ },
684
+ {
685
+ value: "saml",
686
+ label: {
687
+ en: "SAML \u2014 SAML SSO sign-in events",
688
+ ja: "SAML \u2014 SAML SSO \u30B5\u30A4\u30F3\u30A4\u30F3\u30A4\u30D9\u30F3\u30C8"
689
+ }
690
+ },
691
+ {
692
+ value: "token",
693
+ label: {
694
+ en: "Token \u2014 OAuth token grants and revocations",
695
+ ja: "Token \u2014 OAuth \u30C8\u30FC\u30AF\u30F3\u306E\u4ED8\u4E0E\u30FB\u53D6\u308A\u6D88\u3057"
696
+ }
697
+ },
698
+ {
699
+ value: "user_accounts",
700
+ label: {
701
+ en: "User Accounts \u2014 end-user account self-service",
702
+ ja: "User Accounts \u2014 \u30A8\u30F3\u30C9\u30E6\u30FC\u30B6\u30FC\u306E\u30A2\u30AB\u30A6\u30F3\u30C8\u64CD\u4F5C"
703
+ }
704
+ },
705
+ {
706
+ value: "vault",
707
+ label: {
708
+ en: "Vault \u2014 eDiscovery / retention activity",
709
+ ja: "Vault \u2014 eDiscovery\u30FB\u30C7\u30FC\u30BF\u4FDD\u6301\u306E\u64CD\u4F5C"
710
+ }
711
+ }
712
+ ];
713
+ var googleAuditLogSetupFlow = {
714
+ initialState: () => ({}),
715
+ steps: [
716
+ {
717
+ slug: "applications",
718
+ type: "multiSelect",
719
+ question: {
720
+ ja: "\u5BFE\u8C61\u306E Workspace \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\uFF08\u76E3\u67FB\u5BFE\u8C61\uFF09\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
721
+ en: "Select target Workspace applications to audit (multi-select allowed)"
722
+ },
723
+ async fetchOptions(_state, rt) {
724
+ return [
725
+ {
726
+ value: ALL_APPLICATIONS,
727
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3" : "All applications"
728
+ },
729
+ ...APPLICATIONS.map((a) => ({
730
+ value: a.value,
731
+ label: a.label[rt.language]
732
+ }))
733
+ ];
734
+ },
735
+ applyAnswer: (state, answer) => ({ ...state, applications: answer })
736
+ }
737
+ ],
738
+ async finalize(state, rt) {
739
+ if (!state.applications) {
740
+ throw new Error(
741
+ "Google Audit Log setup: incomplete state on finalize"
742
+ );
743
+ }
744
+ const targetApplications = await resolveSetupSelection({
745
+ selected: state.applications,
746
+ allSentinel: ALL_APPLICATIONS,
747
+ fetchAll: async () => APPLICATIONS.map((a) => a.value),
748
+ limit: GOOGLE_AUDIT_LOG_SETUP_MAX_APPS
749
+ });
750
+ const labelByValue = new Map(
751
+ APPLICATIONS.map((a) => [a.value, a.label[rt.language]])
752
+ );
753
+ const sections = ["## Google Workspace Audit Log", ""];
754
+ if (targetApplications.length === 0) {
755
+ sections.push("_No applications selected._", "");
756
+ return sections.join("\n");
757
+ }
758
+ sections.push("| Application | Description |");
759
+ sections.push("|-------------|-------------|");
760
+ for (const app of targetApplications) {
761
+ const desc = (labelByValue.get(app) ?? app).replace(/\|/g, "\\|");
762
+ sections.push(`| ${app} | ${desc} |`);
763
+ }
764
+ sections.push("");
765
+ return sections.join("\n");
766
+ }
767
+ };
768
+
482
769
  // ../connectors/src/connectors/google-audit-log/index.ts
483
770
  var tools = { request_with_delegation: requestWithDelegationTool };
484
771
  var googleAuditLogConnector = new ConnectorPlugin({
@@ -670,7 +957,57 @@ export default async function handler(c: Context) {
670
957
  }
671
958
  \`\`\``
672
959
  },
673
- tools
960
+ tools,
961
+ setup: (params, ctx, config) => runSetupFlow(googleAuditLogSetupFlow, params, ctx, config),
962
+ async checkConnection(params, _config) {
963
+ const keyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
964
+ if (!keyJsonBase64) {
965
+ return {
966
+ success: false,
967
+ error: "google-audit-log: missing service account key"
968
+ };
969
+ }
970
+ let sa;
971
+ try {
972
+ const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
973
+ sa = JSON.parse(decoded);
974
+ } catch (err) {
975
+ const msg = err instanceof Error ? err.message : String(err);
976
+ return {
977
+ success: false,
978
+ error: `google-audit-log: failed to parse service account JSON: ${msg}`
979
+ };
980
+ }
981
+ if (!sa.client_email || !sa.private_key) {
982
+ return {
983
+ success: false,
984
+ error: "google-audit-log: service account JSON must contain client_email and private_key"
985
+ };
986
+ }
987
+ try {
988
+ const { GoogleAuth } = await import("google-auth-library");
989
+ const auth = new GoogleAuth({
990
+ credentials: {
991
+ client_email: sa.client_email,
992
+ private_key: sa.private_key
993
+ },
994
+ scopes: [
995
+ "https://www.googleapis.com/auth/admin.reports.audit.readonly"
996
+ ]
997
+ });
998
+ const token = await auth.getAccessToken();
999
+ if (!token) {
1000
+ return {
1001
+ success: false,
1002
+ error: "google-audit-log: failed to obtain access token"
1003
+ };
1004
+ }
1005
+ return { success: true };
1006
+ } catch (err) {
1007
+ const msg = err instanceof Error ? err.message : String(err);
1008
+ return { success: false, error: msg };
1009
+ }
1010
+ }
674
1011
  });
675
1012
 
676
1013
  // src/connectors/create-connector-sdk.ts
@@ -699,6 +1036,7 @@ function resolveEnvVarOptional(entry, key) {
699
1036
  import { getContext } from "hono/context-storage";
700
1037
  import { getCookie } from "hono/cookie";
701
1038
  var APP_SESSION_COOKIE_NAME = "__Host-squadbase-session";
1039
+ var TABLEAU_SESSION_SENTINEL_URL = "squadbase://tableau-session/";
702
1040
  function normalizeHeaders(input) {
703
1041
  const out = {};
704
1042
  if (!input) return out;
@@ -707,6 +1045,11 @@ function normalizeHeaders(input) {
707
1045
  });
708
1046
  return out;
709
1047
  }
1048
+ function extractInputUrl(input) {
1049
+ if (typeof input === "string") return input;
1050
+ if (input instanceof URL) return input.href;
1051
+ return input.url;
1052
+ }
710
1053
  function createSandboxProxyFetch(connectionId) {
711
1054
  return async (input, init) => {
712
1055
  const token = process.env.INTERNAL_SQUADBASE_OAUTH_MACHINE_CREDENTIAL;
@@ -716,10 +1059,17 @@ function createSandboxProxyFetch(connectionId) {
716
1059
  "Connection proxy is not configured. Please check your deployment settings."
717
1060
  );
718
1061
  }
719
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
1062
+ const originalUrl = extractInputUrl(input);
1063
+ const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
1064
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
1065
+ const sessionUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
1066
+ return fetch(sessionUrl, {
1067
+ method: "POST",
1068
+ headers: { Authorization: `Bearer ${token}` }
1069
+ });
1070
+ }
720
1071
  const originalMethod = init?.method ?? "GET";
721
1072
  const originalBody = init?.body ? JSON.parse(init.body) : void 0;
722
- const baseDomain = process.env["SQUADBASE_PREVIEW_BASE_DOMAIN"] ?? "preview.app.squadbase.dev";
723
1073
  const proxyUrl = `https://${sandboxId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
724
1074
  return fetch(proxyUrl, {
725
1075
  method: "POST",
@@ -745,10 +1095,9 @@ function createDeployedAppProxyFetch(connectionId) {
745
1095
  }
746
1096
  const baseDomain = process.env["SQUADBASE_APP_BASE_DOMAIN"] ?? "squadbase.app";
747
1097
  const proxyUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/request`;
1098
+ const sessionUrl = `https://${projectId}.${baseDomain}/_sqcore/connections/${connectionId}/tableau-session`;
748
1099
  return async (input, init) => {
749
- const originalUrl = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
750
- const originalMethod = init?.method ?? "GET";
751
- const originalBody = init?.body ? JSON.parse(init.body) : void 0;
1100
+ const originalUrl = extractInputUrl(input);
752
1101
  const c = getContext();
753
1102
  const appSession = getCookie(c, APP_SESSION_COOKIE_NAME);
754
1103
  if (!appSession) {
@@ -756,6 +1105,14 @@ function createDeployedAppProxyFetch(connectionId) {
756
1105
  "No authentication method available for connection proxy."
757
1106
  );
758
1107
  }
1108
+ if (originalUrl === TABLEAU_SESSION_SENTINEL_URL) {
1109
+ return fetch(sessionUrl, {
1110
+ method: "POST",
1111
+ headers: { Authorization: `Bearer ${appSession}` }
1112
+ });
1113
+ }
1114
+ const originalMethod = init?.method ?? "GET";
1115
+ const originalBody = init?.body ? JSON.parse(init.body) : void 0;
759
1116
  return fetch(proxyUrl, {
760
1117
  method: "POST",
761
1118
  headers: {